blob: bed5996fffc38b2c42cd66406cf21b5ce377582a [file] [log] [blame]
[email protected]1fdb89f2012-02-03 23:26:441// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]e12de87e2009-08-28 00:02:082// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
6#define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
7
[email protected]790788ac2010-04-06 17:52:198#include <deque>
[email protected]84abba62009-10-07 17:01:449#include <map>
[email protected]e12de87e2009-08-28 00:02:0810#include <set>
[email protected]525074d2011-03-07 22:32:2711#include <string>
12#include <vector>
[email protected]e12de87e2009-08-28 00:02:0813
[email protected]e1f0fc32011-12-01 08:58:1714#include "base/callback.h"
[email protected]ea52f512011-03-08 19:55:5115#include "base/compiler_specific.h"
[email protected]3b63f8f42011-03-28 01:54:1516#include "base/memory/scoped_ptr.h"
17#include "base/memory/weak_ptr.h"
[email protected]fb441962013-05-08 05:35:2418#include "base/sequenced_task_runner_helpers.h"
[email protected]4449a40c2011-05-03 19:29:5219#include "base/synchronization/waitable_event.h"
[email protected]e8cc8b32011-08-24 10:40:5420#include "base/values.h"
[email protected]ac43f702010-10-26 20:18:4521#include "chrome/browser/automation/automation_provider_json.h"
[email protected]eb0bff942011-04-07 22:08:3822#include "chrome/browser/automation/automation_tab_helper.h"
[email protected]6d8ffc9f2010-03-12 18:27:5323#include "chrome/browser/bookmarks/bookmark_model_observer.h"
[email protected]e4b2fa32013-03-09 22:56:5624#include "components/autofill/browser/personal_data_manager.h"
25#include "components/autofill/browser/personal_data_manager_observer.h"
[email protected]60ae33e2011-03-10 00:44:3426#if defined(OS_CHROMEOS)
27#include "chrome/browser/chromeos/cros/network_library.h"
[email protected]02549802013-04-22 18:25:5128#include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
[email protected]3b10fdeb2011-05-06 00:17:2529#include "chrome/browser/chromeos/login/login_status_consumer.h"
[email protected]61a9fb32011-08-03 21:00:5130#include "chrome/browser/chromeos/login/user_manager.h"
[email protected]6a33bb92011-07-28 02:41:1931#include "chrome/browser/chromeos/login/wizard_controller.h"
[email protected]60ae33e2011-03-10 00:44:3432#endif // defined(OS_CHROMEOS)
[email protected]01b654b2012-09-22 02:16:4433#include "chrome/browser/common/cancelable_request.h"
[email protected]73c43482012-11-07 16:53:1934#include "chrome/browser/download/all_download_item_notifier.h"
[email protected]6a2c09f2013-01-25 04:50:0735#include "chrome/browser/history/history_service.h"
[email protected]5783990a2010-11-19 00:24:4836#include "chrome/browser/history/history_types.h"
[email protected]c5aa5322010-07-15 19:00:0737#include "chrome/browser/importer/importer_data_types.h"
[email protected]ea52f512011-03-08 19:55:5138#include "chrome/browser/importer/importer_progress_observer.h"
[email protected]b0539752011-09-23 00:33:1539#include "chrome/browser/memory_details.h"
[email protected]08a3b9bb2011-05-26 19:59:2940#include "chrome/browser/password_manager/password_store_change.h"
[email protected]e5721c182011-03-28 22:27:3441#include "chrome/browser/password_manager/password_store_consumer.h"
[email protected]8e5c89a2011-06-07 18:13:3342#include "chrome/browser/search_engines/template_url_service_observer.h"
[email protected]b56e2e32012-05-11 21:18:0443#include "chrome/browser/ui/tabs/tab_strip_model.h"
[email protected]a22f7e02011-02-09 07:15:3544#include "chrome/common/automation_constants.h"
[email protected]cef7a5e2011-04-13 22:15:3145#include "chrome/common/extensions/extension_constants.h"
[email protected]b7b63872013-01-03 02:41:1946#include "content/public/browser/browser_thread.h"
[email protected]e582fdd2011-12-20 16:48:1747#include "content/public/browser/download_item.h"
48#include "content/public/browser/download_manager.h"
[email protected]6c2381d2011-10-19 02:52:5349#include "content/public/browser/notification_observer.h"
50#include "content/public/browser/notification_registrar.h"
[email protected]0d6e9bd2011-10-18 04:29:1651#include "content/public/browser/notification_types.h"
[email protected]165901feb2012-05-23 15:38:2252#include "content/public/browser/render_view_host_observer.h"
53#include "ui/gfx/point.h"
[email protected]a22f7e02011-02-09 07:15:3554#include "ui/gfx/size.h"
[email protected]e12de87e2009-08-28 00:02:0855
[email protected]165901feb2012-05-23 15:38:2256struct AutomationMouseEvent;
[email protected]e12de87e2009-08-28 00:02:0857class AutomationProvider;
[email protected]ac43f702010-10-26 20:18:4558class BalloonCollection;
[email protected]e12de87e2009-08-28 00:02:0859class Browser;
[email protected]790788ac2010-04-06 17:52:1960class ExtensionProcessManager;
[email protected]0e0bbb12011-08-23 18:42:1761class ExtensionService;
[email protected]0fb286e2011-10-18 19:34:4062class Notification;
[email protected]04024e2c2011-08-12 19:32:1063class Profile;
[email protected]7060bb292010-06-24 00:52:4964class SavePackage;
[email protected]e12de87e2009-08-28 00:02:0865
[email protected]165901feb2012-05-23 15:38:2266namespace automation {
67class Error;
68}
69
[email protected]3b10fdeb2011-05-06 00:17:2570#if defined(OS_CHROMEOS)
71namespace chromeos {
[email protected]64b1b48ef2012-06-04 13:43:5472class ExistingUserController;
73class WizardScreen;
[email protected]3b10fdeb2011-05-06 00:17:2574}
75#endif // defined(OS_CHROMEOS)
76
[email protected]768c5472011-12-26 19:06:1777namespace content {
[email protected]cca0f1e2012-01-03 18:27:4678class NavigationController;
[email protected]eaabba22012-03-07 15:02:1179class RenderViewHost;
[email protected]768c5472011-12-26 19:06:1780class WebContents;
81}
82
[email protected]1c321ee2012-05-21 03:02:3483namespace extensions {
84class Extension;
85}
86
[email protected]768c5472011-12-26 19:06:1787namespace history {
88class TopSites;
89}
90
[email protected]aa190632012-12-04 07:39:5391namespace IPC {
92class Message;
93}
94
[email protected]e1f0fc32011-12-01 08:58:1795namespace policy {
96class BrowserPolicyConnector;
97}
98
[email protected]6c2381d2011-10-19 02:52:5399class InitialLoadObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08100 public:
101 InitialLoadObserver(size_t tab_count, AutomationProvider* automation);
[email protected]b6ce91b2011-02-10 21:30:50102 virtual ~InitialLoadObserver();
[email protected]e12de87e2009-08-28 00:02:08103
[email protected]4ad6c3a2012-06-14 00:31:17104 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27105 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53106 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17107 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08108
[email protected]a3cd5022010-06-16 18:25:29109 // Caller owns the return value and is responsible for deleting it.
110 // Example return value:
111 // {'tabs': [{'start_time_ms': 1, 'stop_time_ms': 2.5},
112 // {'start_time_ms': 0.5, 'stop_time_ms': 3}]}
113 // stop_time_ms values may be null if WaitForInitialLoads has not finished.
114 // Only includes entries for the |tab_count| tabs we are monitoring.
115 // There is no defined ordering of the return value.
[email protected]f3a1c642011-07-12 19:15:03116 base::DictionaryValue* GetTimingInformation() const;
[email protected]a3cd5022010-06-16 18:25:29117
[email protected]e12de87e2009-08-28 00:02:08118 private:
[email protected]a3cd5022010-06-16 18:25:29119 class TabTime;
120 typedef std::map<uintptr_t, TabTime> TabTimeMap;
[email protected]e12de87e2009-08-28 00:02:08121 typedef std::set<uintptr_t> TabSet;
122
123 void ConditionMet();
124
[email protected]6c2381d2011-10-19 02:52:53125 content::NotificationRegistrar registrar_;
[email protected]e12de87e2009-08-28 00:02:08126
[email protected]7d9aecf2011-02-09 11:58:03127 base::WeakPtr<AutomationProvider> automation_;
[email protected]2ce26c432011-09-19 17:08:12128 size_t crashed_tab_count_;
[email protected]e12de87e2009-08-28 00:02:08129 size_t outstanding_tab_count_;
[email protected]a3cd5022010-06-16 18:25:29130 base::TimeTicks init_time_;
131 TabTimeMap loading_tabs_;
[email protected]e12de87e2009-08-28 00:02:08132 TabSet finished_tabs_;
133
134 DISALLOW_COPY_AND_ASSIGN(InitialLoadObserver);
135};
136
[email protected]60ae33e2011-03-10 00:44:34137#if defined(OS_CHROMEOS)
138// Watches for NetworkManager events. Because NetworkLibrary loads
139// asynchronously, this is used to make sure it is done before tests are run.
140class NetworkManagerInitObserver
141 : public chromeos::NetworkLibrary::NetworkManagerObserver {
142 public:
143 explicit NetworkManagerInitObserver(AutomationProvider* automation);
144 virtual ~NetworkManagerInitObserver();
[email protected]8989bb42011-03-26 00:33:21145 virtual bool Init();
[email protected]60ae33e2011-03-10 00:44:34146 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj);
147
148 private:
149 base::WeakPtr<AutomationProvider> automation_;
150
151 DISALLOW_COPY_AND_ASSIGN(NetworkManagerInitObserver);
152};
[email protected]b1bb86d2011-09-02 18:20:51153
[email protected]a105fa32012-05-16 21:32:05154// Observes when the ChromeOS login WebUI becomes ready (by showing the login
155// form, account picker, a network error or the OOBE wizard, depending on Chrome
156// flags and state).
[email protected]64b1b48ef2012-06-04 13:43:54157class OOBEWebuiReadyObserver : public content::NotificationObserver {
[email protected]b1bb86d2011-09-02 18:20:51158 public:
[email protected]64b1b48ef2012-06-04 13:43:54159 explicit OOBEWebuiReadyObserver(AutomationProvider* automation);
[email protected]4ad6c3a2012-06-14 00:31:17160
161 // Overridden from content::NotificationObserver:
[email protected]b1bb86d2011-09-02 18:20:51162 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53163 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17164 const content::NotificationDetails& details) OVERRIDE;
[email protected]b1bb86d2011-09-02 18:20:51165
166 private:
[email protected]64b1b48ef2012-06-04 13:43:54167 void OOBEWebuiReady();
168
[email protected]6c2381d2011-10-19 02:52:53169 content::NotificationRegistrar registrar_;
[email protected]b1bb86d2011-09-02 18:20:51170 base::WeakPtr<AutomationProvider> automation_;
171
[email protected]64b1b48ef2012-06-04 13:43:54172 DISALLOW_COPY_AND_ASSIGN(OOBEWebuiReadyObserver);
[email protected]b1bb86d2011-09-02 18:20:51173};
[email protected]60ae33e2011-03-10 00:44:34174#endif // defined(OS_CHROMEOS)
175
[email protected]e12de87e2009-08-28 00:02:08176// Watches for NewTabUI page loads for performance timing purposes.
[email protected]6c2381d2011-10-19 02:52:53177class NewTabUILoadObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08178 public:
[email protected]04024e2c2011-08-12 19:32:10179 explicit NewTabUILoadObserver(AutomationProvider* automation,
180 Profile* profile);
[email protected]b6ce91b2011-02-10 21:30:50181 virtual ~NewTabUILoadObserver();
[email protected]e12de87e2009-08-28 00:02:08182
[email protected]4ad6c3a2012-06-14 00:31:17183 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27184 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53185 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17186 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08187
188 private:
[email protected]6c2381d2011-10-19 02:52:53189 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03190 base::WeakPtr<AutomationProvider> automation_;
[email protected]e12de87e2009-08-28 00:02:08191
192 DISALLOW_COPY_AND_ASSIGN(NewTabUILoadObserver);
193};
194
[email protected]6c2381d2011-10-19 02:52:53195class NavigationControllerRestoredObserver
196 : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08197 public:
[email protected]cca0f1e2012-01-03 18:27:46198 NavigationControllerRestoredObserver(
199 AutomationProvider* automation,
200 content::NavigationController* controller,
201 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:50202 virtual ~NavigationControllerRestoredObserver();
[email protected]e12de87e2009-08-28 00:02:08203
[email protected]4ad6c3a2012-06-14 00:31:17204 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27205 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53206 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17207 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08208
209 private:
210 bool FinishedRestoring();
211 void SendDone();
212
[email protected]6c2381d2011-10-19 02:52:53213 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03214 base::WeakPtr<AutomationProvider> automation_;
[email protected]cca0f1e2012-01-03 18:27:46215 content::NavigationController* controller_;
[email protected]7d9aecf2011-02-09 11:58:03216 scoped_ptr<IPC::Message> reply_message_;
[email protected]e12de87e2009-08-28 00:02:08217
218 DISALLOW_COPY_AND_ASSIGN(NavigationControllerRestoredObserver);
219};
220
[email protected]6c2381d2011-10-19 02:52:53221class NavigationNotificationObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08222 public:
[email protected]cca0f1e2012-01-03 18:27:46223 NavigationNotificationObserver(content::NavigationController* controller,
[email protected]e12de87e2009-08-28 00:02:08224 AutomationProvider* automation,
225 IPC::Message* reply_message,
[email protected]7dad3d5f2010-03-04 00:27:01226 int number_of_navigations,
[email protected]ab6bb8e2011-03-03 22:41:16227 bool include_current_navigation,
228 bool use_json_interface);
[email protected]b6ce91b2011-02-10 21:30:50229 virtual ~NavigationNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08230
[email protected]4ad6c3a2012-06-14 00:31:17231 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27232 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53233 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17234 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08235
[email protected]e12de87e2009-08-28 00:02:08236 void ConditionMet(AutomationMsg_NavigationResponseValues navigation_result);
237
[email protected]b336ce62012-06-08 20:35:57238 private:
[email protected]6c2381d2011-10-19 02:52:53239 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03240 base::WeakPtr<AutomationProvider> automation_;
241 scoped_ptr<IPC::Message> reply_message_;
[email protected]cca0f1e2012-01-03 18:27:46242 content::NavigationController* controller_;
[email protected]e12de87e2009-08-28 00:02:08243 int navigations_remaining_;
244 bool navigation_started_;
[email protected]ab6bb8e2011-03-03 22:41:16245 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08246
247 DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver);
248};
249
[email protected]6c2381d2011-10-19 02:52:53250class TabStripNotificationObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08251 public:
[email protected]432115822011-07-10 15:52:27252 TabStripNotificationObserver(int notification,
[email protected]e12de87e2009-08-28 00:02:08253 AutomationProvider* automation);
254 virtual ~TabStripNotificationObserver();
255
[email protected]4ad6c3a2012-06-14 00:31:17256 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27257 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53258 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17259 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08260
[email protected]cca0f1e2012-01-03 18:27:46261 virtual void ObserveTab(content::NavigationController* controller) = 0;
[email protected]e12de87e2009-08-28 00:02:08262
263 protected:
[email protected]6c2381d2011-10-19 02:52:53264 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03265 base::WeakPtr<AutomationProvider> automation_;
[email protected]432115822011-07-10 15:52:27266 int notification_;
[email protected]e12de87e2009-08-28 00:02:08267};
268
269class TabAppendedNotificationObserver : public TabStripNotificationObserver {
270 public:
271 TabAppendedNotificationObserver(Browser* parent,
272 AutomationProvider* automation,
[email protected]642858552012-07-13 06:56:52273 IPC::Message* reply_message,
274 bool use_json_interface);
[email protected]b6ce91b2011-02-10 21:30:50275 virtual ~TabAppendedNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08276
[email protected]cca0f1e2012-01-03 18:27:46277 virtual void ObserveTab(content::NavigationController* controller);
[email protected]642858552012-07-13 06:56:52278 IPC::Message* ReleaseReply();
[email protected]e12de87e2009-08-28 00:02:08279
280 protected:
281 Browser* parent_;
[email protected]7d9aecf2011-02-09 11:58:03282 scoped_ptr<IPC::Message> reply_message_;
[email protected]642858552012-07-13 06:56:52283 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08284
285 private:
286 DISALLOW_COPY_AND_ASSIGN(TabAppendedNotificationObserver);
287};
288
289class TabClosedNotificationObserver : public TabStripNotificationObserver {
290 public:
291 TabClosedNotificationObserver(AutomationProvider* automation,
292 bool wait_until_closed,
[email protected]16a517a2012-07-14 01:08:58293 IPC::Message* reply_message,
294 bool use_json_interface);
[email protected]b6ce91b2011-02-10 21:30:50295 virtual ~TabClosedNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08296
[email protected]cca0f1e2012-01-03 18:27:46297 virtual void ObserveTab(content::NavigationController* controller);
[email protected]e12de87e2009-08-28 00:02:08298
299 void set_for_browser_command(bool for_browser_command);
300
301 protected:
[email protected]7d9aecf2011-02-09 11:58:03302 scoped_ptr<IPC::Message> reply_message_;
[email protected]16a517a2012-07-14 01:08:58303 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08304 bool for_browser_command_;
305
306 private:
307 DISALLOW_COPY_AND_ASSIGN(TabClosedNotificationObserver);
308};
309
[email protected]61855fc2010-09-07 19:32:13310// Notifies when the tab count reaches the target number.
311class TabCountChangeObserver : public TabStripModelObserver {
312 public:
313 TabCountChangeObserver(AutomationProvider* automation,
314 Browser* browser,
315 IPC::Message* reply_message,
316 int target_tab_count);
317 // Implementation of TabStripModelObserver.
[email protected]409ea2972012-11-10 19:54:43318 virtual void TabInsertedAt(content::WebContents* contents,
[email protected]61855fc2010-09-07 19:32:13319 int index,
[email protected]409ea2972012-11-10 19:54:43320 bool foreground) OVERRIDE;
[email protected]e89cfcb2012-11-11 14:47:24321 virtual void TabDetachedAt(content::WebContents* contents,
322 int index) OVERRIDE;
[email protected]409ea2972012-11-10 19:54:43323 virtual void TabStripModelDeleted() OVERRIDE;
[email protected]61855fc2010-09-07 19:32:13324
325 private:
[email protected]b6ce91b2011-02-10 21:30:50326 virtual ~TabCountChangeObserver();
[email protected]61855fc2010-09-07 19:32:13327
328 // Checks if the current tab count matches our target, and if so,
329 // sends the reply message and deletes self.
330 void CheckTabCount();
331
[email protected]7d9aecf2011-02-09 11:58:03332 base::WeakPtr<AutomationProvider> automation_;
333 scoped_ptr<IPC::Message> reply_message_;
[email protected]61855fc2010-09-07 19:32:13334
335 TabStripModel* tab_strip_model_;
336
337 const int target_tab_count_;
338
339 DISALLOW_COPY_AND_ASSIGN(TabCountChangeObserver);
340};
341
[email protected]99a1aef2011-03-29 17:17:23342// Observes when an extension has been uninstalled.
[email protected]6c2381d2011-10-19 02:52:53343class ExtensionUninstallObserver : public content::NotificationObserver {
[email protected]99a1aef2011-03-29 17:17:23344 public:
345 ExtensionUninstallObserver(AutomationProvider* automation,
346 IPC::Message* reply_message,
347 const std::string& id);
348 virtual ~ExtensionUninstallObserver();
349
[email protected]4ad6c3a2012-06-14 00:31:17350 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27351 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53352 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17353 const content::NotificationDetails& details) OVERRIDE;
[email protected]99a1aef2011-03-29 17:17:23354
355 private:
[email protected]6c2381d2011-10-19 02:52:53356 content::NotificationRegistrar registrar_;
[email protected]99a1aef2011-03-29 17:17:23357 base::WeakPtr<AutomationProvider> automation_;
358 scoped_ptr<IPC::Message> reply_message_;
359 std::string id_;
360
361 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallObserver);
362};
363
[email protected]790788ac2010-04-06 17:52:19364// Observes when an extension has finished loading and is ready for use. Also
365// checks for possible install errors.
[email protected]6c2381d2011-10-19 02:52:53366class ExtensionReadyNotificationObserver
367 : public content::NotificationObserver {
[email protected]790788ac2010-04-06 17:52:19368 public:
[email protected]1d4bae62011-11-29 13:27:30369 // Creates an observer that replies using the JSON automation interface.
370 ExtensionReadyNotificationObserver(ExtensionProcessManager* manager,
371 ExtensionService* service,
372 AutomationProvider* automation,
373 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:50374 virtual ~ExtensionReadyNotificationObserver();
[email protected]790788ac2010-04-06 17:52:19375
[email protected]4ad6c3a2012-06-14 00:31:17376 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27377 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53378 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17379 const content::NotificationDetails& details) OVERRIDE;
[email protected]790788ac2010-04-06 17:52:19380
381 private:
[email protected]1d4bae62011-11-29 13:27:30382 void Init();
383
[email protected]6c2381d2011-10-19 02:52:53384 content::NotificationRegistrar registrar_;
[email protected]790788ac2010-04-06 17:52:19385 ExtensionProcessManager* manager_;
[email protected]0e0bbb12011-08-23 18:42:17386 ExtensionService* service_;
[email protected]7d9aecf2011-02-09 11:58:03387 base::WeakPtr<AutomationProvider> automation_;
[email protected]7d9aecf2011-02-09 11:58:03388 scoped_ptr<IPC::Message> reply_message_;
[email protected]1c321ee2012-05-21 03:02:34389 const extensions::Extension* extension_;
[email protected]790788ac2010-04-06 17:52:19390
391 DISALLOW_COPY_AND_ASSIGN(ExtensionReadyNotificationObserver);
392};
393
[email protected]6c2381d2011-10-19 02:52:53394class ExtensionUnloadNotificationObserver
395 : public content::NotificationObserver {
[email protected]790788ac2010-04-06 17:52:19396 public:
397 ExtensionUnloadNotificationObserver();
[email protected]b6ce91b2011-02-10 21:30:50398 virtual ~ExtensionUnloadNotificationObserver();
[email protected]790788ac2010-04-06 17:52:19399
[email protected]4ad6c3a2012-06-14 00:31:17400 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27401 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53402 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17403 const content::NotificationDetails& details) OVERRIDE;
[email protected]790788ac2010-04-06 17:52:19404
405 bool did_receive_unload_notification() {
406 return did_receive_unload_notification_;
407 }
408
409 private:
[email protected]6c2381d2011-10-19 02:52:53410 content::NotificationRegistrar registrar_;
[email protected]790788ac2010-04-06 17:52:19411 bool did_receive_unload_notification_;
412
413 DISALLOW_COPY_AND_ASSIGN(ExtensionUnloadNotificationObserver);
414};
415
[email protected]2bb2ee82012-11-13 23:24:03416// Observes when the extensions have been fully updated. The ExtensionUpdater
417// service provides a notification whem all the updated extensions have been
418// installed, but it does not wait for all of them to be loaded too. This
[email protected]6a0322f2011-04-11 19:45:48419// observer waits until all updated extensions have actually been loaded.
[email protected]6c2381d2011-10-19 02:52:53420class ExtensionsUpdatedObserver : public content::NotificationObserver {
[email protected]6a0322f2011-04-11 19:45:48421 public:
422 ExtensionsUpdatedObserver(ExtensionProcessManager* manager,
423 AutomationProvider* automation,
424 IPC::Message* reply_message);
425 virtual ~ExtensionsUpdatedObserver();
426
[email protected]4ad6c3a2012-06-14 00:31:17427 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27428 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53429 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17430 const content::NotificationDetails& details) OVERRIDE;
[email protected]6a0322f2011-04-11 19:45:48431
[email protected]2bb2ee82012-11-13 23:24:03432 // Called by ExtensionUpdater when it has finished updating extensions.
433 void UpdateCheckFinished();
434
[email protected]6a0322f2011-04-11 19:45:48435 private:
[email protected]2bb2ee82012-11-13 23:24:03436 void MaybeReply();
437
[email protected]6c2381d2011-10-19 02:52:53438 content::NotificationRegistrar registrar_;
[email protected]6a0322f2011-04-11 19:45:48439 ExtensionProcessManager* manager_;
440 base::WeakPtr<AutomationProvider> automation_;
441 scoped_ptr<IPC::Message> reply_message_;
[email protected]6a0322f2011-04-11 19:45:48442 bool updater_finished_;
443
444 DISALLOW_COPY_AND_ASSIGN(ExtensionsUpdatedObserver);
445};
446
[email protected]300e4c92011-04-14 19:16:47447// Observes when a new browser has been opened and a tab within it has stopped
448// loading.
[email protected]6c2381d2011-10-19 02:52:53449class BrowserOpenedNotificationObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08450 public:
451 BrowserOpenedNotificationObserver(AutomationProvider* automation,
[email protected]16a517a2012-07-14 01:08:58452 IPC::Message* reply_message,
453 bool use_json_interface);
[email protected]b6ce91b2011-02-10 21:30:50454 virtual ~BrowserOpenedNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08455
[email protected]4ad6c3a2012-06-14 00:31:17456 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27457 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53458 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17459 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08460
461 void set_for_browser_command(bool for_browser_command);
462
463 private:
[email protected]6c2381d2011-10-19 02:52:53464 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03465 base::WeakPtr<AutomationProvider> automation_;
466 scoped_ptr<IPC::Message> reply_message_;
[email protected]300e4c92011-04-14 19:16:47467 int new_window_id_;
[email protected]16a517a2012-07-14 01:08:58468 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08469 bool for_browser_command_;
470
471 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedNotificationObserver);
472};
473
[email protected]6c2381d2011-10-19 02:52:53474class BrowserClosedNotificationObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08475 public:
476 BrowserClosedNotificationObserver(Browser* browser,
477 AutomationProvider* automation,
[email protected]16a517a2012-07-14 01:08:58478 IPC::Message* reply_message,
479 bool use_json_interface);
[email protected]b6ce91b2011-02-10 21:30:50480 virtual ~BrowserClosedNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08481
[email protected]4ad6c3a2012-06-14 00:31:17482 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27483 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53484 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17485 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08486
487 void set_for_browser_command(bool for_browser_command);
488
489 private:
[email protected]6c2381d2011-10-19 02:52:53490 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03491 base::WeakPtr<AutomationProvider> automation_;
492 scoped_ptr<IPC::Message> reply_message_;
[email protected]16a517a2012-07-14 01:08:58493 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08494 bool for_browser_command_;
495
496 DISALLOW_COPY_AND_ASSIGN(BrowserClosedNotificationObserver);
497};
498
[email protected]6c2381d2011-10-19 02:52:53499class BrowserCountChangeNotificationObserver
500 : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08501 public:
502 BrowserCountChangeNotificationObserver(int target_count,
503 AutomationProvider* automation,
504 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:50505 virtual ~BrowserCountChangeNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08506
[email protected]4ad6c3a2012-06-14 00:31:17507 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27508 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53509 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17510 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08511
512 private:
513 int target_count_;
[email protected]6c2381d2011-10-19 02:52:53514 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03515 base::WeakPtr<AutomationProvider> automation_;
516 scoped_ptr<IPC::Message> reply_message_;
[email protected]e12de87e2009-08-28 00:02:08517
518 DISALLOW_COPY_AND_ASSIGN(BrowserCountChangeNotificationObserver);
519};
520
[email protected]6c2381d2011-10-19 02:52:53521class ExecuteBrowserCommandObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08522 public:
[email protected]b6ce91b2011-02-10 21:30:50523 virtual ~ExecuteBrowserCommandObserver();
[email protected]e12de87e2009-08-28 00:02:08524
525 static bool CreateAndRegisterObserver(AutomationProvider* automation,
526 Browser* browser,
527 int command,
[email protected]16a517a2012-07-14 01:08:58528 IPC::Message* reply_message,
529 bool use_json_interface);
[email protected]e12de87e2009-08-28 00:02:08530
[email protected]4ad6c3a2012-06-14 00:31:17531 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27532 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53533 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17534 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08535
536 private:
537 ExecuteBrowserCommandObserver(AutomationProvider* automation,
[email protected]16a517a2012-07-14 01:08:58538 IPC::Message* reply_message,
539 bool use_json_interface);
[email protected]e12de87e2009-08-28 00:02:08540
541 bool Register(int command);
542
[email protected]432115822011-07-10 15:52:27543 bool Getint(int command, int* type);
[email protected]e12de87e2009-08-28 00:02:08544
[email protected]16a517a2012-07-14 01:08:58545 IPC::Message* ReleaseReply();
546
[email protected]6c2381d2011-10-19 02:52:53547 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03548 base::WeakPtr<AutomationProvider> automation_;
[email protected]432115822011-07-10 15:52:27549 int notification_type_;
[email protected]7d9aecf2011-02-09 11:58:03550 scoped_ptr<IPC::Message> reply_message_;
[email protected]16a517a2012-07-14 01:08:58551 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08552
553 DISALLOW_COPY_AND_ASSIGN(ExecuteBrowserCommandObserver);
554};
555
[email protected]6c2381d2011-10-19 02:52:53556class FindInPageNotificationObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08557 public:
558 FindInPageNotificationObserver(AutomationProvider* automation,
[email protected]fbc5e5f92012-01-02 06:08:32559 content::WebContents* parent_tab,
[email protected]f9e3c522010-10-08 00:41:26560 bool reply_with_json,
[email protected]e12de87e2009-08-28 00:02:08561 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:50562 virtual ~FindInPageNotificationObserver();
[email protected]e12de87e2009-08-28 00:02:08563
[email protected]4ad6c3a2012-06-14 00:31:17564 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27565 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53566 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17567 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08568
569 // The Find mechanism is over asynchronous IPC, so a search is kicked off and
570 // we wait for notification to find out what the results are. As the user is
571 // typing, new search requests can be issued and the Request ID helps us make
572 // sense of whether this is the current request or an old one. The unit tests,
573 // however, which uses this constant issues only one search at a time, so we
574 // don't need a rolling id to identify each search. But, we still need to
575 // specify one, so we just use a fixed one - its value does not matter.
576 static const int kFindInPageRequestId;
577
578 private:
[email protected]6c2381d2011-10-19 02:52:53579 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03580 base::WeakPtr<AutomationProvider> automation_;
[email protected]e12de87e2009-08-28 00:02:08581 // We will at some point (before final update) be notified of the ordinal and
582 // we need to preserve it so we can send it later.
583 int active_match_ordinal_;
[email protected]f9e3c522010-10-08 00:41:26584 // Send reply using json automation interface.
585 bool reply_with_json_;
[email protected]7d9aecf2011-02-09 11:58:03586 scoped_ptr<IPC::Message> reply_message_;
[email protected]e12de87e2009-08-28 00:02:08587
588 DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
589};
590
[email protected]6c2381d2011-10-19 02:52:53591class DomOperationObserver : public content::NotificationObserver {
[email protected]e12de87e2009-08-28 00:02:08592 public:
[email protected]4a64ea82012-04-17 01:22:46593 explicit DomOperationObserver(int automation_id);
[email protected]b6ce91b2011-02-10 21:30:50594 virtual ~DomOperationObserver();
[email protected]e12de87e2009-08-28 00:02:08595
[email protected]4ad6c3a2012-06-14 00:31:17596 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27597 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53598 const content::NotificationSource& source,
599 const content::NotificationDetails& details) OVERRIDE;
[email protected]e12de87e2009-08-28 00:02:08600
[email protected]4203e6b2010-11-12 21:41:50601 virtual void OnDomOperationCompleted(const std::string& json) = 0;
[email protected]2b496732011-07-25 22:42:02602 virtual void OnModalDialogShown() = 0;
[email protected]df968842011-11-04 16:00:53603 virtual void OnJavascriptBlocked() = 0;
[email protected]4203e6b2010-11-12 21:41:50604
[email protected]e12de87e2009-08-28 00:02:08605 private:
[email protected]4a64ea82012-04-17 01:22:46606 int automation_id_;
[email protected]6c2381d2011-10-19 02:52:53607 content::NotificationRegistrar registrar_;
[email protected]4203e6b2010-11-12 21:41:50608
609 DISALLOW_COPY_AND_ASSIGN(DomOperationObserver);
610};
611
[email protected]3fdb891b2011-03-10 18:01:00612// Sends a message back to the automation client with the results of the DOM
613// operation.
[email protected]4203e6b2010-11-12 21:41:50614class DomOperationMessageSender : public DomOperationObserver {
615 public:
[email protected]e7e38032011-07-26 17:25:25616 DomOperationMessageSender(AutomationProvider* automation,
[email protected]4a64ea82012-04-17 01:22:46617 IPC::Message* reply_message,
[email protected]e7e38032011-07-26 17:25:25618 bool use_json_interface);
[email protected]b6ce91b2011-02-10 21:30:50619 virtual ~DomOperationMessageSender();
[email protected]4203e6b2010-11-12 21:41:50620
[email protected]2b496732011-07-25 22:42:02621 virtual void OnDomOperationCompleted(const std::string& json) OVERRIDE;
622 virtual void OnModalDialogShown() OVERRIDE;
[email protected]df968842011-11-04 16:00:53623 virtual void OnJavascriptBlocked() OVERRIDE;
[email protected]4203e6b2010-11-12 21:41:50624
625 private:
[email protected]7d9aecf2011-02-09 11:58:03626 base::WeakPtr<AutomationProvider> automation_;
[email protected]3fdb891b2011-03-10 18:01:00627 scoped_ptr<IPC::Message> reply_message_;
628 bool use_json_interface_;
[email protected]e12de87e2009-08-28 00:02:08629
[email protected]4203e6b2010-11-12 21:41:50630 DISALLOW_COPY_AND_ASSIGN(DomOperationMessageSender);
[email protected]e12de87e2009-08-28 00:02:08631};
632
[email protected]84abba62009-10-07 17:01:44633// Collects METRIC_EVENT_DURATION notifications and keep track of the times.
[email protected]6c2381d2011-10-19 02:52:53634class MetricEventDurationObserver : public content::NotificationObserver {
[email protected]84abba62009-10-07 17:01:44635 public:
636 MetricEventDurationObserver();
[email protected]8e383412010-10-19 16:57:03637 virtual ~MetricEventDurationObserver();
[email protected]84abba62009-10-07 17:01:44638
639 // Get the duration of an event. Returns -1 if we haven't seen the event.
640 int GetEventDurationMs(const std::string& event_name);
641
[email protected]4ad6c3a2012-06-14 00:31:17642 // Overridden from content::NotificationObserver:
643 virtual void Observe(int type,
644 const content::NotificationSource& source,
645 const content::NotificationDetails& details) OVERRIDE;
[email protected]84abba62009-10-07 17:01:44646
647 private:
[email protected]6c2381d2011-10-19 02:52:53648 content::NotificationRegistrar registrar_;
[email protected]84abba62009-10-07 17:01:44649
650 typedef std::map<std::string, int> EventDurationMap;
651 EventDurationMap durations_;
652
653 DISALLOW_COPY_AND_ASSIGN(MetricEventDurationObserver);
654};
655
[email protected]6c2381d2011-10-19 02:52:53656class InfoBarCountObserver : public content::NotificationObserver {
[email protected]e04c7eaca2010-09-08 22:04:40657 public:
658 InfoBarCountObserver(AutomationProvider* automation,
659 IPC::Message* reply_message,
[email protected]aa190632012-12-04 07:39:53660 content::WebContents* web_contents,
[email protected]ec8f51162011-02-08 04:20:40661 size_t target_count);
[email protected]b6ce91b2011-02-10 21:30:50662 virtual ~InfoBarCountObserver();
[email protected]e04c7eaca2010-09-08 22:04:40663
[email protected]4ad6c3a2012-06-14 00:31:17664 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:27665 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53666 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:17667 const content::NotificationDetails& details) OVERRIDE;
[email protected]e04c7eaca2010-09-08 22:04:40668
669 private:
670 // Checks whether the infobar count matches our target, and if so
671 // sends the reply message and deletes itself.
672 void CheckCount();
673
[email protected]6c2381d2011-10-19 02:52:53674 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:03675 base::WeakPtr<AutomationProvider> automation_;
676 scoped_ptr<IPC::Message> reply_message_;
[email protected]aa190632012-12-04 07:39:53677 content::WebContents* web_contents_;
[email protected]e04c7eaca2010-09-08 22:04:40678
[email protected]ec8f51162011-02-08 04:20:40679 const size_t target_count_;
[email protected]e04c7eaca2010-09-08 22:04:40680
681 DISALLOW_COPY_AND_ASSIGN(InfoBarCountObserver);
682};
683
[email protected]566a0f762010-03-10 04:14:57684#if defined(OS_CHROMEOS)
[email protected]b1bb86d2011-09-02 18:20:51685class LoginObserver : public chromeos::LoginStatusConsumer {
[email protected]566a0f762010-03-10 04:14:57686 public:
[email protected]3b10fdeb2011-05-06 00:17:25687 LoginObserver(chromeos::ExistingUserController* controller,
688 AutomationProvider* automation,
689 IPC::Message* reply_message);
[email protected]566a0f762010-03-10 04:14:57690
[email protected]b9f0a3402011-05-25 13:41:33691 virtual ~LoginObserver();
[email protected]3b10fdeb2011-05-06 00:17:25692
[email protected]e755d9f2011-05-15 20:03:47693 virtual void OnLoginFailure(const chromeos::LoginFailure& error);
[email protected]3b10fdeb2011-05-06 00:17:25694
[email protected]e755d9f2011-05-15 20:03:47695 virtual void OnLoginSuccess(
[email protected]40429592013-03-29 17:52:33696 const chromeos::UserContext& user_context,
[email protected]cc8f2472011-08-01 07:14:46697 bool pending_requests,
698 bool using_oauth);
[email protected]3b10fdeb2011-05-06 00:17:25699
[email protected]566a0f762010-03-10 04:14:57700 private:
[email protected]3b10fdeb2011-05-06 00:17:25701 chromeos::ExistingUserController* controller_;
[email protected]7d9aecf2011-02-09 11:58:03702 base::WeakPtr<AutomationProvider> automation_;
703 scoped_ptr<IPC::Message> reply_message_;
[email protected]566a0f762010-03-10 04:14:57704
[email protected]3b10fdeb2011-05-06 00:17:25705 DISALLOW_COPY_AND_ASSIGN(LoginObserver);
[email protected]566a0f762010-03-10 04:14:57706};
[email protected]cfc34b79c2011-02-05 00:00:21707
[email protected]64b1b48ef2012-06-04 13:43:54708// Waits for a screen change notification from WizardController.
709class WizardControllerObserver : public chromeos::WizardController::Observer,
710 public content::NotificationObserver {
711 public:
712 WizardControllerObserver(chromeos::WizardController* wizard_controller,
713 AutomationProvider* automation,
714 IPC::Message* reply_message);
715 virtual ~WizardControllerObserver();
716
717 // If non-empty, waits for a specific change to screen with this name.
718 std::string screen_to_wait_for() { return screen_to_wait_for_; }
719 void set_screen_to_wait_for(const std::string& screen_name) {
720 screen_to_wait_for_ = screen_name;
721 }
722
723 protected:
724 // chromeos::WizardController::Observer overrides:
725 virtual void OnScreenChanged(chromeos::WizardScreen* next_screen) OVERRIDE;
726 virtual void OnSessionStart() OVERRIDE;
727
728 // content::NotificationObserver overrides:
729 void Observe(int type,
730 const content::NotificationSource& source,
731 const content::NotificationDetails& details);
732
733 // Sends reply with the given screen name and deletes |this|.
734 void SendReply(const std::string& screen_name);
735
736 content::NotificationRegistrar registrar_;
737 chromeos::WizardController* wizard_controller_;
738 base::WeakPtr<AutomationProvider> automation_;
739 scoped_ptr<IPC::Message> reply_message_;
740 std::string screen_to_wait_for_;
741
742 DISALLOW_COPY_AND_ASSIGN(WizardControllerObserver);
743};
744
[email protected]cfc34b79c2011-02-05 00:00:21745// Collects SCREEN_LOCK_STATE_CHANGED notifications and returns
746// whether authentication succeeded to the automation provider.
[email protected]6c2381d2011-10-19 02:52:53747class ScreenLockUnlockObserver : public content::NotificationObserver {
[email protected]cfc34b79c2011-02-05 00:00:21748 public:
749 // Set lock_screen to true to observe lock screen events,
750 // false for unlock screen events.
751 ScreenLockUnlockObserver(AutomationProvider* automation,
752 IPC::Message* reply_message,
753 bool lock_screen);
[email protected]d958c2bc2011-03-11 20:08:26754 virtual ~ScreenLockUnlockObserver();
[email protected]cfc34b79c2011-02-05 00:00:21755
[email protected]4ad6c3a2012-06-14 00:31:17756 // Overridden from content::NotificationObserver:
757 virtual void Observe(int type,
758 const content::NotificationSource& source,
759 const content::NotificationDetails& details) OVERRIDE;
[email protected]cfc34b79c2011-02-05 00:00:21760
[email protected]29d35012011-05-31 19:27:29761 protected:
762 base::WeakPtr<AutomationProvider> automation_;
763 scoped_ptr<IPC::Message> reply_message_;
764
[email protected]cfc34b79c2011-02-05 00:00:21765 private:
[email protected]6c2381d2011-10-19 02:52:53766 content::NotificationRegistrar registrar_;
[email protected]cfc34b79c2011-02-05 00:00:21767 bool lock_screen_;
768
769 DISALLOW_COPY_AND_ASSIGN(ScreenLockUnlockObserver);
770};
[email protected]8989bb42011-03-26 00:33:21771
[email protected]29d35012011-05-31 19:27:29772// Watches SCREEN_LOCK_STATE_CHANGED notifications like the
773// ScreenLockUnlockObserver, but additionally adds itself as an observer
774// to a screen locker in order to monitor unlock failure cases.
775class ScreenUnlockObserver : public ScreenLockUnlockObserver,
776 public chromeos::LoginStatusConsumer {
777 public:
778 ScreenUnlockObserver(AutomationProvider* automation,
779 IPC::Message* reply_message);
780 virtual ~ScreenUnlockObserver();
781
782 virtual void OnLoginFailure(const chromeos::LoginFailure& error);
783
784 virtual void OnLoginSuccess(
[email protected]40429592013-03-29 17:52:33785 const chromeos::UserContext& user_context,
[email protected]cc8f2472011-08-01 07:14:46786 bool pending_requests,
787 bool using_oauth) {}
[email protected]29d35012011-05-31 19:27:29788
789 private:
790 DISALLOW_COPY_AND_ASSIGN(ScreenUnlockObserver);
791};
792
[email protected]8989bb42011-03-26 00:33:21793class NetworkScanObserver
794 : public chromeos::NetworkLibrary::NetworkManagerObserver {
795 public:
796 NetworkScanObserver(AutomationProvider* automation,
797 IPC::Message* reply_message);
798
799 virtual ~NetworkScanObserver();
800
801 // NetworkLibrary::NetworkManagerObserver implementation.
802 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj);
803
804 private:
[email protected]f717d1c2011-06-20 18:44:11805 base::WeakPtr<AutomationProvider> automation_;
806 scoped_ptr<IPC::Message> reply_message_;
[email protected]8989bb42011-03-26 00:33:21807
808 DISALLOW_COPY_AND_ASSIGN(NetworkScanObserver);
809};
810
[email protected]5d4a99d2011-08-02 02:19:05811class ToggleNetworkDeviceObserver
812 : public chromeos::NetworkLibrary::NetworkManagerObserver {
813 public:
814 ToggleNetworkDeviceObserver(AutomationProvider* automation,
815 IPC::Message* reply_message,
816 const std::string& device,
817 bool enable);
818
819 virtual ~ToggleNetworkDeviceObserver();
820
821 // NetworkLibrary::NetworkManagerObserver implementation.
822 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj);
823
824 private:
825 base::WeakPtr<AutomationProvider> automation_;
826 scoped_ptr<IPC::Message> reply_message_;
827 std::string device_;
828 bool enable_;
829
830 DISALLOW_COPY_AND_ASSIGN(ToggleNetworkDeviceObserver);
831};
832
[email protected]52a90fd02011-10-12 03:05:08833class NetworkStatusObserver
834 : public chromeos::NetworkLibrary::NetworkManagerObserver {
835 public:
836 NetworkStatusObserver(AutomationProvider* automation,
837 IPC::Message* reply_message);
838 virtual ~NetworkStatusObserver();
839
840 virtual const chromeos::Network* GetNetwork(
841 chromeos::NetworkLibrary* network_library) = 0;
842 // NetworkLibrary::NetworkManagerObserver implementation.
843 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj);
844 virtual void NetworkStatusCheck(const chromeos::Network* network) = 0;
845
846 protected:
847 base::WeakPtr<AutomationProvider> automation_;
848 scoped_ptr<IPC::Message> reply_message_;
849
850 private:
851 DISALLOW_COPY_AND_ASSIGN(NetworkStatusObserver);
852};
853
[email protected]8989bb42011-03-26 00:33:21854// Waits for a connection success or failure for the specified
855// network and returns the status to the automation provider.
[email protected]52a90fd02011-10-12 03:05:08856class NetworkConnectObserver : public NetworkStatusObserver {
[email protected]8989bb42011-03-26 00:33:21857 public:
858 NetworkConnectObserver(AutomationProvider* automation,
[email protected]7ae8d0f2011-04-12 02:47:35859 IPC::Message* reply_message);
[email protected]8989bb42011-03-26 00:33:21860
[email protected]52a90fd02011-10-12 03:05:08861 virtual void NetworkStatusCheck(const chromeos::Network* network);
[email protected]8989bb42011-03-26 00:33:21862
863 private:
[email protected]8989bb42011-03-26 00:33:21864 DISALLOW_COPY_AND_ASSIGN(NetworkConnectObserver);
865};
[email protected]7ae8d0f2011-04-12 02:47:35866
[email protected]52a90fd02011-10-12 03:05:08867// Waits until a network has disconnected. Then returns success
868// or failure.
869class NetworkDisconnectObserver : public NetworkStatusObserver {
870 public:
871 NetworkDisconnectObserver(AutomationProvider* automation,
872 IPC::Message* reply_message,
873 const std::string& service_path);
874
875 virtual void NetworkStatusCheck(const chromeos::Network* network);
876 const chromeos::Network* GetNetwork(
877 chromeos::NetworkLibrary* network_library);
878
879 private:
880 std::string service_path_;
881 DISALLOW_COPY_AND_ASSIGN(NetworkDisconnectObserver);
882};
883
[email protected]7ae8d0f2011-04-12 02:47:35884// Waits for a connection success or failure for the specified
885// network and returns the status to the automation provider.
886class ServicePathConnectObserver : public NetworkConnectObserver {
887 public:
888 ServicePathConnectObserver(AutomationProvider* automation,
889 IPC::Message* reply_message,
890 const std::string& service_path);
891
[email protected]52a90fd02011-10-12 03:05:08892 const chromeos::Network* GetNetwork(
[email protected]7ae8d0f2011-04-12 02:47:35893 chromeos::NetworkLibrary* network_library);
894
895 private:
896 std::string service_path_;
[email protected]7ae8d0f2011-04-12 02:47:35897 DISALLOW_COPY_AND_ASSIGN(ServicePathConnectObserver);
898};
899
900// Waits for a connection success or failure for the specified
[email protected]52a90fd02011-10-12 03:05:08901// network and returns the status to the automation provider.
902class SSIDConnectObserver : public NetworkConnectObserver {
903 public:
904 SSIDConnectObserver(AutomationProvider* automation,
905 IPC::Message* reply_message,
906 const std::string& ssid);
907
908 const chromeos::Network* GetNetwork(
909 chromeos::NetworkLibrary* network_library);
910
911 private:
912 std::string ssid_;
913 DISALLOW_COPY_AND_ASSIGN(SSIDConnectObserver);
914};
915
916// Waits for a connection success or failure for the specified
[email protected]f717d1c2011-06-20 18:44:11917// virtual network and returns the status to the automation provider.
918class VirtualConnectObserver
919 : public chromeos::NetworkLibrary::NetworkManagerObserver {
920 public:
921 VirtualConnectObserver(AutomationProvider* automation,
922 IPC::Message* reply_message,
923 const std::string& service_name);
924
925 virtual ~VirtualConnectObserver();
926
927 // NetworkLibrary::NetworkManagerObserver implementation.
928 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* cros);
929
930 private:
931 virtual chromeos::VirtualNetwork* GetVirtualNetwork(
932 const chromeos::NetworkLibrary* cros);
933
934 base::WeakPtr<AutomationProvider> automation_;
935 scoped_ptr<IPC::Message> reply_message_;
936 std::string service_name_;
937
938 DISALLOW_COPY_AND_ASSIGN(VirtualConnectObserver);
939};
940
[email protected]6a33bb92011-07-28 02:41:19941// Waits for enterprise device enrollment to complete and returns the status to
942// the automation provider.
943class EnrollmentObserver
[email protected]02549802013-04-22 18:25:51944 : public chromeos::EnrollmentScreen::TestingObserver {
[email protected]6a33bb92011-07-28 02:41:19945 public:
946 EnrollmentObserver(AutomationProvider* automation,
[email protected]f24cab42012-11-01 14:41:16947 IPC::Message* reply_message,
[email protected]02549802013-04-22 18:25:51948 chromeos::EnrollmentScreen* enrollment_screen);
[email protected]6a33bb92011-07-28 02:41:19949
950 virtual ~EnrollmentObserver();
951
[email protected]02549802013-04-22 18:25:51952 // chromeos::EnrollmentScreen::Observer implementation.
[email protected]f24cab42012-11-01 14:41:16953 virtual void OnEnrollmentComplete(bool succeeded);
[email protected]6a33bb92011-07-28 02:41:19954
955 private:
956 base::WeakPtr<AutomationProvider> automation_;
957 scoped_ptr<IPC::Message> reply_message_;
[email protected]02549802013-04-22 18:25:51958 chromeos::EnrollmentScreen* enrollment_screen_;
[email protected]6a33bb92011-07-28 02:41:19959
960 DISALLOW_COPY_AND_ASSIGN(EnrollmentObserver);
961};
962
[email protected]60ae33e2011-03-10 00:44:34963#endif // defined(OS_CHROMEOS)
[email protected]566a0f762010-03-10 04:14:57964
[email protected]6d8ffc9f2010-03-12 18:27:53965// Waits for the bookmark model to load.
[email protected]c58c5ea2011-07-13 21:43:16966class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver {
[email protected]6d8ffc9f2010-03-12 18:27:53967 public:
968 AutomationProviderBookmarkModelObserver(AutomationProvider* provider,
969 IPC::Message* reply_message,
[email protected]9329d682012-08-13 22:59:03970 BookmarkModel* model,
971 bool use_json_interface);
[email protected]6d8ffc9f2010-03-12 18:27:53972 virtual ~AutomationProviderBookmarkModelObserver();
973
[email protected]f12de8302011-05-23 16:12:30974 // BookmarkModelObserver:
[email protected]c58c5ea2011-07-13 21:43:16975 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
[email protected]f12de8302011-05-23 16:12:30976 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
[email protected]6d8ffc9f2010-03-12 18:27:53977 virtual void BookmarkNodeMoved(BookmarkModel* model,
978 const BookmarkNode* old_parent,
979 int old_index,
980 const BookmarkNode* new_parent,
[email protected]f12de8302011-05-23 16:12:30981 int new_index) OVERRIDE {}
[email protected]6d8ffc9f2010-03-12 18:27:53982 virtual void BookmarkNodeAdded(BookmarkModel* model,
983 const BookmarkNode* parent,
[email protected]f12de8302011-05-23 16:12:30984 int index) OVERRIDE {}
[email protected]6d8ffc9f2010-03-12 18:27:53985 virtual void BookmarkNodeRemoved(BookmarkModel* model,
986 const BookmarkNode* parent,
987 int old_index,
[email protected]f12de8302011-05-23 16:12:30988 const BookmarkNode* node) OVERRIDE {}
[email protected]323dbf72013-03-30 17:08:33989 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) OVERRIDE {}
[email protected]6d8ffc9f2010-03-12 18:27:53990 virtual void BookmarkNodeChanged(BookmarkModel* model,
[email protected]f12de8302011-05-23 16:12:30991 const BookmarkNode* node) OVERRIDE {}
992 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
993 const BookmarkNode* node) OVERRIDE {}
994 virtual void BookmarkNodeChildrenReordered(
995 BookmarkModel* model,
996 const BookmarkNode* node) OVERRIDE {}
[email protected]6d8ffc9f2010-03-12 18:27:53997
[email protected]9329d682012-08-13 22:59:03998 IPC::Message* ReleaseReply();
999
[email protected]6d8ffc9f2010-03-12 18:27:531000 private:
1001 // Reply to the automation message with the given success value,
1002 // then delete myself (which removes myself from the bookmark model
1003 // observer list).
1004 void ReplyAndDelete(bool success);
1005
[email protected]7d9aecf2011-02-09 11:58:031006 base::WeakPtr<AutomationProvider> automation_provider_;
1007 scoped_ptr<IPC::Message> reply_message_;
[email protected]6d8ffc9f2010-03-12 18:27:531008 BookmarkModel* model_;
[email protected]9329d682012-08-13 22:59:031009 bool use_json_interface_;
[email protected]6d8ffc9f2010-03-12 18:27:531010
1011 DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver);
1012};
1013
[email protected]2d54c4032010-08-20 00:42:281014// Allows the automation provider to wait until the download has been updated
1015// or opened.
1016class AutomationProviderDownloadUpdatedObserver
[email protected]e582fdd2011-12-20 16:48:171017 : public content::DownloadItem::Observer {
[email protected]2d54c4032010-08-20 00:42:281018 public:
1019 AutomationProviderDownloadUpdatedObserver(
1020 AutomationProvider* provider,
1021 IPC::Message* reply_message,
[email protected]66521d02012-08-14 17:51:541022 bool wait_for_open,
1023 bool incognito);
[email protected]b6ce91b2011-02-10 21:30:501024 virtual ~AutomationProviderDownloadUpdatedObserver();
[email protected]2d54c4032010-08-20 00:42:281025
[email protected]e582fdd2011-12-20 16:48:171026 virtual void OnDownloadUpdated(content::DownloadItem* download);
1027 virtual void OnDownloadOpened(content::DownloadItem* download);
[email protected]2d54c4032010-08-20 00:42:281028
1029 private:
[email protected]7d9aecf2011-02-09 11:58:031030 base::WeakPtr<AutomationProvider> provider_;
1031 scoped_ptr<IPC::Message> reply_message_;
[email protected]2d54c4032010-08-20 00:42:281032 bool wait_for_open_;
[email protected]66521d02012-08-14 17:51:541033 bool incognito_;
[email protected]2d54c4032010-08-20 00:42:281034
1035 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadUpdatedObserver);
1036};
1037
1038// Allows the automation provider to wait until the download model has changed
1039// (because a new download has been added or removed).
1040class AutomationProviderDownloadModelChangedObserver
[email protected]73c43482012-11-07 16:53:191041 : public AllDownloadItemNotifier::Observer {
[email protected]2d54c4032010-08-20 00:42:281042 public:
1043 AutomationProviderDownloadModelChangedObserver(
1044 AutomationProvider* provider,
1045 IPC::Message* reply_message,
[email protected]e582fdd2011-12-20 16:48:171046 content::DownloadManager* download_manager);
[email protected]b6ce91b2011-02-10 21:30:501047 virtual ~AutomationProviderDownloadModelChangedObserver();
[email protected]2d54c4032010-08-20 00:42:281048
[email protected]73c43482012-11-07 16:53:191049 virtual void OnDownloadCreated(
1050 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
1051 virtual void OnDownloadRemoved(
1052 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
[email protected]2d54c4032010-08-20 00:42:281053
1054 private:
[email protected]73c43482012-11-07 16:53:191055 void ModelChanged();
1056
[email protected]7d9aecf2011-02-09 11:58:031057 base::WeakPtr<AutomationProvider> provider_;
1058 scoped_ptr<IPC::Message> reply_message_;
[email protected]73c43482012-11-07 16:53:191059 AllDownloadItemNotifier notifier_;
[email protected]2d54c4032010-08-20 00:42:281060
1061 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver);
1062};
1063
[email protected]e4af4eba2011-08-10 16:52:361064// Observes when all pending downloads have completed.
1065class AllDownloadsCompleteObserver
[email protected]e582fdd2011-12-20 16:48:171066 : public content::DownloadManager::Observer,
1067 public content::DownloadItem::Observer {
[email protected]e4af4eba2011-08-10 16:52:361068 public:
1069 AllDownloadsCompleteObserver(
1070 AutomationProvider* provider,
1071 IPC::Message* reply_message,
[email protected]e582fdd2011-12-20 16:48:171072 content::DownloadManager* download_manager,
[email protected]e4af4eba2011-08-10 16:52:361073 ListValue* pre_download_ids);
1074 virtual ~AllDownloadsCompleteObserver();
1075
[email protected]75e51b52012-02-04 16:57:541076 // content::DownloadManager::Observer.
[email protected]9f1f4092012-09-10 21:18:041077 virtual void OnDownloadCreated(
1078 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
[email protected]8fe3ae42012-09-13 21:50:311079 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE;
[email protected]e4af4eba2011-08-10 16:52:361080
[email protected]75e51b52012-02-04 16:57:541081 // content::DownloadItem::Observer.
1082 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
[email protected]e4af4eba2011-08-10 16:52:361083
1084 private:
1085 void ReplyIfNecessary();
1086
1087 base::WeakPtr<AutomationProvider> provider_;
1088 scoped_ptr<IPC::Message> reply_message_;
[email protected]e582fdd2011-12-20 16:48:171089 content::DownloadManager* download_manager_;
[email protected]e4af4eba2011-08-10 16:52:361090 std::set<int> pre_download_ids_;
[email protected]e582fdd2011-12-20 16:48:171091 std::set<content::DownloadItem*> pending_downloads_;
[email protected]e4af4eba2011-08-10 16:52:361092
1093 DISALLOW_COPY_AND_ASSIGN(AllDownloadsCompleteObserver);
1094};
1095
[email protected]8e5c89a2011-06-07 18:13:331096// Allows automation provider to wait until TemplateURLService has loaded
[email protected]61023d002010-09-17 21:03:071097// before looking up/returning search engine info.
1098class AutomationProviderSearchEngineObserver
[email protected]8e5c89a2011-06-07 18:13:331099 : public TemplateURLServiceObserver {
[email protected]61023d002010-09-17 21:03:071100 public:
1101 AutomationProviderSearchEngineObserver(
[email protected]88efa012010-10-12 04:47:441102 AutomationProvider* provider,
[email protected]6c1e3ec2012-04-27 01:26:461103 Profile* profile,
[email protected]7d9aecf2011-02-09 11:58:031104 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501105 virtual ~AutomationProviderSearchEngineObserver();
[email protected]61023d002010-09-17 21:03:071106
[email protected]8e5c89a2011-06-07 18:13:331107 virtual void OnTemplateURLServiceChanged();
[email protected]61023d002010-09-17 21:03:071108
1109 private:
[email protected]7d9aecf2011-02-09 11:58:031110 base::WeakPtr<AutomationProvider> provider_;
[email protected]6c1e3ec2012-04-27 01:26:461111 Profile* profile_;
[email protected]7d9aecf2011-02-09 11:58:031112 scoped_ptr<IPC::Message> reply_message_;
[email protected]61023d002010-09-17 21:03:071113
1114 DISALLOW_COPY_AND_ASSIGN(AutomationProviderSearchEngineObserver);
1115};
1116
[email protected]e6e376e2010-04-19 21:41:361117// Allows the automation provider to wait for history queries to finish.
1118class AutomationProviderHistoryObserver {
1119 public:
1120 AutomationProviderHistoryObserver(
1121 AutomationProvider* provider,
[email protected]7d9aecf2011-02-09 11:58:031122 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501123 virtual ~AutomationProviderHistoryObserver();
[email protected]7d9aecf2011-02-09 11:58:031124
[email protected]e6e376e2010-04-19 21:41:361125 void HistoryQueryComplete(HistoryService::Handle request_handle,
1126 history::QueryResults* results);
1127
1128 private:
[email protected]7d9aecf2011-02-09 11:58:031129 base::WeakPtr<AutomationProvider> provider_;
1130 scoped_ptr<IPC::Message> reply_message_;
[email protected]e6e376e2010-04-19 21:41:361131};
1132
[email protected]c5aa5322010-07-15 19:00:071133// Allows the automation provider to wait for import queries to finish.
[email protected]6c69796d2010-07-16 21:41:161134class AutomationProviderImportSettingsObserver
[email protected]ea52f512011-03-08 19:55:511135 : public importer::ImporterProgressObserver {
[email protected]c5aa5322010-07-15 19:00:071136 public:
1137 AutomationProviderImportSettingsObserver(
1138 AutomationProvider* provider,
[email protected]7d9aecf2011-02-09 11:58:031139 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501140 virtual ~AutomationProviderImportSettingsObserver();
[email protected]7d9aecf2011-02-09 11:58:031141
[email protected]ea52f512011-03-08 19:55:511142 // importer::ImporterProgressObserver:
1143 virtual void ImportStarted() OVERRIDE;
1144 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE;
1145 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE;
1146 virtual void ImportEnded() OVERRIDE;
1147
[email protected]c5aa5322010-07-15 19:00:071148 private:
[email protected]7d9aecf2011-02-09 11:58:031149 base::WeakPtr<AutomationProvider> provider_;
1150 scoped_ptr<IPC::Message> reply_message_;
[email protected]c5aa5322010-07-15 19:00:071151};
1152
[email protected]5bcfe1672010-07-16 20:51:571153// Allows automation provider to wait for getting passwords to finish.
[email protected]e5721c182011-03-28 22:27:341154class AutomationProviderGetPasswordsObserver : public PasswordStoreConsumer {
[email protected]5bcfe1672010-07-16 20:51:571155 public:
1156 AutomationProviderGetPasswordsObserver(
1157 AutomationProvider* provider,
[email protected]7d9aecf2011-02-09 11:58:031158 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501159 virtual ~AutomationProviderGetPasswordsObserver();
[email protected]5bcfe1672010-07-16 20:51:571160
[email protected]cef1a752012-12-14 04:01:561161 // PasswordStoreConsumer implementation.
[email protected]78994ab02010-12-08 18:06:441162 virtual void OnPasswordStoreRequestDone(
[email protected]e5721c182011-03-28 22:27:341163 CancelableRequestProvider::Handle handle,
[email protected]1ecbe862012-10-05 01:29:141164 const std::vector<content::PasswordForm*>& result) OVERRIDE;
[email protected]cef1a752012-12-14 04:01:561165 virtual void OnGetPasswordStoreResults(
1166 const std::vector<content::PasswordForm*>& results) OVERRIDE;
[email protected]5bcfe1672010-07-16 20:51:571167
1168 private:
[email protected]7d9aecf2011-02-09 11:58:031169 base::WeakPtr<AutomationProvider> provider_;
1170 scoped_ptr<IPC::Message> reply_message_;
[email protected]5bcfe1672010-07-16 20:51:571171};
1172
[email protected]64ad22e2011-05-20 21:59:291173// Observes when login entries stored in the password store are changed. The
[email protected]08a3b9bb2011-05-26 19:59:291174// notifications are sent on the DB thread, the thread that interacts with the
1175// web database.
[email protected]64ad22e2011-05-20 21:59:291176class PasswordStoreLoginsChangedObserver
1177 : public base::RefCountedThreadSafe<
1178 PasswordStoreLoginsChangedObserver,
[email protected]631bb742011-11-02 11:29:391179 content::BrowserThread::DeleteOnUIThread>,
[email protected]6c2381d2011-10-19 02:52:531180 public content::NotificationObserver {
[email protected]64ad22e2011-05-20 21:59:291181 public:
1182 PasswordStoreLoginsChangedObserver(AutomationProvider* automation,
1183 IPC::Message* reply_message,
[email protected]08a3b9bb2011-05-26 19:59:291184 PasswordStoreChange::Type expected_type,
[email protected]64ad22e2011-05-20 21:59:291185 const std::string& result_key);
[email protected]64ad22e2011-05-20 21:59:291186
[email protected]08a3b9bb2011-05-26 19:59:291187 // Schedules a task on the DB thread to register the appropriate observers.
[email protected]64ad22e2011-05-20 21:59:291188 virtual void Init();
1189
[email protected]4ad6c3a2012-06-14 00:31:171190 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271191 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531192 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171193 const content::NotificationDetails& details) OVERRIDE;
[email protected]64ad22e2011-05-20 21:59:291194
1195 private:
[email protected]631bb742011-11-02 11:29:391196 friend struct content::BrowserThread::DeleteOnThread<
1197 content::BrowserThread::UI>;
[email protected]f2a6ec642012-05-09 05:16:291198 ~PasswordStoreLoginsChangedObserver();
[email protected]cff06c572012-01-02 20:03:051199 friend class base::DeleteHelper<PasswordStoreLoginsChangedObserver>;
[email protected]64ad22e2011-05-20 21:59:291200
[email protected]08a3b9bb2011-05-26 19:59:291201 // Registers the appropriate observers. Called on the DB thread.
[email protected]64ad22e2011-05-20 21:59:291202 void RegisterObserversTask();
1203
1204 // Sends the |reply_message_| to |automation_| indicating we're done. Called
[email protected]08a3b9bb2011-05-26 19:59:291205 // on the UI thread.
[email protected]64ad22e2011-05-20 21:59:291206 void IndicateDone();
1207
[email protected]08a3b9bb2011-05-26 19:59:291208 // Sends an error reply to |automation_|. Called on the UI thread.
1209 void IndicateError(const std::string& error);
1210
[email protected]64ad22e2011-05-20 21:59:291211 base::WeakPtr<AutomationProvider> automation_;
1212 scoped_ptr<IPC::Message> reply_message_;
[email protected]f2a6ec642012-05-09 05:16:291213 scoped_ptr<content::NotificationRegistrar> registrar_;
[email protected]08a3b9bb2011-05-26 19:59:291214 PasswordStoreChange::Type expected_type_;
[email protected]64ad22e2011-05-20 21:59:291215 std::string result_key_;
1216
[email protected]08a3b9bb2011-05-26 19:59:291217 // Used to ensure that the UI thread waits for the DB thread to finish
1218 // registering observers before proceeding.
[email protected]64ad22e2011-05-20 21:59:291219 base::WaitableEvent done_event_;
1220
1221 DISALLOW_COPY_AND_ASSIGN(PasswordStoreLoginsChangedObserver);
1222};
1223
[email protected]c1654832010-05-17 23:22:121224// Allows automation provider to wait until page load after selecting an item
1225// in the omnibox popup.
[email protected]6c2381d2011-10-19 02:52:531226class OmniboxAcceptNotificationObserver : public content::NotificationObserver {
[email protected]c1654832010-05-17 23:22:121227 public:
[email protected]b7b63872013-01-03 02:41:191228 OmniboxAcceptNotificationObserver(content::NavigationController* controller,
1229 AutomationProvider* automation,
1230 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501231 virtual ~OmniboxAcceptNotificationObserver();
[email protected]c1654832010-05-17 23:22:121232
[email protected]4ad6c3a2012-06-14 00:31:171233 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271234 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531235 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171236 const content::NotificationDetails& details) OVERRIDE;
[email protected]c1654832010-05-17 23:22:121237
1238 private:
[email protected]6c2381d2011-10-19 02:52:531239 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:031240 base::WeakPtr<AutomationProvider> automation_;
1241 scoped_ptr<IPC::Message> reply_message_;
[email protected]cca0f1e2012-01-03 18:27:461242 content::NavigationController* controller_;
[email protected]c1654832010-05-17 23:22:121243
1244 DISALLOW_COPY_AND_ASSIGN(OmniboxAcceptNotificationObserver);
1245};
1246
[email protected]7060bb292010-06-24 00:52:491247// Allows the automation provider to wait for a save package notification.
[email protected]df58aa82013-01-24 21:54:001248class SavePackageNotificationObserver
1249: public content::DownloadManager::Observer {
[email protected]7060bb292010-06-24 00:52:491250 public:
[email protected]e582fdd2011-12-20 16:48:171251 SavePackageNotificationObserver(content::DownloadManager* download_manager,
[email protected]7060bb292010-06-24 00:52:491252 AutomationProvider* automation,
1253 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501254 virtual ~SavePackageNotificationObserver();
[email protected]7060bb292010-06-24 00:52:491255
[email protected]df58aa82013-01-24 21:54:001256 // Overridden from content::DownloadManager::Observer:
1257 virtual void OnSavePackageSuccessfullyFinished(
1258 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
1259 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE;
[email protected]7060bb292010-06-24 00:52:491260
1261 private:
[email protected]df58aa82013-01-24 21:54:001262 content::DownloadManager* download_manager_;
[email protected]7d9aecf2011-02-09 11:58:031263 base::WeakPtr<AutomationProvider> automation_;
1264 scoped_ptr<IPC::Message> reply_message_;
[email protected]7060bb292010-06-24 00:52:491265
1266 DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver);
1267};
1268
[email protected]fad82962011-10-28 21:09:061269// This class manages taking a snapshot of a page.
1270class PageSnapshotTaker : public TabEventObserver,
1271 public content::NotificationObserver {
[email protected]4203e6b2010-11-12 21:41:501272 public:
1273 PageSnapshotTaker(AutomationProvider* automation,
1274 IPC::Message* reply_message,
[email protected]aa190632012-12-04 07:39:531275 content::WebContents* web_contents,
[email protected]650b2d52013-02-10 03:41:451276 const base::FilePath& path);
[email protected]b6ce91b2011-02-10 21:30:501277 virtual ~PageSnapshotTaker();
[email protected]4203e6b2010-11-12 21:41:501278
1279 // Start the process of taking a snapshot of the entire page.
1280 void Start();
1281
1282 private:
[email protected]4ad6c3a2012-06-14 00:31:171283 // Overridden from TabEventObserver:
[email protected]fad82962011-10-28 21:09:061284 virtual void OnSnapshotEntirePageACK(
1285 bool success,
1286 const std::vector<unsigned char>& png_data,
1287 const std::string& error_msg) OVERRIDE;
[email protected]4ad6c3a2012-06-14 00:31:171288
1289 // Overridden from content::NotificationObserver:
[email protected]fad82962011-10-28 21:09:061290 virtual void Observe(int type,
1291 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171292 const content::NotificationDetails& details) OVERRIDE;
[email protected]4203e6b2010-11-12 21:41:501293
1294 // Helper method to send a response back to the client. Deletes this.
[email protected]2b496732011-07-25 22:42:021295 void SendMessage(bool success, const std::string& error_msg);
[email protected]4203e6b2010-11-12 21:41:501296
[email protected]7d9aecf2011-02-09 11:58:031297 base::WeakPtr<AutomationProvider> automation_;
1298 scoped_ptr<IPC::Message> reply_message_;
[email protected]aa190632012-12-04 07:39:531299 content::WebContents* web_contents_;
[email protected]650b2d52013-02-10 03:41:451300 base::FilePath image_path_;
[email protected]fad82962011-10-28 21:09:061301 content::NotificationRegistrar registrar_;
[email protected]4203e6b2010-11-12 21:41:501302
1303 DISALLOW_COPY_AND_ASSIGN(PageSnapshotTaker);
1304};
1305
[email protected]165901feb2012-05-23 15:38:221306// Processes automation mouse events and invokes a callback when processing
1307// has completed.
1308class AutomationMouseEventProcessor : public content::RenderViewHostObserver,
1309 public content::NotificationObserver {
1310 public:
1311 typedef base::Callback<void(const gfx::Point&)> CompletionCallback;
1312 typedef base::Callback<void(const automation::Error&)> ErrorCallback;
1313
1314 // Creates a new processor which immediately processes the given event.
1315 // Either the |completion_callback| or |error_callback| will be called
1316 // exactly once. After invoking the callback, this class will delete itself.
1317 // The |completion_callback| will be given the point at which the mouse event
1318 // occurred.
1319 AutomationMouseEventProcessor(content::RenderViewHost* render_view_host,
1320 const AutomationMouseEvent& event,
1321 const CompletionCallback& completion_callback,
1322 const ErrorCallback& error_callback);
1323 virtual ~AutomationMouseEventProcessor();
1324
1325 private:
1326 // IPC message handlers.
1327 virtual void OnWillProcessMouseEventAt(const gfx::Point& point);
1328 virtual void OnProcessMouseEventACK(
1329 bool success,
1330 const std::string& error_msg);
1331
[email protected]4ad6c3a2012-06-14 00:31:171332 // Overriden from RenderViewHostObserver.
[email protected]165901feb2012-05-23 15:38:221333 virtual void RenderViewHostDestroyed(content::RenderViewHost* host) OVERRIDE;
1334 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
1335
[email protected]4ad6c3a2012-06-14 00:31:171336 // Overridden from content::NotificationObserver:
[email protected]165901feb2012-05-23 15:38:221337 virtual void Observe(int type,
1338 const content::NotificationSource& source,
1339 const content::NotificationDetails& details) OVERRIDE;
1340
1341 // Helper method to invoke the appropriate callback. Uses the given error
1342 // only if the operation failed. Deletes this.
1343 void InvokeCallback(const automation::Error& error);
1344
1345 content::NotificationRegistrar registrar_;
1346 CompletionCallback completion_callback_;
1347 ErrorCallback error_callback_;
1348 bool has_point_;
1349 gfx::Point point_;
1350
1351 DISALLOW_COPY_AND_ASSIGN(AutomationMouseEventProcessor);
1352};
1353
[email protected]6c2381d2011-10-19 02:52:531354class NTPInfoObserver : public content::NotificationObserver {
[email protected]5783990a2010-11-19 00:24:481355 public:
[email protected]da927a12012-11-06 00:39:491356 NTPInfoObserver(AutomationProvider* automation, IPC::Message* reply_message);
[email protected]aa20e062010-12-07 23:07:271357 virtual ~NTPInfoObserver();
[email protected]5783990a2010-11-19 00:24:481358
[email protected]4ad6c3a2012-06-14 00:31:171359 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271360 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531361 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171362 const content::NotificationDetails& details) OVERRIDE;
[email protected]5783990a2010-11-19 00:24:481363
1364 private:
1365 void OnTopSitesLoaded();
1366 void OnTopSitesReceived(const history::MostVisitedURLList& visited_list);
1367
[email protected]7d9aecf2011-02-09 11:58:031368 base::WeakPtr<AutomationProvider> automation_;
1369 scoped_ptr<IPC::Message> reply_message_;
[email protected]5783990a2010-11-19 00:24:481370 CancelableRequestProvider::Handle request_;
[email protected]f3a1c642011-07-12 19:15:031371 scoped_ptr<base::DictionaryValue> ntp_info_;
[email protected]5783990a2010-11-19 00:24:481372 history::TopSites* top_sites_;
[email protected]6c2381d2011-10-19 02:52:531373 content::NotificationRegistrar registrar_;
[email protected]5783990a2010-11-19 00:24:481374
1375 DISALLOW_COPY_AND_ASSIGN(NTPInfoObserver);
1376};
1377
[email protected]cef7a5e2011-04-13 22:15:311378// Observes when an app has been launched, as indicated by a notification that
1379// a content load in some tab has stopped.
[email protected]6c2381d2011-10-19 02:52:531380class AppLaunchObserver : public content::NotificationObserver {
[email protected]cef7a5e2011-04-13 22:15:311381 public:
[email protected]cca0f1e2012-01-03 18:27:461382 AppLaunchObserver(content::NavigationController* controller,
[email protected]cef7a5e2011-04-13 22:15:311383 AutomationProvider* automation,
1384 IPC::Message* reply_message,
1385 extension_misc::LaunchContainer launch_container);
1386 virtual ~AppLaunchObserver();
1387
[email protected]4ad6c3a2012-06-14 00:31:171388 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271389 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531390 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171391 const content::NotificationDetails& details) OVERRIDE;
[email protected]cef7a5e2011-04-13 22:15:311392
1393 private:
[email protected]cca0f1e2012-01-03 18:27:461394 content::NavigationController* controller_;
[email protected]cef7a5e2011-04-13 22:15:311395 base::WeakPtr<AutomationProvider> automation_;
1396 scoped_ptr<IPC::Message> reply_message_;
[email protected]6c2381d2011-10-19 02:52:531397 content::NotificationRegistrar registrar_;
[email protected]cef7a5e2011-04-13 22:15:311398 extension_misc::LaunchContainer launch_container_;
1399 int new_window_id_;
1400
1401 DISALLOW_COPY_AND_ASSIGN(AppLaunchObserver);
1402};
1403
[email protected]17a00eb2010-12-15 18:14:501404// Allows the automation provider to wait until all the notification
1405// processes are ready.
[email protected]6c2381d2011-10-19 02:52:531406class GetAllNotificationsObserver : public content::NotificationObserver {
[email protected]17a00eb2010-12-15 18:14:501407 public:
[email protected]0fb286e2011-10-18 19:34:401408 GetAllNotificationsObserver(AutomationProvider* automation,
1409 IPC::Message* reply_message);
1410 virtual ~GetAllNotificationsObserver();
[email protected]17a00eb2010-12-15 18:14:501411
[email protected]4ad6c3a2012-06-14 00:31:171412 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271413 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531414 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171415 const content::NotificationDetails& details) OVERRIDE;
[email protected]17a00eb2010-12-15 18:14:501416
1417 private:
[email protected]4dc553ab2011-05-13 17:42:501418 // Sends a message via the |AutomationProvider|. |automation_| must be valid.
1419 // Deletes itself after the message is sent.
[email protected]17a00eb2010-12-15 18:14:501420 void SendMessage();
[email protected]0fb286e2011-10-18 19:34:401421 // Returns a new dictionary describing the given notification.
1422 base::DictionaryValue* NotificationToJson(const Notification* note);
[email protected]17a00eb2010-12-15 18:14:501423
[email protected]4321f53812011-10-19 02:59:401424 content::NotificationRegistrar registrar_;
[email protected]4dc553ab2011-05-13 17:42:501425 base::WeakPtr<AutomationProvider> automation_;
1426 scoped_ptr<IPC::Message> reply_message_;
[email protected]17a00eb2010-12-15 18:14:501427
[email protected]0fb286e2011-10-18 19:34:401428 DISALLOW_COPY_AND_ASSIGN(GetAllNotificationsObserver);
1429};
1430
1431// Allows the automation provider to wait for a new notification balloon
1432// to appear and be ready.
[email protected]6c2381d2011-10-19 02:52:531433class NewNotificationBalloonObserver : public content::NotificationObserver {
[email protected]0fb286e2011-10-18 19:34:401434 public:
1435 NewNotificationBalloonObserver(AutomationProvider* provider,
1436 IPC::Message* reply_message);
1437 virtual ~NewNotificationBalloonObserver();
[email protected]4ad6c3a2012-06-14 00:31:171438
1439 // Overridden from content::NotificationObserver:
[email protected]0fb286e2011-10-18 19:34:401440 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531441 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171442 const content::NotificationDetails& details) OVERRIDE;
[email protected]0fb286e2011-10-18 19:34:401443
1444 private:
[email protected]6c2381d2011-10-19 02:52:531445 content::NotificationRegistrar registrar_;
[email protected]0fb286e2011-10-18 19:34:401446 base::WeakPtr<AutomationProvider> automation_;
1447 scoped_ptr<IPC::Message> reply_message_;
1448
1449 DISALLOW_COPY_AND_ASSIGN(NewNotificationBalloonObserver);
[email protected]17a00eb2010-12-15 18:14:501450};
1451
[email protected]ac43f702010-10-26 20:18:451452// Allows the automation provider to wait for a given number of
1453// notification balloons.
[email protected]6c2381d2011-10-19 02:52:531454class OnNotificationBalloonCountObserver
1455 : public content::NotificationObserver {
[email protected]ac43f702010-10-26 20:18:451456 public:
1457 OnNotificationBalloonCountObserver(AutomationProvider* provider,
1458 IPC::Message* reply_message,
[email protected]ac43f702010-10-26 20:18:451459 int count);
[email protected]f6e8e1e2011-05-13 18:05:311460 virtual ~OnNotificationBalloonCountObserver();
[email protected]ac43f702010-10-26 20:18:451461
[email protected]4dc553ab2011-05-13 17:42:501462 // Sends an automation reply message if |automation_| is still valid and the
1463 // number of ready balloons matches the desired count. Deletes itself if the
1464 // message is sent or if |automation_| is invalid.
1465 void CheckBalloonCount();
1466
[email protected]4ad6c3a2012-06-14 00:31:171467 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271468 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531469 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171470 const content::NotificationDetails& details) OVERRIDE;
[email protected]ac43f702010-10-26 20:18:451471
1472 private:
[email protected]6c2381d2011-10-19 02:52:531473 content::NotificationRegistrar registrar_;
[email protected]4dc553ab2011-05-13 17:42:501474 base::WeakPtr<AutomationProvider> automation_;
1475 scoped_ptr<IPC::Message> reply_message_;
1476
[email protected]ac43f702010-10-26 20:18:451477 BalloonCollection* collection_;
1478 int count_;
1479
1480 DISALLOW_COPY_AND_ASSIGN(OnNotificationBalloonCountObserver);
1481};
1482
[email protected]ddbe86692010-12-14 17:32:521483// Allows the automation provider to wait for a RENDERER_PROCESS_CLOSED
1484// notification.
[email protected]6c2381d2011-10-19 02:52:531485class RendererProcessClosedObserver : public content::NotificationObserver {
[email protected]ddbe86692010-12-14 17:32:521486 public:
1487 RendererProcessClosedObserver(AutomationProvider* automation,
1488 IPC::Message* reply_message);
[email protected]b6ce91b2011-02-10 21:30:501489 virtual ~RendererProcessClosedObserver();
[email protected]ddbe86692010-12-14 17:32:521490
[email protected]4ad6c3a2012-06-14 00:31:171491 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271492 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531493 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171494 const content::NotificationDetails& details) OVERRIDE;
[email protected]ddbe86692010-12-14 17:32:521495
1496 private:
[email protected]6c2381d2011-10-19 02:52:531497 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:031498 base::WeakPtr<AutomationProvider> automation_;
1499 scoped_ptr<IPC::Message> reply_message_;
[email protected]ddbe86692010-12-14 17:32:521500
1501 DISALLOW_COPY_AND_ASSIGN(RendererProcessClosedObserver);
1502};
1503
[email protected]a1b38b3c2011-04-27 15:49:161504// Allows the automation provider to wait for acknowledgement that a certain
1505// type and number of input events has been processed by the renderer.
[email protected]6c2381d2011-10-19 02:52:531506class InputEventAckNotificationObserver : public content::NotificationObserver {
[email protected]92e937562011-01-31 21:00:581507 public:
1508 InputEventAckNotificationObserver(AutomationProvider* automation,
1509 IPC::Message* reply_message,
[email protected]a1b38b3c2011-04-27 15:49:161510 int event_type, int count);
[email protected]b6ce91b2011-02-10 21:30:501511 virtual ~InputEventAckNotificationObserver();
[email protected]92e937562011-01-31 21:00:581512
[email protected]4ad6c3a2012-06-14 00:31:171513 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271514 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531515 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171516 const content::NotificationDetails& details) OVERRIDE;
[email protected]92e937562011-01-31 21:00:581517
1518 private:
[email protected]6c2381d2011-10-19 02:52:531519 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:031520 base::WeakPtr<AutomationProvider> automation_;
1521 scoped_ptr<IPC::Message> reply_message_;
[email protected]92e937562011-01-31 21:00:581522 int event_type_;
[email protected]a1b38b3c2011-04-27 15:49:161523 int count_;
[email protected]92e937562011-01-31 21:00:581524
1525 DISALLOW_COPY_AND_ASSIGN(InputEventAckNotificationObserver);
1526};
1527
[email protected]4518a582011-12-06 02:34:241528// Allows the automation provider to wait for all render views to finish any
1529// pending loads. This wait is only guaranteed for views that exist at the
1530// observer's creation. Will send a message on construction if no views are
1531// currently loading.
1532class AllViewsStoppedLoadingObserver : public TabEventObserver,
1533 public content::NotificationObserver {
[email protected]781dbd7d2011-02-25 23:23:271534 public:
[email protected]4518a582011-12-06 02:34:241535 AllViewsStoppedLoadingObserver(
1536 AutomationProvider* automation,
1537 IPC::Message* reply_message,
1538 ExtensionProcessManager* extension_process_manager);
1539 virtual ~AllViewsStoppedLoadingObserver();
[email protected]781dbd7d2011-02-25 23:23:271540
[email protected]eb0bff942011-04-07 22:08:381541 // TabEventObserver implementation.
[email protected]26b5e322011-12-23 01:36:471542 virtual void OnFirstPendingLoad(content::WebContents* web_contents) OVERRIDE;
1543 virtual void OnNoMorePendingLoads(
1544 content::WebContents* web_contents) OVERRIDE;
[email protected]2b496732011-07-25 22:42:021545
[email protected]4ad6c3a2012-06-14 00:31:171546 // Overridden from content::NotificationObserver:
[email protected]2b496732011-07-25 22:42:021547 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531548 const content::NotificationSource& source,
1549 const content::NotificationDetails& details) OVERRIDE;
[email protected]781dbd7d2011-02-25 23:23:271550
1551 private:
[email protected]26b5e322011-12-23 01:36:471552 typedef std::set<content::WebContents*> TabSet;
[email protected]eb0bff942011-04-07 22:08:381553
1554 // Checks if there are no pending loads. If none, it will send an automation
1555 // relpy and delete itself.
1556 void CheckIfNoMorePendingLoads();
1557
[email protected]781dbd7d2011-02-25 23:23:271558 base::WeakPtr<AutomationProvider> automation_;
1559 scoped_ptr<IPC::Message> reply_message_;
[email protected]4518a582011-12-06 02:34:241560 ExtensionProcessManager* extension_process_manager_;
1561 content::NotificationRegistrar registrar_;
1562 TabSet pending_tabs_;
[email protected]781dbd7d2011-02-25 23:23:271563
[email protected]4518a582011-12-06 02:34:241564 DISALLOW_COPY_AND_ASSIGN(AllViewsStoppedLoadingObserver);
[email protected]781dbd7d2011-02-25 23:23:271565};
1566
[email protected]49922312011-01-31 17:37:541567// Observer used to listen for new tab creation to complete.
[email protected]6c2381d2011-10-19 02:52:531568class NewTabObserver : public content::NotificationObserver {
[email protected]49922312011-01-31 17:37:541569 public:
[email protected]16a517a2012-07-14 01:08:581570 NewTabObserver(AutomationProvider* automation,
1571 IPC::Message* reply_message,
1572 bool use_json_interface);
[email protected]49922312011-01-31 17:37:541573
[email protected]4ad6c3a2012-06-14 00:31:171574 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271575 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531576 const content::NotificationSource& source,
1577 const content::NotificationDetails& details) OVERRIDE;
[email protected]49922312011-01-31 17:37:541578
1579 private:
[email protected]b6ce91b2011-02-10 21:30:501580 virtual ~NewTabObserver();
[email protected]49922312011-01-31 17:37:541581
[email protected]6c2381d2011-10-19 02:52:531582 content::NotificationRegistrar registrar_;
[email protected]7d9aecf2011-02-09 11:58:031583 base::WeakPtr<AutomationProvider> automation_;
1584 scoped_ptr<IPC::Message> reply_message_;
[email protected]16a517a2012-07-14 01:08:581585 bool use_json_interface_;
[email protected]49922312011-01-31 17:37:541586
1587 DISALLOW_COPY_AND_ASSIGN(NewTabObserver);
1588};
1589
1590// Posts a task to the PROCESS_LAUNCHER thread, once processed posts a task
1591// back to the UI thread that notifies the provider we're done.
1592class WaitForProcessLauncherThreadToGoIdleObserver
1593 : public base::RefCountedThreadSafe<
[email protected]7d9aecf2011-02-09 11:58:031594 WaitForProcessLauncherThreadToGoIdleObserver,
[email protected]631bb742011-11-02 11:29:391595 content::BrowserThread::DeleteOnUIThread> {
[email protected]49922312011-01-31 17:37:541596 public:
1597 WaitForProcessLauncherThreadToGoIdleObserver(
1598 AutomationProvider* automation, IPC::Message* reply_message);
1599
1600 private:
[email protected]631bb742011-11-02 11:29:391601 friend struct content::BrowserThread::DeleteOnThread<
1602 content::BrowserThread::UI>;
[email protected]cff06c572012-01-02 20:03:051603 friend class base::DeleteHelper<WaitForProcessLauncherThreadToGoIdleObserver>;
[email protected]49922312011-01-31 17:37:541604
[email protected]b6ce91b2011-02-10 21:30:501605 virtual ~WaitForProcessLauncherThreadToGoIdleObserver();
[email protected]49922312011-01-31 17:37:541606
[email protected]cdc54892011-03-04 22:33:091607 // Schedules a task on the PROCESS_LAUNCHER thread to execute
1608 // |RunOnProcessLauncherThread2|. By the time the task is executed the
1609 // PROCESS_LAUNCHER thread should be some what idle.
[email protected]49922312011-01-31 17:37:541610 void RunOnProcessLauncherThread();
[email protected]cdc54892011-03-04 22:33:091611
1612 // When executed the PROCESS_LAUNCHER thread should have processed any pending
1613 // tasks. Schedules a task on the UI thread that sends the message saying
1614 // we're done.
1615 void RunOnProcessLauncherThread2();
1616
1617 // Sends the |reply_message_| to |automation_| indicating we're done.
[email protected]49922312011-01-31 17:37:541618 void RunOnUIThread();
1619
[email protected]7d9aecf2011-02-09 11:58:031620 base::WeakPtr<AutomationProvider> automation_;
1621 scoped_ptr<IPC::Message> reply_message_;
[email protected]49922312011-01-31 17:37:541622
1623 DISALLOW_COPY_AND_ASSIGN(WaitForProcessLauncherThreadToGoIdleObserver);
1624};
[email protected]ac43f702010-10-26 20:18:451625
[email protected]fcad49452011-06-28 17:11:571626// Allows the automation provider to wait for acknowledgement that a drop
1627// operation has been processed by the renderer.
[email protected]6c2381d2011-10-19 02:52:531628class DragTargetDropAckNotificationObserver
1629 : public content::NotificationObserver {
[email protected]fcad49452011-06-28 17:11:571630 public:
1631 DragTargetDropAckNotificationObserver(AutomationProvider* automation,
1632 IPC::Message* reply_message);
1633 virtual ~DragTargetDropAckNotificationObserver();
1634
[email protected]4ad6c3a2012-06-14 00:31:171635 // Overridden from content::NotificationObserver:
[email protected]432115822011-07-10 15:52:271636 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531637 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171638 const content::NotificationDetails& details) OVERRIDE;
[email protected]fcad49452011-06-28 17:11:571639
1640 private:
[email protected]6c2381d2011-10-19 02:52:531641 content::NotificationRegistrar registrar_;
[email protected]fcad49452011-06-28 17:11:571642 base::WeakPtr<AutomationProvider> automation_;
1643 scoped_ptr<IPC::Message> reply_message_;
1644
1645 DISALLOW_COPY_AND_ASSIGN(DragTargetDropAckNotificationObserver);
1646};
1647
[email protected]b0539752011-09-23 00:33:151648// Allows the automation provider to wait for process memory details to be
1649// available before sending this information to the client.
1650class ProcessInfoObserver : public MemoryDetails {
1651 public:
1652 ProcessInfoObserver(AutomationProvider* automation,
1653 IPC::Message* reply_message);
1654
1655 virtual void OnDetailsAvailable() OVERRIDE;
1656
1657 private:
[email protected]5ed5b9292011-09-23 11:09:171658 virtual ~ProcessInfoObserver();
[email protected]b0539752011-09-23 00:33:151659 base::WeakPtr<AutomationProvider> automation_;
1660 scoped_ptr<IPC::Message> reply_message_;
1661
1662 DISALLOW_COPY_AND_ASSIGN(ProcessInfoObserver);
1663};
1664
[email protected]83c841a2012-02-08 19:18:261665// Observes when new v8 heap statistics are computed for a renderer process.
[email protected]1fdb89f2012-02-03 23:26:441666class V8HeapStatsObserver : public content::NotificationObserver {
1667 public:
1668 V8HeapStatsObserver(AutomationProvider* automation,
1669 IPC::Message* reply_message,
1670 base::ProcessId renderer_id);
1671 virtual ~V8HeapStatsObserver();
1672
[email protected]4ad6c3a2012-06-14 00:31:171673 // Overridden from content::NotificationObserver:
[email protected]1fdb89f2012-02-03 23:26:441674 virtual void Observe(int type,
1675 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171676 const content::NotificationDetails& details) OVERRIDE;
[email protected]1fdb89f2012-02-03 23:26:441677
1678 private:
1679 content::NotificationRegistrar registrar_;
1680 base::WeakPtr<AutomationProvider> automation_;
1681 scoped_ptr<IPC::Message> reply_message_;
1682 base::ProcessId renderer_id_;
1683
1684 DISALLOW_COPY_AND_ASSIGN(V8HeapStatsObserver);
1685};
1686
[email protected]83c841a2012-02-08 19:18:261687// Observes when a new FPS value is computed for a renderer process.
1688class FPSObserver : public content::NotificationObserver {
1689 public:
1690 FPSObserver(AutomationProvider* automation,
1691 IPC::Message* reply_message,
1692 base::ProcessId renderer_id,
1693 int routing_id);
1694 virtual ~FPSObserver();
1695
[email protected]4ad6c3a2012-06-14 00:31:171696 // Overridden from content::NotificationObserver:
[email protected]83c841a2012-02-08 19:18:261697 virtual void Observe(int type,
1698 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171699 const content::NotificationDetails& details) OVERRIDE;
[email protected]83c841a2012-02-08 19:18:261700
1701 private:
1702 content::NotificationRegistrar registrar_;
1703 base::WeakPtr<AutomationProvider> automation_;
1704 scoped_ptr<IPC::Message> reply_message_;
1705 base::ProcessId renderer_id_;
1706 int routing_id_;
1707
1708 DISALLOW_COPY_AND_ASSIGN(FPSObserver);
1709};
1710
[email protected]53d9e952011-09-23 09:44:111711// Manages the process of creating a new Profile and opening a new browser with
1712// that profile. This observer should be created, and then a new Profile
1713// should be created through the ProfileManager using
1714// profile_manager->CreateMultiProfileAsync(). The Observer watches for profile
1715// creation, upon which it creates a new browser window; after observing
1716// window creation, it creates a new tab and then finally observes it finish
1717// loading.
1718class BrowserOpenedWithNewProfileNotificationObserver
[email protected]6c2381d2011-10-19 02:52:531719 : public content::NotificationObserver {
[email protected]53d9e952011-09-23 09:44:111720 public:
1721 BrowserOpenedWithNewProfileNotificationObserver(
1722 AutomationProvider* automation,
1723 IPC::Message* reply_message);
1724 virtual ~BrowserOpenedWithNewProfileNotificationObserver();
1725
[email protected]4ad6c3a2012-06-14 00:31:171726 // Overridden from content::NotificationObserver:
[email protected]53d9e952011-09-23 09:44:111727 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:531728 const content::NotificationSource& source,
[email protected]4ad6c3a2012-06-14 00:31:171729 const content::NotificationDetails& details) OVERRIDE;
[email protected]53d9e952011-09-23 09:44:111730
1731 private:
[email protected]6c2381d2011-10-19 02:52:531732 content::NotificationRegistrar registrar_;
[email protected]53d9e952011-09-23 09:44:111733 base::WeakPtr<AutomationProvider> automation_;
1734 scoped_ptr<IPC::Message> reply_message_;
1735 int new_window_id_;
1736
1737 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedWithNewProfileNotificationObserver);
1738};
1739
[email protected]4518a582011-12-06 02:34:241740// Waits for an extension popup to appear and load.
1741class ExtensionPopupObserver : public content::NotificationObserver {
1742 public:
1743 ExtensionPopupObserver(
1744 AutomationProvider* automation,
1745 IPC::Message* reply_message,
1746 const std::string& extension_id);
1747 ~ExtensionPopupObserver();
1748
[email protected]4ad6c3a2012-06-14 00:31:171749 // Overridden from content::NotificationObserver:
[email protected]4518a582011-12-06 02:34:241750 virtual void Observe(int type,
1751 const content::NotificationSource& source,
1752 const content::NotificationDetails& details) OVERRIDE;
1753
1754 private:
1755 base::WeakPtr<AutomationProvider> automation_;
1756 scoped_ptr<IPC::Message> reply_message_;
1757 std::string extension_id_;
1758 content::NotificationRegistrar registrar_;
1759
1760 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupObserver);
1761};
1762
[email protected]4ad6c3a2012-06-14 00:31:171763#if defined(OS_LINUX)
1764// Allows the automation provider to wait for a WINDOW_MAXIMIZED notification.
1765class WindowMaximizedObserver : public content::NotificationObserver {
1766 public:
1767 WindowMaximizedObserver(AutomationProvider* automation,
1768 IPC::Message* reply_message);
1769 virtual ~WindowMaximizedObserver();
1770
1771 // Overridden from content::NotificationObserver:
1772 virtual void Observe(int type,
1773 const content::NotificationSource& source,
1774 const content::NotificationDetails& details) OVERRIDE;
1775
1776 private:
1777 content::NotificationRegistrar registrar_;
1778 base::WeakPtr<AutomationProvider> automation_;
1779 scoped_ptr<IPC::Message> reply_message_;
1780
1781 DISALLOW_COPY_AND_ASSIGN(WindowMaximizedObserver);
1782};
1783#endif // defined(OS_LINUX)
1784
[email protected]d024cd12012-06-19 21:46:301785// Wait for a new browser window to get created (for an existing profile).
1786// Useful when reopening a multi-profile window.
1787class BrowserOpenedWithExistingProfileNotificationObserver
1788 : public content::NotificationObserver {
1789 public:
1790 BrowserOpenedWithExistingProfileNotificationObserver(
1791 AutomationProvider* automation,
1792 IPC::Message* reply_message,
1793 int num_loads);
1794 virtual ~BrowserOpenedWithExistingProfileNotificationObserver();
[email protected]4ad6c3a2012-06-14 00:31:171795
[email protected]d024cd12012-06-19 21:46:301796 virtual void Observe(int type,
1797 const content::NotificationSource& source,
1798 const content::NotificationDetails& details);
1799 private:
1800 content::NotificationRegistrar registrar_;
1801 base::WeakPtr<AutomationProvider> automation_;
1802 scoped_ptr<IPC::Message> reply_message_;
1803 int new_window_id_;
1804 int num_loads_;
1805
1806 DISALLOW_COPY_AND_ASSIGN(
1807 BrowserOpenedWithExistingProfileNotificationObserver);
1808};
[email protected]4ad6c3a2012-06-14 00:31:171809
[email protected]e12de87e2009-08-28 00:02:081810#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_