[email protected] | 1fdb89f | 2012-02-03 23:26:44 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 2 | // 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] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 8 | #include <deque> |
[email protected] | 84abba6 | 2009-10-07 17:01:44 | [diff] [blame] | 9 | #include <map> |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 10 | #include <set> |
[email protected] | 525074d | 2011-03-07 22:32:27 | [diff] [blame] | 11 | #include <string> |
| 12 | #include <vector> |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 13 | |
[email protected] | e1f0fc3 | 2011-12-01 08:58:17 | [diff] [blame] | 14 | #include "base/callback.h" |
[email protected] | ea52f51 | 2011-03-08 19:55:51 | [diff] [blame] | 15 | #include "base/compiler_specific.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 16 | #include "base/memory/scoped_ptr.h" |
| 17 | #include "base/memory/weak_ptr.h" |
[email protected] | fb44196 | 2013-05-08 05:35:24 | [diff] [blame] | 18 | #include "base/sequenced_task_runner_helpers.h" |
[email protected] | 4449a40c | 2011-05-03 19:29:52 | [diff] [blame] | 19 | #include "base/synchronization/waitable_event.h" |
[email protected] | e8cc8b3 | 2011-08-24 10:40:54 | [diff] [blame] | 20 | #include "base/values.h" |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 21 | #include "chrome/browser/automation/automation_provider_json.h" |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 22 | #include "chrome/browser/automation/automation_tab_helper.h" |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 23 | #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
[email protected] | e4b2fa3 | 2013-03-09 22:56:56 | [diff] [blame] | 24 | #include "components/autofill/browser/personal_data_manager.h" |
| 25 | #include "components/autofill/browser/personal_data_manager_observer.h" |
[email protected] | 60ae33e | 2011-03-10 00:44:34 | [diff] [blame] | 26 | #if defined(OS_CHROMEOS) |
| 27 | #include "chrome/browser/chromeos/cros/network_library.h" |
[email protected] | 0254980 | 2013-04-22 18:25:51 | [diff] [blame] | 28 | #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 29 | #include "chrome/browser/chromeos/login/login_status_consumer.h" |
[email protected] | 61a9fb3 | 2011-08-03 21:00:51 | [diff] [blame] | 30 | #include "chrome/browser/chromeos/login/user_manager.h" |
[email protected] | 6a33bb9 | 2011-07-28 02:41:19 | [diff] [blame] | 31 | #include "chrome/browser/chromeos/login/wizard_controller.h" |
[email protected] | 60ae33e | 2011-03-10 00:44:34 | [diff] [blame] | 32 | #endif // defined(OS_CHROMEOS) |
[email protected] | 01b654b | 2012-09-22 02:16:44 | [diff] [blame] | 33 | #include "chrome/browser/common/cancelable_request.h" |
[email protected] | 73c4348 | 2012-11-07 16:53:19 | [diff] [blame] | 34 | #include "chrome/browser/download/all_download_item_notifier.h" |
[email protected] | 6a2c09f | 2013-01-25 04:50:07 | [diff] [blame] | 35 | #include "chrome/browser/history/history_service.h" |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 36 | #include "chrome/browser/history/history_types.h" |
[email protected] | c5aa532 | 2010-07-15 19:00:07 | [diff] [blame] | 37 | #include "chrome/browser/importer/importer_data_types.h" |
[email protected] | ea52f51 | 2011-03-08 19:55:51 | [diff] [blame] | 38 | #include "chrome/browser/importer/importer_progress_observer.h" |
[email protected] | b053975 | 2011-09-23 00:33:15 | [diff] [blame] | 39 | #include "chrome/browser/memory_details.h" |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 40 | #include "chrome/browser/password_manager/password_store_change.h" |
[email protected] | e5721c18 | 2011-03-28 22:27:34 | [diff] [blame] | 41 | #include "chrome/browser/password_manager/password_store_consumer.h" |
[email protected] | 8e5c89a | 2011-06-07 18:13:33 | [diff] [blame] | 42 | #include "chrome/browser/search_engines/template_url_service_observer.h" |
[email protected] | b56e2e3 | 2012-05-11 21:18:04 | [diff] [blame] | 43 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | a22f7e0 | 2011-02-09 07:15:35 | [diff] [blame] | 44 | #include "chrome/common/automation_constants.h" |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 45 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | b7b6387 | 2013-01-03 02:41:19 | [diff] [blame] | 46 | #include "content/public/browser/browser_thread.h" |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 47 | #include "content/public/browser/download_item.h" |
| 48 | #include "content/public/browser/download_manager.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 49 | #include "content/public/browser/notification_observer.h" |
| 50 | #include "content/public/browser/notification_registrar.h" |
[email protected] | 0d6e9bd | 2011-10-18 04:29:16 | [diff] [blame] | 51 | #include "content/public/browser/notification_types.h" |
[email protected] | 165901feb | 2012-05-23 15:38:22 | [diff] [blame] | 52 | #include "content/public/browser/render_view_host_observer.h" |
| 53 | #include "ui/gfx/point.h" |
[email protected] | a22f7e0 | 2011-02-09 07:15:35 | [diff] [blame] | 54 | #include "ui/gfx/size.h" |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 55 | |
[email protected] | 165901feb | 2012-05-23 15:38:22 | [diff] [blame] | 56 | struct AutomationMouseEvent; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 57 | class AutomationProvider; |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 58 | class BalloonCollection; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 59 | class Browser; |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 60 | class ExtensionProcessManager; |
[email protected] | 0e0bbb1 | 2011-08-23 18:42:17 | [diff] [blame] | 61 | class ExtensionService; |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 62 | class Notification; |
[email protected] | 04024e2c | 2011-08-12 19:32:10 | [diff] [blame] | 63 | class Profile; |
[email protected] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 64 | class SavePackage; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 65 | |
[email protected] | 165901feb | 2012-05-23 15:38:22 | [diff] [blame] | 66 | namespace automation { |
| 67 | class Error; |
| 68 | } |
| 69 | |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 70 | #if defined(OS_CHROMEOS) |
| 71 | namespace chromeos { |
[email protected] | 64b1b48ef | 2012-06-04 13:43:54 | [diff] [blame] | 72 | class ExistingUserController; |
| 73 | class WizardScreen; |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 74 | } |
| 75 | #endif // defined(OS_CHROMEOS) |
| 76 | |
[email protected] | 768c547 | 2011-12-26 19:06:17 | [diff] [blame] | 77 | namespace content { |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 78 | class NavigationController; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 79 | class RenderViewHost; |
[email protected] | 768c547 | 2011-12-26 19:06:17 | [diff] [blame] | 80 | class WebContents; |
| 81 | } |
| 82 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 83 | namespace extensions { |
| 84 | class Extension; |
| 85 | } |
| 86 | |
[email protected] | 768c547 | 2011-12-26 19:06:17 | [diff] [blame] | 87 | namespace history { |
| 88 | class TopSites; |
| 89 | } |
| 90 | |
[email protected] | aa19063 | 2012-12-04 07:39:53 | [diff] [blame] | 91 | namespace IPC { |
| 92 | class Message; |
| 93 | } |
| 94 | |
[email protected] | e1f0fc3 | 2011-12-01 08:58:17 | [diff] [blame] | 95 | namespace policy { |
| 96 | class BrowserPolicyConnector; |
| 97 | } |
| 98 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 99 | class InitialLoadObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 100 | public: |
| 101 | InitialLoadObserver(size_t tab_count, AutomationProvider* automation); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 102 | virtual ~InitialLoadObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 103 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 104 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 105 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 106 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 107 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 108 | |
[email protected] | a3cd502 | 2010-06-16 18:25:29 | [diff] [blame] | 109 | // 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] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 116 | base::DictionaryValue* GetTimingInformation() const; |
[email protected] | a3cd502 | 2010-06-16 18:25:29 | [diff] [blame] | 117 | |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 118 | private: |
[email protected] | a3cd502 | 2010-06-16 18:25:29 | [diff] [blame] | 119 | class TabTime; |
| 120 | typedef std::map<uintptr_t, TabTime> TabTimeMap; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 121 | typedef std::set<uintptr_t> TabSet; |
| 122 | |
| 123 | void ConditionMet(); |
| 124 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 125 | content::NotificationRegistrar registrar_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 126 | |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 127 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | 2ce26c43 | 2011-09-19 17:08:12 | [diff] [blame] | 128 | size_t crashed_tab_count_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 129 | size_t outstanding_tab_count_; |
[email protected] | a3cd502 | 2010-06-16 18:25:29 | [diff] [blame] | 130 | base::TimeTicks init_time_; |
| 131 | TabTimeMap loading_tabs_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 132 | TabSet finished_tabs_; |
| 133 | |
| 134 | DISALLOW_COPY_AND_ASSIGN(InitialLoadObserver); |
| 135 | }; |
| 136 | |
[email protected] | 60ae33e | 2011-03-10 00:44:34 | [diff] [blame] | 137 | #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. |
| 140 | class NetworkManagerInitObserver |
| 141 | : public chromeos::NetworkLibrary::NetworkManagerObserver { |
| 142 | public: |
| 143 | explicit NetworkManagerInitObserver(AutomationProvider* automation); |
| 144 | virtual ~NetworkManagerInitObserver(); |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 145 | virtual bool Init(); |
[email protected] | 60ae33e | 2011-03-10 00:44:34 | [diff] [blame] | 146 | virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj); |
| 147 | |
| 148 | private: |
| 149 | base::WeakPtr<AutomationProvider> automation_; |
| 150 | |
| 151 | DISALLOW_COPY_AND_ASSIGN(NetworkManagerInitObserver); |
| 152 | }; |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 153 | |
[email protected] | a105fa3 | 2012-05-16 21:32:05 | [diff] [blame] | 154 | // 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] | 64b1b48ef | 2012-06-04 13:43:54 | [diff] [blame] | 157 | class OOBEWebuiReadyObserver : public content::NotificationObserver { |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 158 | public: |
[email protected] | 64b1b48ef | 2012-06-04 13:43:54 | [diff] [blame] | 159 | explicit OOBEWebuiReadyObserver(AutomationProvider* automation); |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 160 | |
| 161 | // Overridden from content::NotificationObserver: |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 162 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 163 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 164 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 165 | |
| 166 | private: |
[email protected] | 64b1b48ef | 2012-06-04 13:43:54 | [diff] [blame] | 167 | void OOBEWebuiReady(); |
| 168 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 169 | content::NotificationRegistrar registrar_; |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 170 | base::WeakPtr<AutomationProvider> automation_; |
| 171 | |
[email protected] | 64b1b48ef | 2012-06-04 13:43:54 | [diff] [blame] | 172 | DISALLOW_COPY_AND_ASSIGN(OOBEWebuiReadyObserver); |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 173 | }; |
[email protected] | 60ae33e | 2011-03-10 00:44:34 | [diff] [blame] | 174 | #endif // defined(OS_CHROMEOS) |
| 175 | |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 176 | // Watches for NewTabUI page loads for performance timing purposes. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 177 | class NewTabUILoadObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 178 | public: |
[email protected] | 04024e2c | 2011-08-12 19:32:10 | [diff] [blame] | 179 | explicit NewTabUILoadObserver(AutomationProvider* automation, |
| 180 | Profile* profile); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 181 | virtual ~NewTabUILoadObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 182 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 183 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 184 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 185 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 186 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 187 | |
| 188 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 189 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 190 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 191 | |
| 192 | DISALLOW_COPY_AND_ASSIGN(NewTabUILoadObserver); |
| 193 | }; |
| 194 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 195 | class NavigationControllerRestoredObserver |
| 196 | : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 197 | public: |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 198 | NavigationControllerRestoredObserver( |
| 199 | AutomationProvider* automation, |
| 200 | content::NavigationController* controller, |
| 201 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 202 | virtual ~NavigationControllerRestoredObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 203 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 204 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 205 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 206 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 207 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 208 | |
| 209 | private: |
| 210 | bool FinishedRestoring(); |
| 211 | void SendDone(); |
| 212 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 213 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 214 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 215 | content::NavigationController* controller_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 216 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 217 | |
| 218 | DISALLOW_COPY_AND_ASSIGN(NavigationControllerRestoredObserver); |
| 219 | }; |
| 220 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 221 | class NavigationNotificationObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 222 | public: |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 223 | NavigationNotificationObserver(content::NavigationController* controller, |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 224 | AutomationProvider* automation, |
| 225 | IPC::Message* reply_message, |
[email protected] | 7dad3d5f | 2010-03-04 00:27:01 | [diff] [blame] | 226 | int number_of_navigations, |
[email protected] | ab6bb8e | 2011-03-03 22:41:16 | [diff] [blame] | 227 | bool include_current_navigation, |
| 228 | bool use_json_interface); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 229 | virtual ~NavigationNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 230 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 231 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 232 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 233 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 234 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 235 | |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 236 | void ConditionMet(AutomationMsg_NavigationResponseValues navigation_result); |
| 237 | |
[email protected] | b336ce6 | 2012-06-08 20:35:57 | [diff] [blame] | 238 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 239 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 240 | base::WeakPtr<AutomationProvider> automation_; |
| 241 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 242 | content::NavigationController* controller_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 243 | int navigations_remaining_; |
| 244 | bool navigation_started_; |
[email protected] | ab6bb8e | 2011-03-03 22:41:16 | [diff] [blame] | 245 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 246 | |
| 247 | DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver); |
| 248 | }; |
| 249 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 250 | class TabStripNotificationObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 251 | public: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 252 | TabStripNotificationObserver(int notification, |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 253 | AutomationProvider* automation); |
| 254 | virtual ~TabStripNotificationObserver(); |
| 255 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 256 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 257 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 258 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 259 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 260 | |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 261 | virtual void ObserveTab(content::NavigationController* controller) = 0; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 262 | |
| 263 | protected: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 264 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 265 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 266 | int notification_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | class TabAppendedNotificationObserver : public TabStripNotificationObserver { |
| 270 | public: |
| 271 | TabAppendedNotificationObserver(Browser* parent, |
| 272 | AutomationProvider* automation, |
[email protected] | 64285855 | 2012-07-13 06:56:52 | [diff] [blame] | 273 | IPC::Message* reply_message, |
| 274 | bool use_json_interface); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 275 | virtual ~TabAppendedNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 276 | |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 277 | virtual void ObserveTab(content::NavigationController* controller); |
[email protected] | 64285855 | 2012-07-13 06:56:52 | [diff] [blame] | 278 | IPC::Message* ReleaseReply(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 279 | |
| 280 | protected: |
| 281 | Browser* parent_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 282 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 64285855 | 2012-07-13 06:56:52 | [diff] [blame] | 283 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 284 | |
| 285 | private: |
| 286 | DISALLOW_COPY_AND_ASSIGN(TabAppendedNotificationObserver); |
| 287 | }; |
| 288 | |
| 289 | class TabClosedNotificationObserver : public TabStripNotificationObserver { |
| 290 | public: |
| 291 | TabClosedNotificationObserver(AutomationProvider* automation, |
| 292 | bool wait_until_closed, |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 293 | IPC::Message* reply_message, |
| 294 | bool use_json_interface); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 295 | virtual ~TabClosedNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 296 | |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 297 | virtual void ObserveTab(content::NavigationController* controller); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 298 | |
| 299 | void set_for_browser_command(bool for_browser_command); |
| 300 | |
| 301 | protected: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 302 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 303 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 304 | bool for_browser_command_; |
| 305 | |
| 306 | private: |
| 307 | DISALLOW_COPY_AND_ASSIGN(TabClosedNotificationObserver); |
| 308 | }; |
| 309 | |
[email protected] | 61855fc | 2010-09-07 19:32:13 | [diff] [blame] | 310 | // Notifies when the tab count reaches the target number. |
| 311 | class 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] | 409ea297 | 2012-11-10 19:54:43 | [diff] [blame] | 318 | virtual void TabInsertedAt(content::WebContents* contents, |
[email protected] | 61855fc | 2010-09-07 19:32:13 | [diff] [blame] | 319 | int index, |
[email protected] | 409ea297 | 2012-11-10 19:54:43 | [diff] [blame] | 320 | bool foreground) OVERRIDE; |
[email protected] | e89cfcb | 2012-11-11 14:47:24 | [diff] [blame] | 321 | virtual void TabDetachedAt(content::WebContents* contents, |
| 322 | int index) OVERRIDE; |
[email protected] | 409ea297 | 2012-11-10 19:54:43 | [diff] [blame] | 323 | virtual void TabStripModelDeleted() OVERRIDE; |
[email protected] | 61855fc | 2010-09-07 19:32:13 | [diff] [blame] | 324 | |
| 325 | private: |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 326 | virtual ~TabCountChangeObserver(); |
[email protected] | 61855fc | 2010-09-07 19:32:13 | [diff] [blame] | 327 | |
| 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] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 332 | base::WeakPtr<AutomationProvider> automation_; |
| 333 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 61855fc | 2010-09-07 19:32:13 | [diff] [blame] | 334 | |
| 335 | TabStripModel* tab_strip_model_; |
| 336 | |
| 337 | const int target_tab_count_; |
| 338 | |
| 339 | DISALLOW_COPY_AND_ASSIGN(TabCountChangeObserver); |
| 340 | }; |
| 341 | |
[email protected] | 99a1aef | 2011-03-29 17:17:23 | [diff] [blame] | 342 | // Observes when an extension has been uninstalled. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 343 | class ExtensionUninstallObserver : public content::NotificationObserver { |
[email protected] | 99a1aef | 2011-03-29 17:17:23 | [diff] [blame] | 344 | public: |
| 345 | ExtensionUninstallObserver(AutomationProvider* automation, |
| 346 | IPC::Message* reply_message, |
| 347 | const std::string& id); |
| 348 | virtual ~ExtensionUninstallObserver(); |
| 349 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 350 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 351 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 352 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 353 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 99a1aef | 2011-03-29 17:17:23 | [diff] [blame] | 354 | |
| 355 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 356 | content::NotificationRegistrar registrar_; |
[email protected] | 99a1aef | 2011-03-29 17:17:23 | [diff] [blame] | 357 | 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] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 364 | // Observes when an extension has finished loading and is ready for use. Also |
| 365 | // checks for possible install errors. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 366 | class ExtensionReadyNotificationObserver |
| 367 | : public content::NotificationObserver { |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 368 | public: |
[email protected] | 1d4bae6 | 2011-11-29 13:27:30 | [diff] [blame] | 369 | // 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] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 374 | virtual ~ExtensionReadyNotificationObserver(); |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 375 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 376 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 377 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 378 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 379 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 380 | |
| 381 | private: |
[email protected] | 1d4bae6 | 2011-11-29 13:27:30 | [diff] [blame] | 382 | void Init(); |
| 383 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 384 | content::NotificationRegistrar registrar_; |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 385 | ExtensionProcessManager* manager_; |
[email protected] | 0e0bbb1 | 2011-08-23 18:42:17 | [diff] [blame] | 386 | ExtensionService* service_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 387 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 388 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 389 | const extensions::Extension* extension_; |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 390 | |
| 391 | DISALLOW_COPY_AND_ASSIGN(ExtensionReadyNotificationObserver); |
| 392 | }; |
| 393 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 394 | class ExtensionUnloadNotificationObserver |
| 395 | : public content::NotificationObserver { |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 396 | public: |
| 397 | ExtensionUnloadNotificationObserver(); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 398 | virtual ~ExtensionUnloadNotificationObserver(); |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 399 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 400 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 401 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 402 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 403 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 404 | |
| 405 | bool did_receive_unload_notification() { |
| 406 | return did_receive_unload_notification_; |
| 407 | } |
| 408 | |
| 409 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 410 | content::NotificationRegistrar registrar_; |
[email protected] | 790788ac | 2010-04-06 17:52:19 | [diff] [blame] | 411 | bool did_receive_unload_notification_; |
| 412 | |
| 413 | DISALLOW_COPY_AND_ASSIGN(ExtensionUnloadNotificationObserver); |
| 414 | }; |
| 415 | |
[email protected] | 2bb2ee8 | 2012-11-13 23:24:03 | [diff] [blame] | 416 | // 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] | 6a0322f | 2011-04-11 19:45:48 | [diff] [blame] | 419 | // observer waits until all updated extensions have actually been loaded. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 420 | class ExtensionsUpdatedObserver : public content::NotificationObserver { |
[email protected] | 6a0322f | 2011-04-11 19:45:48 | [diff] [blame] | 421 | public: |
| 422 | ExtensionsUpdatedObserver(ExtensionProcessManager* manager, |
| 423 | AutomationProvider* automation, |
| 424 | IPC::Message* reply_message); |
| 425 | virtual ~ExtensionsUpdatedObserver(); |
| 426 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 427 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 428 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 429 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 430 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 6a0322f | 2011-04-11 19:45:48 | [diff] [blame] | 431 | |
[email protected] | 2bb2ee8 | 2012-11-13 23:24:03 | [diff] [blame] | 432 | // Called by ExtensionUpdater when it has finished updating extensions. |
| 433 | void UpdateCheckFinished(); |
| 434 | |
[email protected] | 6a0322f | 2011-04-11 19:45:48 | [diff] [blame] | 435 | private: |
[email protected] | 2bb2ee8 | 2012-11-13 23:24:03 | [diff] [blame] | 436 | void MaybeReply(); |
| 437 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 438 | content::NotificationRegistrar registrar_; |
[email protected] | 6a0322f | 2011-04-11 19:45:48 | [diff] [blame] | 439 | ExtensionProcessManager* manager_; |
| 440 | base::WeakPtr<AutomationProvider> automation_; |
| 441 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 6a0322f | 2011-04-11 19:45:48 | [diff] [blame] | 442 | bool updater_finished_; |
| 443 | |
| 444 | DISALLOW_COPY_AND_ASSIGN(ExtensionsUpdatedObserver); |
| 445 | }; |
| 446 | |
[email protected] | 300e4c9 | 2011-04-14 19:16:47 | [diff] [blame] | 447 | // Observes when a new browser has been opened and a tab within it has stopped |
| 448 | // loading. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 449 | class BrowserOpenedNotificationObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 450 | public: |
| 451 | BrowserOpenedNotificationObserver(AutomationProvider* automation, |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 452 | IPC::Message* reply_message, |
| 453 | bool use_json_interface); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 454 | virtual ~BrowserOpenedNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 455 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 456 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 457 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 458 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 459 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 460 | |
| 461 | void set_for_browser_command(bool for_browser_command); |
| 462 | |
| 463 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 464 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 465 | base::WeakPtr<AutomationProvider> automation_; |
| 466 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 300e4c9 | 2011-04-14 19:16:47 | [diff] [blame] | 467 | int new_window_id_; |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 468 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 469 | bool for_browser_command_; |
| 470 | |
| 471 | DISALLOW_COPY_AND_ASSIGN(BrowserOpenedNotificationObserver); |
| 472 | }; |
| 473 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 474 | class BrowserClosedNotificationObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 475 | public: |
| 476 | BrowserClosedNotificationObserver(Browser* browser, |
| 477 | AutomationProvider* automation, |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 478 | IPC::Message* reply_message, |
| 479 | bool use_json_interface); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 480 | virtual ~BrowserClosedNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 481 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 482 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 483 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 484 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 485 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 486 | |
| 487 | void set_for_browser_command(bool for_browser_command); |
| 488 | |
| 489 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 490 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 491 | base::WeakPtr<AutomationProvider> automation_; |
| 492 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 493 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 494 | bool for_browser_command_; |
| 495 | |
| 496 | DISALLOW_COPY_AND_ASSIGN(BrowserClosedNotificationObserver); |
| 497 | }; |
| 498 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 499 | class BrowserCountChangeNotificationObserver |
| 500 | : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 501 | public: |
| 502 | BrowserCountChangeNotificationObserver(int target_count, |
| 503 | AutomationProvider* automation, |
| 504 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 505 | virtual ~BrowserCountChangeNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 506 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 507 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 508 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 509 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 510 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 511 | |
| 512 | private: |
| 513 | int target_count_; |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 514 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 515 | base::WeakPtr<AutomationProvider> automation_; |
| 516 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 517 | |
| 518 | DISALLOW_COPY_AND_ASSIGN(BrowserCountChangeNotificationObserver); |
| 519 | }; |
| 520 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 521 | class ExecuteBrowserCommandObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 522 | public: |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 523 | virtual ~ExecuteBrowserCommandObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 524 | |
| 525 | static bool CreateAndRegisterObserver(AutomationProvider* automation, |
| 526 | Browser* browser, |
| 527 | int command, |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 528 | IPC::Message* reply_message, |
| 529 | bool use_json_interface); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 530 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 531 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 532 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 533 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 534 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 535 | |
| 536 | private: |
| 537 | ExecuteBrowserCommandObserver(AutomationProvider* automation, |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 538 | IPC::Message* reply_message, |
| 539 | bool use_json_interface); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 540 | |
| 541 | bool Register(int command); |
| 542 | |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 543 | bool Getint(int command, int* type); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 544 | |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 545 | IPC::Message* ReleaseReply(); |
| 546 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 547 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 548 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 549 | int notification_type_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 550 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 551 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 552 | |
| 553 | DISALLOW_COPY_AND_ASSIGN(ExecuteBrowserCommandObserver); |
| 554 | }; |
| 555 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 556 | class FindInPageNotificationObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 557 | public: |
| 558 | FindInPageNotificationObserver(AutomationProvider* automation, |
[email protected] | fbc5e5f9 | 2012-01-02 06:08:32 | [diff] [blame] | 559 | content::WebContents* parent_tab, |
[email protected] | f9e3c52 | 2010-10-08 00:41:26 | [diff] [blame] | 560 | bool reply_with_json, |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 561 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 562 | virtual ~FindInPageNotificationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 563 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 564 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 565 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 566 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 567 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 568 | |
| 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] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 579 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 580 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 581 | // 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] | f9e3c52 | 2010-10-08 00:41:26 | [diff] [blame] | 584 | // Send reply using json automation interface. |
| 585 | bool reply_with_json_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 586 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 587 | |
| 588 | DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver); |
| 589 | }; |
| 590 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 591 | class DomOperationObserver : public content::NotificationObserver { |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 592 | public: |
[email protected] | 4a64ea8 | 2012-04-17 01:22:46 | [diff] [blame] | 593 | explicit DomOperationObserver(int automation_id); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 594 | virtual ~DomOperationObserver(); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 595 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 596 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 597 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 598 | const content::NotificationSource& source, |
| 599 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 600 | |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 601 | virtual void OnDomOperationCompleted(const std::string& json) = 0; |
[email protected] | 2b49673 | 2011-07-25 22:42:02 | [diff] [blame] | 602 | virtual void OnModalDialogShown() = 0; |
[email protected] | df96884 | 2011-11-04 16:00:53 | [diff] [blame] | 603 | virtual void OnJavascriptBlocked() = 0; |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 604 | |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 605 | private: |
[email protected] | 4a64ea8 | 2012-04-17 01:22:46 | [diff] [blame] | 606 | int automation_id_; |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 607 | content::NotificationRegistrar registrar_; |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 608 | |
| 609 | DISALLOW_COPY_AND_ASSIGN(DomOperationObserver); |
| 610 | }; |
| 611 | |
[email protected] | 3fdb891b | 2011-03-10 18:01:00 | [diff] [blame] | 612 | // Sends a message back to the automation client with the results of the DOM |
| 613 | // operation. |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 614 | class DomOperationMessageSender : public DomOperationObserver { |
| 615 | public: |
[email protected] | e7e3803 | 2011-07-26 17:25:25 | [diff] [blame] | 616 | DomOperationMessageSender(AutomationProvider* automation, |
[email protected] | 4a64ea8 | 2012-04-17 01:22:46 | [diff] [blame] | 617 | IPC::Message* reply_message, |
[email protected] | e7e3803 | 2011-07-26 17:25:25 | [diff] [blame] | 618 | bool use_json_interface); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 619 | virtual ~DomOperationMessageSender(); |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 620 | |
[email protected] | 2b49673 | 2011-07-25 22:42:02 | [diff] [blame] | 621 | virtual void OnDomOperationCompleted(const std::string& json) OVERRIDE; |
| 622 | virtual void OnModalDialogShown() OVERRIDE; |
[email protected] | df96884 | 2011-11-04 16:00:53 | [diff] [blame] | 623 | virtual void OnJavascriptBlocked() OVERRIDE; |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 624 | |
| 625 | private: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 626 | base::WeakPtr<AutomationProvider> automation_; |
[email protected] | 3fdb891b | 2011-03-10 18:01:00 | [diff] [blame] | 627 | scoped_ptr<IPC::Message> reply_message_; |
| 628 | bool use_json_interface_; |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 629 | |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 630 | DISALLOW_COPY_AND_ASSIGN(DomOperationMessageSender); |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 631 | }; |
| 632 | |
[email protected] | 84abba6 | 2009-10-07 17:01:44 | [diff] [blame] | 633 | // Collects METRIC_EVENT_DURATION notifications and keep track of the times. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 634 | class MetricEventDurationObserver : public content::NotificationObserver { |
[email protected] | 84abba6 | 2009-10-07 17:01:44 | [diff] [blame] | 635 | public: |
| 636 | MetricEventDurationObserver(); |
[email protected] | 8e38341 | 2010-10-19 16:57:03 | [diff] [blame] | 637 | virtual ~MetricEventDurationObserver(); |
[email protected] | 84abba6 | 2009-10-07 17:01:44 | [diff] [blame] | 638 | |
| 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 642 | // Overridden from content::NotificationObserver: |
| 643 | virtual void Observe(int type, |
| 644 | const content::NotificationSource& source, |
| 645 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 84abba6 | 2009-10-07 17:01:44 | [diff] [blame] | 646 | |
| 647 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 648 | content::NotificationRegistrar registrar_; |
[email protected] | 84abba6 | 2009-10-07 17:01:44 | [diff] [blame] | 649 | |
| 650 | typedef std::map<std::string, int> EventDurationMap; |
| 651 | EventDurationMap durations_; |
| 652 | |
| 653 | DISALLOW_COPY_AND_ASSIGN(MetricEventDurationObserver); |
| 654 | }; |
| 655 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 656 | class InfoBarCountObserver : public content::NotificationObserver { |
[email protected] | e04c7eaca | 2010-09-08 22:04:40 | [diff] [blame] | 657 | public: |
| 658 | InfoBarCountObserver(AutomationProvider* automation, |
| 659 | IPC::Message* reply_message, |
[email protected] | aa19063 | 2012-12-04 07:39:53 | [diff] [blame] | 660 | content::WebContents* web_contents, |
[email protected] | ec8f5116 | 2011-02-08 04:20:40 | [diff] [blame] | 661 | size_t target_count); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 662 | virtual ~InfoBarCountObserver(); |
[email protected] | e04c7eaca | 2010-09-08 22:04:40 | [diff] [blame] | 663 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 664 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 665 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 666 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 667 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | e04c7eaca | 2010-09-08 22:04:40 | [diff] [blame] | 668 | |
| 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] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 674 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 675 | base::WeakPtr<AutomationProvider> automation_; |
| 676 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | aa19063 | 2012-12-04 07:39:53 | [diff] [blame] | 677 | content::WebContents* web_contents_; |
[email protected] | e04c7eaca | 2010-09-08 22:04:40 | [diff] [blame] | 678 | |
[email protected] | ec8f5116 | 2011-02-08 04:20:40 | [diff] [blame] | 679 | const size_t target_count_; |
[email protected] | e04c7eaca | 2010-09-08 22:04:40 | [diff] [blame] | 680 | |
| 681 | DISALLOW_COPY_AND_ASSIGN(InfoBarCountObserver); |
| 682 | }; |
| 683 | |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 684 | #if defined(OS_CHROMEOS) |
[email protected] | b1bb86d | 2011-09-02 18:20:51 | [diff] [blame] | 685 | class LoginObserver : public chromeos::LoginStatusConsumer { |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 686 | public: |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 687 | LoginObserver(chromeos::ExistingUserController* controller, |
| 688 | AutomationProvider* automation, |
| 689 | IPC::Message* reply_message); |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 690 | |
[email protected] | b9f0a340 | 2011-05-25 13:41:33 | [diff] [blame] | 691 | virtual ~LoginObserver(); |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 692 | |
[email protected] | e755d9f | 2011-05-15 20:03:47 | [diff] [blame] | 693 | virtual void OnLoginFailure(const chromeos::LoginFailure& error); |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 694 | |
[email protected] | e755d9f | 2011-05-15 20:03:47 | [diff] [blame] | 695 | virtual void OnLoginSuccess( |
[email protected] | 4042959 | 2013-03-29 17:52:33 | [diff] [blame] | 696 | const chromeos::UserContext& user_context, |
[email protected] | cc8f247 | 2011-08-01 07:14:46 | [diff] [blame] | 697 | bool pending_requests, |
| 698 | bool using_oauth); |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 699 | |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 700 | private: |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 701 | chromeos::ExistingUserController* controller_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 702 | base::WeakPtr<AutomationProvider> automation_; |
| 703 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 704 | |
[email protected] | 3b10fdeb | 2011-05-06 00:17:25 | [diff] [blame] | 705 | DISALLOW_COPY_AND_ASSIGN(LoginObserver); |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 706 | }; |
[email protected] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 707 | |
[email protected] | 64b1b48ef | 2012-06-04 13:43:54 | [diff] [blame] | 708 | // Waits for a screen change notification from WizardController. |
| 709 | class 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] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 745 | // Collects SCREEN_LOCK_STATE_CHANGED notifications and returns |
| 746 | // whether authentication succeeded to the automation provider. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 747 | class ScreenLockUnlockObserver : public content::NotificationObserver { |
[email protected] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 748 | 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] | d958c2bc | 2011-03-11 20:08:26 | [diff] [blame] | 754 | virtual ~ScreenLockUnlockObserver(); |
[email protected] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 755 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 756 | // Overridden from content::NotificationObserver: |
| 757 | virtual void Observe(int type, |
| 758 | const content::NotificationSource& source, |
| 759 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 760 | |
[email protected] | 29d3501 | 2011-05-31 19:27:29 | [diff] [blame] | 761 | protected: |
| 762 | base::WeakPtr<AutomationProvider> automation_; |
| 763 | scoped_ptr<IPC::Message> reply_message_; |
| 764 | |
[email protected] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 765 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 766 | content::NotificationRegistrar registrar_; |
[email protected] | cfc34b79c | 2011-02-05 00:00:21 | [diff] [blame] | 767 | bool lock_screen_; |
| 768 | |
| 769 | DISALLOW_COPY_AND_ASSIGN(ScreenLockUnlockObserver); |
| 770 | }; |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 771 | |
[email protected] | 29d3501 | 2011-05-31 19:27:29 | [diff] [blame] | 772 | // 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. |
| 775 | class 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] | 4042959 | 2013-03-29 17:52:33 | [diff] [blame] | 785 | const chromeos::UserContext& user_context, |
[email protected] | cc8f247 | 2011-08-01 07:14:46 | [diff] [blame] | 786 | bool pending_requests, |
| 787 | bool using_oauth) {} |
[email protected] | 29d3501 | 2011-05-31 19:27:29 | [diff] [blame] | 788 | |
| 789 | private: |
| 790 | DISALLOW_COPY_AND_ASSIGN(ScreenUnlockObserver); |
| 791 | }; |
| 792 | |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 793 | class 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] | f717d1c | 2011-06-20 18:44:11 | [diff] [blame] | 805 | base::WeakPtr<AutomationProvider> automation_; |
| 806 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 807 | |
| 808 | DISALLOW_COPY_AND_ASSIGN(NetworkScanObserver); |
| 809 | }; |
| 810 | |
[email protected] | 5d4a99d | 2011-08-02 02:19:05 | [diff] [blame] | 811 | class 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] | 52a90fd0 | 2011-10-12 03:05:08 | [diff] [blame] | 833 | class 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] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 854 | // Waits for a connection success or failure for the specified |
| 855 | // network and returns the status to the automation provider. |
[email protected] | 52a90fd0 | 2011-10-12 03:05:08 | [diff] [blame] | 856 | class NetworkConnectObserver : public NetworkStatusObserver { |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 857 | public: |
| 858 | NetworkConnectObserver(AutomationProvider* automation, |
[email protected] | 7ae8d0f | 2011-04-12 02:47:35 | [diff] [blame] | 859 | IPC::Message* reply_message); |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 860 | |
[email protected] | 52a90fd0 | 2011-10-12 03:05:08 | [diff] [blame] | 861 | virtual void NetworkStatusCheck(const chromeos::Network* network); |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 862 | |
| 863 | private: |
[email protected] | 8989bb4 | 2011-03-26 00:33:21 | [diff] [blame] | 864 | DISALLOW_COPY_AND_ASSIGN(NetworkConnectObserver); |
| 865 | }; |
[email protected] | 7ae8d0f | 2011-04-12 02:47:35 | [diff] [blame] | 866 | |
[email protected] | 52a90fd0 | 2011-10-12 03:05:08 | [diff] [blame] | 867 | // Waits until a network has disconnected. Then returns success |
| 868 | // or failure. |
| 869 | class 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] | 7ae8d0f | 2011-04-12 02:47:35 | [diff] [blame] | 884 | // Waits for a connection success or failure for the specified |
| 885 | // network and returns the status to the automation provider. |
| 886 | class ServicePathConnectObserver : public NetworkConnectObserver { |
| 887 | public: |
| 888 | ServicePathConnectObserver(AutomationProvider* automation, |
| 889 | IPC::Message* reply_message, |
| 890 | const std::string& service_path); |
| 891 | |
[email protected] | 52a90fd0 | 2011-10-12 03:05:08 | [diff] [blame] | 892 | const chromeos::Network* GetNetwork( |
[email protected] | 7ae8d0f | 2011-04-12 02:47:35 | [diff] [blame] | 893 | chromeos::NetworkLibrary* network_library); |
| 894 | |
| 895 | private: |
| 896 | std::string service_path_; |
[email protected] | 7ae8d0f | 2011-04-12 02:47:35 | [diff] [blame] | 897 | DISALLOW_COPY_AND_ASSIGN(ServicePathConnectObserver); |
| 898 | }; |
| 899 | |
| 900 | // Waits for a connection success or failure for the specified |
[email protected] | 52a90fd0 | 2011-10-12 03:05:08 | [diff] [blame] | 901 | // network and returns the status to the automation provider. |
| 902 | class 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] | f717d1c | 2011-06-20 18:44:11 | [diff] [blame] | 917 | // virtual network and returns the status to the automation provider. |
| 918 | class 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] | 6a33bb9 | 2011-07-28 02:41:19 | [diff] [blame] | 941 | // Waits for enterprise device enrollment to complete and returns the status to |
| 942 | // the automation provider. |
| 943 | class EnrollmentObserver |
[email protected] | 0254980 | 2013-04-22 18:25:51 | [diff] [blame] | 944 | : public chromeos::EnrollmentScreen::TestingObserver { |
[email protected] | 6a33bb9 | 2011-07-28 02:41:19 | [diff] [blame] | 945 | public: |
| 946 | EnrollmentObserver(AutomationProvider* automation, |
[email protected] | f24cab4 | 2012-11-01 14:41:16 | [diff] [blame] | 947 | IPC::Message* reply_message, |
[email protected] | 0254980 | 2013-04-22 18:25:51 | [diff] [blame] | 948 | chromeos::EnrollmentScreen* enrollment_screen); |
[email protected] | 6a33bb9 | 2011-07-28 02:41:19 | [diff] [blame] | 949 | |
| 950 | virtual ~EnrollmentObserver(); |
| 951 | |
[email protected] | 0254980 | 2013-04-22 18:25:51 | [diff] [blame] | 952 | // chromeos::EnrollmentScreen::Observer implementation. |
[email protected] | f24cab4 | 2012-11-01 14:41:16 | [diff] [blame] | 953 | virtual void OnEnrollmentComplete(bool succeeded); |
[email protected] | 6a33bb9 | 2011-07-28 02:41:19 | [diff] [blame] | 954 | |
| 955 | private: |
| 956 | base::WeakPtr<AutomationProvider> automation_; |
| 957 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 0254980 | 2013-04-22 18:25:51 | [diff] [blame] | 958 | chromeos::EnrollmentScreen* enrollment_screen_; |
[email protected] | 6a33bb9 | 2011-07-28 02:41:19 | [diff] [blame] | 959 | |
| 960 | DISALLOW_COPY_AND_ASSIGN(EnrollmentObserver); |
| 961 | }; |
| 962 | |
[email protected] | 60ae33e | 2011-03-10 00:44:34 | [diff] [blame] | 963 | #endif // defined(OS_CHROMEOS) |
[email protected] | 566a0f76 | 2010-03-10 04:14:57 | [diff] [blame] | 964 | |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 965 | // Waits for the bookmark model to load. |
[email protected] | c58c5ea | 2011-07-13 21:43:16 | [diff] [blame] | 966 | class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver { |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 967 | public: |
| 968 | AutomationProviderBookmarkModelObserver(AutomationProvider* provider, |
| 969 | IPC::Message* reply_message, |
[email protected] | 9329d68 | 2012-08-13 22:59:03 | [diff] [blame] | 970 | BookmarkModel* model, |
| 971 | bool use_json_interface); |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 972 | virtual ~AutomationProviderBookmarkModelObserver(); |
| 973 | |
[email protected] | f12de830 | 2011-05-23 16:12:30 | [diff] [blame] | 974 | // BookmarkModelObserver: |
[email protected] | c58c5ea | 2011-07-13 21:43:16 | [diff] [blame] | 975 | virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; |
[email protected] | f12de830 | 2011-05-23 16:12:30 | [diff] [blame] | 976 | virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 977 | virtual void BookmarkNodeMoved(BookmarkModel* model, |
| 978 | const BookmarkNode* old_parent, |
| 979 | int old_index, |
| 980 | const BookmarkNode* new_parent, |
[email protected] | f12de830 | 2011-05-23 16:12:30 | [diff] [blame] | 981 | int new_index) OVERRIDE {} |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 982 | virtual void BookmarkNodeAdded(BookmarkModel* model, |
| 983 | const BookmarkNode* parent, |
[email protected] | f12de830 | 2011-05-23 16:12:30 | [diff] [blame] | 984 | int index) OVERRIDE {} |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 985 | virtual void BookmarkNodeRemoved(BookmarkModel* model, |
| 986 | const BookmarkNode* parent, |
| 987 | int old_index, |
[email protected] | f12de830 | 2011-05-23 16:12:30 | [diff] [blame] | 988 | const BookmarkNode* node) OVERRIDE {} |
[email protected] | 323dbf7 | 2013-03-30 17:08:33 | [diff] [blame] | 989 | virtual void BookmarkAllNodesRemoved(BookmarkModel* model) OVERRIDE {} |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 990 | virtual void BookmarkNodeChanged(BookmarkModel* model, |
[email protected] | f12de830 | 2011-05-23 16:12:30 | [diff] [blame] | 991 | 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] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 997 | |
[email protected] | 9329d68 | 2012-08-13 22:59:03 | [diff] [blame] | 998 | IPC::Message* ReleaseReply(); |
| 999 | |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 1000 | 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] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1006 | base::WeakPtr<AutomationProvider> automation_provider_; |
| 1007 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 1008 | BookmarkModel* model_; |
[email protected] | 9329d68 | 2012-08-13 22:59:03 | [diff] [blame] | 1009 | bool use_json_interface_; |
[email protected] | 6d8ffc9f | 2010-03-12 18:27:53 | [diff] [blame] | 1010 | |
| 1011 | DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver); |
| 1012 | }; |
| 1013 | |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1014 | // Allows the automation provider to wait until the download has been updated |
| 1015 | // or opened. |
| 1016 | class AutomationProviderDownloadUpdatedObserver |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1017 | : public content::DownloadItem::Observer { |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1018 | public: |
| 1019 | AutomationProviderDownloadUpdatedObserver( |
| 1020 | AutomationProvider* provider, |
| 1021 | IPC::Message* reply_message, |
[email protected] | 66521d0 | 2012-08-14 17:51:54 | [diff] [blame] | 1022 | bool wait_for_open, |
| 1023 | bool incognito); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1024 | virtual ~AutomationProviderDownloadUpdatedObserver(); |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1025 | |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1026 | virtual void OnDownloadUpdated(content::DownloadItem* download); |
| 1027 | virtual void OnDownloadOpened(content::DownloadItem* download); |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1028 | |
| 1029 | private: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1030 | base::WeakPtr<AutomationProvider> provider_; |
| 1031 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1032 | bool wait_for_open_; |
[email protected] | 66521d0 | 2012-08-14 17:51:54 | [diff] [blame] | 1033 | bool incognito_; |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1034 | |
| 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). |
| 1040 | class AutomationProviderDownloadModelChangedObserver |
[email protected] | 73c4348 | 2012-11-07 16:53:19 | [diff] [blame] | 1041 | : public AllDownloadItemNotifier::Observer { |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1042 | public: |
| 1043 | AutomationProviderDownloadModelChangedObserver( |
| 1044 | AutomationProvider* provider, |
| 1045 | IPC::Message* reply_message, |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1046 | content::DownloadManager* download_manager); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1047 | virtual ~AutomationProviderDownloadModelChangedObserver(); |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1048 | |
[email protected] | 73c4348 | 2012-11-07 16:53:19 | [diff] [blame] | 1049 | 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] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1053 | |
| 1054 | private: |
[email protected] | 73c4348 | 2012-11-07 16:53:19 | [diff] [blame] | 1055 | void ModelChanged(); |
| 1056 | |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1057 | base::WeakPtr<AutomationProvider> provider_; |
| 1058 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 73c4348 | 2012-11-07 16:53:19 | [diff] [blame] | 1059 | AllDownloadItemNotifier notifier_; |
[email protected] | 2d54c403 | 2010-08-20 00:42:28 | [diff] [blame] | 1060 | |
| 1061 | DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver); |
| 1062 | }; |
| 1063 | |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1064 | // Observes when all pending downloads have completed. |
| 1065 | class AllDownloadsCompleteObserver |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1066 | : public content::DownloadManager::Observer, |
| 1067 | public content::DownloadItem::Observer { |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1068 | public: |
| 1069 | AllDownloadsCompleteObserver( |
| 1070 | AutomationProvider* provider, |
| 1071 | IPC::Message* reply_message, |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1072 | content::DownloadManager* download_manager, |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1073 | ListValue* pre_download_ids); |
| 1074 | virtual ~AllDownloadsCompleteObserver(); |
| 1075 | |
[email protected] | 75e51b5 | 2012-02-04 16:57:54 | [diff] [blame] | 1076 | // content::DownloadManager::Observer. |
[email protected] | 9f1f409 | 2012-09-10 21:18:04 | [diff] [blame] | 1077 | virtual void OnDownloadCreated( |
| 1078 | content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE; |
[email protected] | 8fe3ae4 | 2012-09-13 21:50:31 | [diff] [blame] | 1079 | virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE; |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1080 | |
[email protected] | 75e51b5 | 2012-02-04 16:57:54 | [diff] [blame] | 1081 | // content::DownloadItem::Observer. |
| 1082 | virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1083 | |
| 1084 | private: |
| 1085 | void ReplyIfNecessary(); |
| 1086 | |
| 1087 | base::WeakPtr<AutomationProvider> provider_; |
| 1088 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1089 | content::DownloadManager* download_manager_; |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1090 | std::set<int> pre_download_ids_; |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1091 | std::set<content::DownloadItem*> pending_downloads_; |
[email protected] | e4af4eba | 2011-08-10 16:52:36 | [diff] [blame] | 1092 | |
| 1093 | DISALLOW_COPY_AND_ASSIGN(AllDownloadsCompleteObserver); |
| 1094 | }; |
| 1095 | |
[email protected] | 8e5c89a | 2011-06-07 18:13:33 | [diff] [blame] | 1096 | // Allows automation provider to wait until TemplateURLService has loaded |
[email protected] | 61023d00 | 2010-09-17 21:03:07 | [diff] [blame] | 1097 | // before looking up/returning search engine info. |
| 1098 | class AutomationProviderSearchEngineObserver |
[email protected] | 8e5c89a | 2011-06-07 18:13:33 | [diff] [blame] | 1099 | : public TemplateURLServiceObserver { |
[email protected] | 61023d00 | 2010-09-17 21:03:07 | [diff] [blame] | 1100 | public: |
| 1101 | AutomationProviderSearchEngineObserver( |
[email protected] | 88efa01 | 2010-10-12 04:47:44 | [diff] [blame] | 1102 | AutomationProvider* provider, |
[email protected] | 6c1e3ec | 2012-04-27 01:26:46 | [diff] [blame] | 1103 | Profile* profile, |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1104 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1105 | virtual ~AutomationProviderSearchEngineObserver(); |
[email protected] | 61023d00 | 2010-09-17 21:03:07 | [diff] [blame] | 1106 | |
[email protected] | 8e5c89a | 2011-06-07 18:13:33 | [diff] [blame] | 1107 | virtual void OnTemplateURLServiceChanged(); |
[email protected] | 61023d00 | 2010-09-17 21:03:07 | [diff] [blame] | 1108 | |
| 1109 | private: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1110 | base::WeakPtr<AutomationProvider> provider_; |
[email protected] | 6c1e3ec | 2012-04-27 01:26:46 | [diff] [blame] | 1111 | Profile* profile_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1112 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 61023d00 | 2010-09-17 21:03:07 | [diff] [blame] | 1113 | |
| 1114 | DISALLOW_COPY_AND_ASSIGN(AutomationProviderSearchEngineObserver); |
| 1115 | }; |
| 1116 | |
[email protected] | e6e376e | 2010-04-19 21:41:36 | [diff] [blame] | 1117 | // Allows the automation provider to wait for history queries to finish. |
| 1118 | class AutomationProviderHistoryObserver { |
| 1119 | public: |
| 1120 | AutomationProviderHistoryObserver( |
| 1121 | AutomationProvider* provider, |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1122 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1123 | virtual ~AutomationProviderHistoryObserver(); |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1124 | |
[email protected] | e6e376e | 2010-04-19 21:41:36 | [diff] [blame] | 1125 | void HistoryQueryComplete(HistoryService::Handle request_handle, |
| 1126 | history::QueryResults* results); |
| 1127 | |
| 1128 | private: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1129 | base::WeakPtr<AutomationProvider> provider_; |
| 1130 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | e6e376e | 2010-04-19 21:41:36 | [diff] [blame] | 1131 | }; |
| 1132 | |
[email protected] | c5aa532 | 2010-07-15 19:00:07 | [diff] [blame] | 1133 | // Allows the automation provider to wait for import queries to finish. |
[email protected] | 6c69796d | 2010-07-16 21:41:16 | [diff] [blame] | 1134 | class AutomationProviderImportSettingsObserver |
[email protected] | ea52f51 | 2011-03-08 19:55:51 | [diff] [blame] | 1135 | : public importer::ImporterProgressObserver { |
[email protected] | c5aa532 | 2010-07-15 19:00:07 | [diff] [blame] | 1136 | public: |
| 1137 | AutomationProviderImportSettingsObserver( |
| 1138 | AutomationProvider* provider, |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1139 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1140 | virtual ~AutomationProviderImportSettingsObserver(); |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1141 | |
[email protected] | ea52f51 | 2011-03-08 19:55:51 | [diff] [blame] | 1142 | // 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] | c5aa532 | 2010-07-15 19:00:07 | [diff] [blame] | 1148 | private: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1149 | base::WeakPtr<AutomationProvider> provider_; |
| 1150 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | c5aa532 | 2010-07-15 19:00:07 | [diff] [blame] | 1151 | }; |
| 1152 | |
[email protected] | 5bcfe167 | 2010-07-16 20:51:57 | [diff] [blame] | 1153 | // Allows automation provider to wait for getting passwords to finish. |
[email protected] | e5721c18 | 2011-03-28 22:27:34 | [diff] [blame] | 1154 | class AutomationProviderGetPasswordsObserver : public PasswordStoreConsumer { |
[email protected] | 5bcfe167 | 2010-07-16 20:51:57 | [diff] [blame] | 1155 | public: |
| 1156 | AutomationProviderGetPasswordsObserver( |
| 1157 | AutomationProvider* provider, |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1158 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1159 | virtual ~AutomationProviderGetPasswordsObserver(); |
[email protected] | 5bcfe167 | 2010-07-16 20:51:57 | [diff] [blame] | 1160 | |
[email protected] | cef1a75 | 2012-12-14 04:01:56 | [diff] [blame] | 1161 | // PasswordStoreConsumer implementation. |
[email protected] | 78994ab0 | 2010-12-08 18:06:44 | [diff] [blame] | 1162 | virtual void OnPasswordStoreRequestDone( |
[email protected] | e5721c18 | 2011-03-28 22:27:34 | [diff] [blame] | 1163 | CancelableRequestProvider::Handle handle, |
[email protected] | 1ecbe86 | 2012-10-05 01:29:14 | [diff] [blame] | 1164 | const std::vector<content::PasswordForm*>& result) OVERRIDE; |
[email protected] | cef1a75 | 2012-12-14 04:01:56 | [diff] [blame] | 1165 | virtual void OnGetPasswordStoreResults( |
| 1166 | const std::vector<content::PasswordForm*>& results) OVERRIDE; |
[email protected] | 5bcfe167 | 2010-07-16 20:51:57 | [diff] [blame] | 1167 | |
| 1168 | private: |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1169 | base::WeakPtr<AutomationProvider> provider_; |
| 1170 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 5bcfe167 | 2010-07-16 20:51:57 | [diff] [blame] | 1171 | }; |
| 1172 | |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1173 | // Observes when login entries stored in the password store are changed. The |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1174 | // notifications are sent on the DB thread, the thread that interacts with the |
| 1175 | // web database. |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1176 | class PasswordStoreLoginsChangedObserver |
| 1177 | : public base::RefCountedThreadSafe< |
| 1178 | PasswordStoreLoginsChangedObserver, |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 1179 | content::BrowserThread::DeleteOnUIThread>, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1180 | public content::NotificationObserver { |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1181 | public: |
| 1182 | PasswordStoreLoginsChangedObserver(AutomationProvider* automation, |
| 1183 | IPC::Message* reply_message, |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1184 | PasswordStoreChange::Type expected_type, |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1185 | const std::string& result_key); |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1186 | |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1187 | // Schedules a task on the DB thread to register the appropriate observers. |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1188 | virtual void Init(); |
| 1189 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1190 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1191 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1192 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1193 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1194 | |
| 1195 | private: |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 1196 | friend struct content::BrowserThread::DeleteOnThread< |
| 1197 | content::BrowserThread::UI>; |
[email protected] | f2a6ec64 | 2012-05-09 05:16:29 | [diff] [blame] | 1198 | ~PasswordStoreLoginsChangedObserver(); |
[email protected] | cff06c57 | 2012-01-02 20:03:05 | [diff] [blame] | 1199 | friend class base::DeleteHelper<PasswordStoreLoginsChangedObserver>; |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1200 | |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1201 | // Registers the appropriate observers. Called on the DB thread. |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1202 | void RegisterObserversTask(); |
| 1203 | |
| 1204 | // Sends the |reply_message_| to |automation_| indicating we're done. Called |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1205 | // on the UI thread. |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1206 | void IndicateDone(); |
| 1207 | |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1208 | // Sends an error reply to |automation_|. Called on the UI thread. |
| 1209 | void IndicateError(const std::string& error); |
| 1210 | |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1211 | base::WeakPtr<AutomationProvider> automation_; |
| 1212 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | f2a6ec64 | 2012-05-09 05:16:29 | [diff] [blame] | 1213 | scoped_ptr<content::NotificationRegistrar> registrar_; |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1214 | PasswordStoreChange::Type expected_type_; |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1215 | std::string result_key_; |
| 1216 | |
[email protected] | 08a3b9bb | 2011-05-26 19:59:29 | [diff] [blame] | 1217 | // Used to ensure that the UI thread waits for the DB thread to finish |
| 1218 | // registering observers before proceeding. |
[email protected] | 64ad22e | 2011-05-20 21:59:29 | [diff] [blame] | 1219 | base::WaitableEvent done_event_; |
| 1220 | |
| 1221 | DISALLOW_COPY_AND_ASSIGN(PasswordStoreLoginsChangedObserver); |
| 1222 | }; |
| 1223 | |
[email protected] | c165483 | 2010-05-17 23:22:12 | [diff] [blame] | 1224 | // Allows automation provider to wait until page load after selecting an item |
| 1225 | // in the omnibox popup. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1226 | class OmniboxAcceptNotificationObserver : public content::NotificationObserver { |
[email protected] | c165483 | 2010-05-17 23:22:12 | [diff] [blame] | 1227 | public: |
[email protected] | b7b6387 | 2013-01-03 02:41:19 | [diff] [blame] | 1228 | OmniboxAcceptNotificationObserver(content::NavigationController* controller, |
| 1229 | AutomationProvider* automation, |
| 1230 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1231 | virtual ~OmniboxAcceptNotificationObserver(); |
[email protected] | c165483 | 2010-05-17 23:22:12 | [diff] [blame] | 1232 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1233 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1234 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1235 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1236 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | c165483 | 2010-05-17 23:22:12 | [diff] [blame] | 1237 | |
| 1238 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1239 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1240 | base::WeakPtr<AutomationProvider> automation_; |
| 1241 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 1242 | content::NavigationController* controller_; |
[email protected] | c165483 | 2010-05-17 23:22:12 | [diff] [blame] | 1243 | |
| 1244 | DISALLOW_COPY_AND_ASSIGN(OmniboxAcceptNotificationObserver); |
| 1245 | }; |
| 1246 | |
[email protected] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 1247 | // Allows the automation provider to wait for a save package notification. |
[email protected] | df58aa8 | 2013-01-24 21:54:00 | [diff] [blame] | 1248 | class SavePackageNotificationObserver |
| 1249 | : public content::DownloadManager::Observer { |
[email protected] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 1250 | public: |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 1251 | SavePackageNotificationObserver(content::DownloadManager* download_manager, |
[email protected] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 1252 | AutomationProvider* automation, |
| 1253 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1254 | virtual ~SavePackageNotificationObserver(); |
[email protected] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 1255 | |
[email protected] | df58aa8 | 2013-01-24 21:54:00 | [diff] [blame] | 1256 | // 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] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 1260 | |
| 1261 | private: |
[email protected] | df58aa8 | 2013-01-24 21:54:00 | [diff] [blame] | 1262 | content::DownloadManager* download_manager_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1263 | base::WeakPtr<AutomationProvider> automation_; |
| 1264 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 7060bb29 | 2010-06-24 00:52:49 | [diff] [blame] | 1265 | |
| 1266 | DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver); |
| 1267 | }; |
| 1268 | |
[email protected] | fad8296 | 2011-10-28 21:09:06 | [diff] [blame] | 1269 | // This class manages taking a snapshot of a page. |
| 1270 | class PageSnapshotTaker : public TabEventObserver, |
| 1271 | public content::NotificationObserver { |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 1272 | public: |
| 1273 | PageSnapshotTaker(AutomationProvider* automation, |
| 1274 | IPC::Message* reply_message, |
[email protected] | aa19063 | 2012-12-04 07:39:53 | [diff] [blame] | 1275 | content::WebContents* web_contents, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 1276 | const base::FilePath& path); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1277 | virtual ~PageSnapshotTaker(); |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 1278 | |
| 1279 | // Start the process of taking a snapshot of the entire page. |
| 1280 | void Start(); |
| 1281 | |
| 1282 | private: |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1283 | // Overridden from TabEventObserver: |
[email protected] | fad8296 | 2011-10-28 21:09:06 | [diff] [blame] | 1284 | virtual void OnSnapshotEntirePageACK( |
| 1285 | bool success, |
| 1286 | const std::vector<unsigned char>& png_data, |
| 1287 | const std::string& error_msg) OVERRIDE; |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1288 | |
| 1289 | // Overridden from content::NotificationObserver: |
[email protected] | fad8296 | 2011-10-28 21:09:06 | [diff] [blame] | 1290 | virtual void Observe(int type, |
| 1291 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1292 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 1293 | |
| 1294 | // Helper method to send a response back to the client. Deletes this. |
[email protected] | 2b49673 | 2011-07-25 22:42:02 | [diff] [blame] | 1295 | void SendMessage(bool success, const std::string& error_msg); |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 1296 | |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1297 | base::WeakPtr<AutomationProvider> automation_; |
| 1298 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | aa19063 | 2012-12-04 07:39:53 | [diff] [blame] | 1299 | content::WebContents* web_contents_; |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 1300 | base::FilePath image_path_; |
[email protected] | fad8296 | 2011-10-28 21:09:06 | [diff] [blame] | 1301 | content::NotificationRegistrar registrar_; |
[email protected] | 4203e6b | 2010-11-12 21:41:50 | [diff] [blame] | 1302 | |
| 1303 | DISALLOW_COPY_AND_ASSIGN(PageSnapshotTaker); |
| 1304 | }; |
| 1305 | |
[email protected] | 165901feb | 2012-05-23 15:38:22 | [diff] [blame] | 1306 | // Processes automation mouse events and invokes a callback when processing |
| 1307 | // has completed. |
| 1308 | class 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1332 | // Overriden from RenderViewHostObserver. |
[email protected] | 165901feb | 2012-05-23 15:38:22 | [diff] [blame] | 1333 | virtual void RenderViewHostDestroyed(content::RenderViewHost* host) OVERRIDE; |
| 1334 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 1335 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1336 | // Overridden from content::NotificationObserver: |
[email protected] | 165901feb | 2012-05-23 15:38:22 | [diff] [blame] | 1337 | 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] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1354 | class NTPInfoObserver : public content::NotificationObserver { |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 1355 | public: |
[email protected] | da927a1 | 2012-11-06 00:39:49 | [diff] [blame] | 1356 | NTPInfoObserver(AutomationProvider* automation, IPC::Message* reply_message); |
[email protected] | aa20e06 | 2010-12-07 23:07:27 | [diff] [blame] | 1357 | virtual ~NTPInfoObserver(); |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 1358 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1359 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1360 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1361 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1362 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 1363 | |
| 1364 | private: |
| 1365 | void OnTopSitesLoaded(); |
| 1366 | void OnTopSitesReceived(const history::MostVisitedURLList& visited_list); |
| 1367 | |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1368 | base::WeakPtr<AutomationProvider> automation_; |
| 1369 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 1370 | CancelableRequestProvider::Handle request_; |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 1371 | scoped_ptr<base::DictionaryValue> ntp_info_; |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 1372 | history::TopSites* top_sites_; |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1373 | content::NotificationRegistrar registrar_; |
[email protected] | 5783990a | 2010-11-19 00:24:48 | [diff] [blame] | 1374 | |
| 1375 | DISALLOW_COPY_AND_ASSIGN(NTPInfoObserver); |
| 1376 | }; |
| 1377 | |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 1378 | // Observes when an app has been launched, as indicated by a notification that |
| 1379 | // a content load in some tab has stopped. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1380 | class AppLaunchObserver : public content::NotificationObserver { |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 1381 | public: |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 1382 | AppLaunchObserver(content::NavigationController* controller, |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 1383 | AutomationProvider* automation, |
| 1384 | IPC::Message* reply_message, |
| 1385 | extension_misc::LaunchContainer launch_container); |
| 1386 | virtual ~AppLaunchObserver(); |
| 1387 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1388 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1389 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1390 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1391 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 1392 | |
| 1393 | private: |
[email protected] | cca0f1e | 2012-01-03 18:27:46 | [diff] [blame] | 1394 | content::NavigationController* controller_; |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 1395 | base::WeakPtr<AutomationProvider> automation_; |
| 1396 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1397 | content::NotificationRegistrar registrar_; |
[email protected] | cef7a5e | 2011-04-13 22:15:31 | [diff] [blame] | 1398 | extension_misc::LaunchContainer launch_container_; |
| 1399 | int new_window_id_; |
| 1400 | |
| 1401 | DISALLOW_COPY_AND_ASSIGN(AppLaunchObserver); |
| 1402 | }; |
| 1403 | |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1404 | // Allows the automation provider to wait until all the notification |
| 1405 | // processes are ready. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1406 | class GetAllNotificationsObserver : public content::NotificationObserver { |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1407 | public: |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1408 | GetAllNotificationsObserver(AutomationProvider* automation, |
| 1409 | IPC::Message* reply_message); |
| 1410 | virtual ~GetAllNotificationsObserver(); |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1411 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1412 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1413 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1414 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1415 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1416 | |
| 1417 | private: |
[email protected] | 4dc553ab | 2011-05-13 17:42:50 | [diff] [blame] | 1418 | // Sends a message via the |AutomationProvider|. |automation_| must be valid. |
| 1419 | // Deletes itself after the message is sent. |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1420 | void SendMessage(); |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1421 | // Returns a new dictionary describing the given notification. |
| 1422 | base::DictionaryValue* NotificationToJson(const Notification* note); |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1423 | |
[email protected] | 4321f5381 | 2011-10-19 02:59:40 | [diff] [blame] | 1424 | content::NotificationRegistrar registrar_; |
[email protected] | 4dc553ab | 2011-05-13 17:42:50 | [diff] [blame] | 1425 | base::WeakPtr<AutomationProvider> automation_; |
| 1426 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1427 | |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1428 | 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] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1433 | class NewNotificationBalloonObserver : public content::NotificationObserver { |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1434 | public: |
| 1435 | NewNotificationBalloonObserver(AutomationProvider* provider, |
| 1436 | IPC::Message* reply_message); |
| 1437 | virtual ~NewNotificationBalloonObserver(); |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1438 | |
| 1439 | // Overridden from content::NotificationObserver: |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1440 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1441 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1442 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1443 | |
| 1444 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1445 | content::NotificationRegistrar registrar_; |
[email protected] | 0fb286e | 2011-10-18 19:34:40 | [diff] [blame] | 1446 | base::WeakPtr<AutomationProvider> automation_; |
| 1447 | scoped_ptr<IPC::Message> reply_message_; |
| 1448 | |
| 1449 | DISALLOW_COPY_AND_ASSIGN(NewNotificationBalloonObserver); |
[email protected] | 17a00eb | 2010-12-15 18:14:50 | [diff] [blame] | 1450 | }; |
| 1451 | |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1452 | // Allows the automation provider to wait for a given number of |
| 1453 | // notification balloons. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1454 | class OnNotificationBalloonCountObserver |
| 1455 | : public content::NotificationObserver { |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1456 | public: |
| 1457 | OnNotificationBalloonCountObserver(AutomationProvider* provider, |
| 1458 | IPC::Message* reply_message, |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1459 | int count); |
[email protected] | f6e8e1e | 2011-05-13 18:05:31 | [diff] [blame] | 1460 | virtual ~OnNotificationBalloonCountObserver(); |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1461 | |
[email protected] | 4dc553ab | 2011-05-13 17:42:50 | [diff] [blame] | 1462 | // 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1467 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1468 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1469 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1470 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1471 | |
| 1472 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1473 | content::NotificationRegistrar registrar_; |
[email protected] | 4dc553ab | 2011-05-13 17:42:50 | [diff] [blame] | 1474 | base::WeakPtr<AutomationProvider> automation_; |
| 1475 | scoped_ptr<IPC::Message> reply_message_; |
| 1476 | |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1477 | BalloonCollection* collection_; |
| 1478 | int count_; |
| 1479 | |
| 1480 | DISALLOW_COPY_AND_ASSIGN(OnNotificationBalloonCountObserver); |
| 1481 | }; |
| 1482 | |
[email protected] | ddbe8669 | 2010-12-14 17:32:52 | [diff] [blame] | 1483 | // Allows the automation provider to wait for a RENDERER_PROCESS_CLOSED |
| 1484 | // notification. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1485 | class RendererProcessClosedObserver : public content::NotificationObserver { |
[email protected] | ddbe8669 | 2010-12-14 17:32:52 | [diff] [blame] | 1486 | public: |
| 1487 | RendererProcessClosedObserver(AutomationProvider* automation, |
| 1488 | IPC::Message* reply_message); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1489 | virtual ~RendererProcessClosedObserver(); |
[email protected] | ddbe8669 | 2010-12-14 17:32:52 | [diff] [blame] | 1490 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1491 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1492 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1493 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1494 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | ddbe8669 | 2010-12-14 17:32:52 | [diff] [blame] | 1495 | |
| 1496 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1497 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1498 | base::WeakPtr<AutomationProvider> automation_; |
| 1499 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | ddbe8669 | 2010-12-14 17:32:52 | [diff] [blame] | 1500 | |
| 1501 | DISALLOW_COPY_AND_ASSIGN(RendererProcessClosedObserver); |
| 1502 | }; |
| 1503 | |
[email protected] | a1b38b3c | 2011-04-27 15:49:16 | [diff] [blame] | 1504 | // 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] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1506 | class InputEventAckNotificationObserver : public content::NotificationObserver { |
[email protected] | 92e93756 | 2011-01-31 21:00:58 | [diff] [blame] | 1507 | public: |
| 1508 | InputEventAckNotificationObserver(AutomationProvider* automation, |
| 1509 | IPC::Message* reply_message, |
[email protected] | a1b38b3c | 2011-04-27 15:49:16 | [diff] [blame] | 1510 | int event_type, int count); |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1511 | virtual ~InputEventAckNotificationObserver(); |
[email protected] | 92e93756 | 2011-01-31 21:00:58 | [diff] [blame] | 1512 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1513 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1514 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1515 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1516 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 92e93756 | 2011-01-31 21:00:58 | [diff] [blame] | 1517 | |
| 1518 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1519 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1520 | base::WeakPtr<AutomationProvider> automation_; |
| 1521 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 92e93756 | 2011-01-31 21:00:58 | [diff] [blame] | 1522 | int event_type_; |
[email protected] | a1b38b3c | 2011-04-27 15:49:16 | [diff] [blame] | 1523 | int count_; |
[email protected] | 92e93756 | 2011-01-31 21:00:58 | [diff] [blame] | 1524 | |
| 1525 | DISALLOW_COPY_AND_ASSIGN(InputEventAckNotificationObserver); |
| 1526 | }; |
| 1527 | |
[email protected] | 4518a58 | 2011-12-06 02:34:24 | [diff] [blame] | 1528 | // 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. |
| 1532 | class AllViewsStoppedLoadingObserver : public TabEventObserver, |
| 1533 | public content::NotificationObserver { |
[email protected] | 781dbd7d | 2011-02-25 23:23:27 | [diff] [blame] | 1534 | public: |
[email protected] | 4518a58 | 2011-12-06 02:34:24 | [diff] [blame] | 1535 | AllViewsStoppedLoadingObserver( |
| 1536 | AutomationProvider* automation, |
| 1537 | IPC::Message* reply_message, |
| 1538 | ExtensionProcessManager* extension_process_manager); |
| 1539 | virtual ~AllViewsStoppedLoadingObserver(); |
[email protected] | 781dbd7d | 2011-02-25 23:23:27 | [diff] [blame] | 1540 | |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 1541 | // TabEventObserver implementation. |
[email protected] | 26b5e32 | 2011-12-23 01:36:47 | [diff] [blame] | 1542 | virtual void OnFirstPendingLoad(content::WebContents* web_contents) OVERRIDE; |
| 1543 | virtual void OnNoMorePendingLoads( |
| 1544 | content::WebContents* web_contents) OVERRIDE; |
[email protected] | 2b49673 | 2011-07-25 22:42:02 | [diff] [blame] | 1545 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1546 | // Overridden from content::NotificationObserver: |
[email protected] | 2b49673 | 2011-07-25 22:42:02 | [diff] [blame] | 1547 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1548 | const content::NotificationSource& source, |
| 1549 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 781dbd7d | 2011-02-25 23:23:27 | [diff] [blame] | 1550 | |
| 1551 | private: |
[email protected] | 26b5e32 | 2011-12-23 01:36:47 | [diff] [blame] | 1552 | typedef std::set<content::WebContents*> TabSet; |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 1553 | |
| 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] | 781dbd7d | 2011-02-25 23:23:27 | [diff] [blame] | 1558 | base::WeakPtr<AutomationProvider> automation_; |
| 1559 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 4518a58 | 2011-12-06 02:34:24 | [diff] [blame] | 1560 | ExtensionProcessManager* extension_process_manager_; |
| 1561 | content::NotificationRegistrar registrar_; |
| 1562 | TabSet pending_tabs_; |
[email protected] | 781dbd7d | 2011-02-25 23:23:27 | [diff] [blame] | 1563 | |
[email protected] | 4518a58 | 2011-12-06 02:34:24 | [diff] [blame] | 1564 | DISALLOW_COPY_AND_ASSIGN(AllViewsStoppedLoadingObserver); |
[email protected] | 781dbd7d | 2011-02-25 23:23:27 | [diff] [blame] | 1565 | }; |
| 1566 | |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1567 | // Observer used to listen for new tab creation to complete. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1568 | class NewTabObserver : public content::NotificationObserver { |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1569 | public: |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 1570 | NewTabObserver(AutomationProvider* automation, |
| 1571 | IPC::Message* reply_message, |
| 1572 | bool use_json_interface); |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1573 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1574 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1575 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1576 | const content::NotificationSource& source, |
| 1577 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1578 | |
| 1579 | private: |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1580 | virtual ~NewTabObserver(); |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1581 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1582 | content::NotificationRegistrar registrar_; |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1583 | base::WeakPtr<AutomationProvider> automation_; |
| 1584 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 16a517a | 2012-07-14 01:08:58 | [diff] [blame] | 1585 | bool use_json_interface_; |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1586 | |
| 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. |
| 1592 | class WaitForProcessLauncherThreadToGoIdleObserver |
| 1593 | : public base::RefCountedThreadSafe< |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1594 | WaitForProcessLauncherThreadToGoIdleObserver, |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 1595 | content::BrowserThread::DeleteOnUIThread> { |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1596 | public: |
| 1597 | WaitForProcessLauncherThreadToGoIdleObserver( |
| 1598 | AutomationProvider* automation, IPC::Message* reply_message); |
| 1599 | |
| 1600 | private: |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 1601 | friend struct content::BrowserThread::DeleteOnThread< |
| 1602 | content::BrowserThread::UI>; |
[email protected] | cff06c57 | 2012-01-02 20:03:05 | [diff] [blame] | 1603 | friend class base::DeleteHelper<WaitForProcessLauncherThreadToGoIdleObserver>; |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1604 | |
[email protected] | b6ce91b | 2011-02-10 21:30:50 | [diff] [blame] | 1605 | virtual ~WaitForProcessLauncherThreadToGoIdleObserver(); |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1606 | |
[email protected] | cdc5489 | 2011-03-04 22:33:09 | [diff] [blame] | 1607 | // 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] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1610 | void RunOnProcessLauncherThread(); |
[email protected] | cdc5489 | 2011-03-04 22:33:09 | [diff] [blame] | 1611 | |
| 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] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1618 | void RunOnUIThread(); |
| 1619 | |
[email protected] | 7d9aecf | 2011-02-09 11:58:03 | [diff] [blame] | 1620 | base::WeakPtr<AutomationProvider> automation_; |
| 1621 | scoped_ptr<IPC::Message> reply_message_; |
[email protected] | 4992231 | 2011-01-31 17:37:54 | [diff] [blame] | 1622 | |
| 1623 | DISALLOW_COPY_AND_ASSIGN(WaitForProcessLauncherThreadToGoIdleObserver); |
| 1624 | }; |
[email protected] | ac43f70 | 2010-10-26 20:18:45 | [diff] [blame] | 1625 | |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 1626 | // Allows the automation provider to wait for acknowledgement that a drop |
| 1627 | // operation has been processed by the renderer. |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1628 | class DragTargetDropAckNotificationObserver |
| 1629 | : public content::NotificationObserver { |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 1630 | public: |
| 1631 | DragTargetDropAckNotificationObserver(AutomationProvider* automation, |
| 1632 | IPC::Message* reply_message); |
| 1633 | virtual ~DragTargetDropAckNotificationObserver(); |
| 1634 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1635 | // Overridden from content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 1636 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1637 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1638 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 1639 | |
| 1640 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1641 | content::NotificationRegistrar registrar_; |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 1642 | base::WeakPtr<AutomationProvider> automation_; |
| 1643 | scoped_ptr<IPC::Message> reply_message_; |
| 1644 | |
| 1645 | DISALLOW_COPY_AND_ASSIGN(DragTargetDropAckNotificationObserver); |
| 1646 | }; |
| 1647 | |
[email protected] | b053975 | 2011-09-23 00:33:15 | [diff] [blame] | 1648 | // Allows the automation provider to wait for process memory details to be |
| 1649 | // available before sending this information to the client. |
| 1650 | class 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] | 5ed5b929 | 2011-09-23 11:09:17 | [diff] [blame] | 1658 | virtual ~ProcessInfoObserver(); |
[email protected] | b053975 | 2011-09-23 00:33:15 | [diff] [blame] | 1659 | base::WeakPtr<AutomationProvider> automation_; |
| 1660 | scoped_ptr<IPC::Message> reply_message_; |
| 1661 | |
| 1662 | DISALLOW_COPY_AND_ASSIGN(ProcessInfoObserver); |
| 1663 | }; |
| 1664 | |
[email protected] | 83c841a | 2012-02-08 19:18:26 | [diff] [blame] | 1665 | // Observes when new v8 heap statistics are computed for a renderer process. |
[email protected] | 1fdb89f | 2012-02-03 23:26:44 | [diff] [blame] | 1666 | class 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1673 | // Overridden from content::NotificationObserver: |
[email protected] | 1fdb89f | 2012-02-03 23:26:44 | [diff] [blame] | 1674 | virtual void Observe(int type, |
| 1675 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1676 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 1fdb89f | 2012-02-03 23:26:44 | [diff] [blame] | 1677 | |
| 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] | 83c841a | 2012-02-08 19:18:26 | [diff] [blame] | 1687 | // Observes when a new FPS value is computed for a renderer process. |
| 1688 | class 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1696 | // Overridden from content::NotificationObserver: |
[email protected] | 83c841a | 2012-02-08 19:18:26 | [diff] [blame] | 1697 | virtual void Observe(int type, |
| 1698 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1699 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 83c841a | 2012-02-08 19:18:26 | [diff] [blame] | 1700 | |
| 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] | 53d9e95 | 2011-09-23 09:44:11 | [diff] [blame] | 1711 | // 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. |
| 1718 | class BrowserOpenedWithNewProfileNotificationObserver |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1719 | : public content::NotificationObserver { |
[email protected] | 53d9e95 | 2011-09-23 09:44:11 | [diff] [blame] | 1720 | public: |
| 1721 | BrowserOpenedWithNewProfileNotificationObserver( |
| 1722 | AutomationProvider* automation, |
| 1723 | IPC::Message* reply_message); |
| 1724 | virtual ~BrowserOpenedWithNewProfileNotificationObserver(); |
| 1725 | |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1726 | // Overridden from content::NotificationObserver: |
[email protected] | 53d9e95 | 2011-09-23 09:44:11 | [diff] [blame] | 1727 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1728 | const content::NotificationSource& source, |
[email protected] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1729 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 53d9e95 | 2011-09-23 09:44:11 | [diff] [blame] | 1730 | |
| 1731 | private: |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 1732 | content::NotificationRegistrar registrar_; |
[email protected] | 53d9e95 | 2011-09-23 09:44:11 | [diff] [blame] | 1733 | 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] | 4518a58 | 2011-12-06 02:34:24 | [diff] [blame] | 1740 | // Waits for an extension popup to appear and load. |
| 1741 | class 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1749 | // Overridden from content::NotificationObserver: |
[email protected] | 4518a58 | 2011-12-06 02:34:24 | [diff] [blame] | 1750 | 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1763 | #if defined(OS_LINUX) |
| 1764 | // Allows the automation provider to wait for a WINDOW_MAXIMIZED notification. |
| 1765 | class 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] | d024cd1 | 2012-06-19 21:46:30 | [diff] [blame] | 1785 | // Wait for a new browser window to get created (for an existing profile). |
| 1786 | // Useful when reopening a multi-profile window. |
| 1787 | class 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1795 | |
[email protected] | d024cd1 | 2012-06-19 21:46:30 | [diff] [blame] | 1796 | 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] | 4ad6c3a | 2012-06-14 00:31:17 | [diff] [blame] | 1809 | |
[email protected] | e12de87e | 2009-08-28 00:02:08 | [diff] [blame] | 1810 | #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |