1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_
14 #include "base/callback.h"
15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/sequenced_task_runner_helpers.h"
19 #include "base/synchronization/waitable_event.h"
20 #include "base/values.h"
21 #include "chrome/browser/automation/automation_provider_json.h"
22 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
23 #include "components/autofill/core/browser/personal_data_manager.h"
24 #include "components/autofill/core/browser/personal_data_manager_observer.h"
25 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
27 #include "chrome/browser/chromeos/login/login_status_consumer.h"
28 #include "chrome/browser/chromeos/login/user_manager.h"
29 #include "chrome/browser/chromeos/login/wizard_controller.h"
30 #endif // defined(OS_CHROMEOS)
31 #include "chrome/browser/common/cancelable_request.h"
32 #include "chrome/browser/download/all_download_item_notifier.h"
33 #include "chrome/browser/history/history_service.h"
34 #include "chrome/browser/history/history_types.h"
35 #include "chrome/browser/importer/importer_progress_observer.h"
36 #include "chrome/browser/memory_details.h"
37 #include "chrome/browser/password_manager/password_store_change.h"
38 #include "chrome/browser/password_manager/password_store_consumer.h"
39 #include "chrome/browser/search_engines/template_url_service_observer.h"
40 #include "chrome/browser/ui/tabs/tab_strip_model.h"
41 #include "chrome/common/automation_constants.h"
42 #include "chrome/common/extensions/extension_constants.h"
43 #include "chrome/common/importer/importer_data_types.h"
44 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/download_item.h"
46 #include "content/public/browser/download_manager.h"
47 #include "content/public/browser/notification_observer.h"
48 #include "content/public/browser/notification_registrar.h"
49 #include "content/public/browser/notification_types.h"
50 #include "ui/gfx/point.h"
51 #include "ui/gfx/size.h"
53 class AutomationProvider
;
54 class BalloonCollection
;
56 class ExtensionService
;
61 namespace automation
{
65 #if defined(OS_CHROMEOS)
67 class ExistingUserController
;
70 #endif // defined(OS_CHROMEOS)
73 class NavigationController
;
78 namespace extensions
{
92 class BrowserPolicyConnector
;
95 class InitialLoadObserver
: public content::NotificationObserver
{
97 InitialLoadObserver(size_t tab_count
, AutomationProvider
* automation
);
98 virtual ~InitialLoadObserver();
100 // Overridden from content::NotificationObserver:
101 virtual void Observe(int type
,
102 const content::NotificationSource
& source
,
103 const content::NotificationDetails
& details
) OVERRIDE
;
105 // Caller owns the return value and is responsible for deleting it.
106 // Example return value:
107 // {'tabs': [{'start_time_ms': 1, 'stop_time_ms': 2.5},
108 // {'start_time_ms': 0.5, 'stop_time_ms': 3}]}
109 // stop_time_ms values may be null if WaitForInitialLoads has not finished.
110 // Only includes entries for the |tab_count| tabs we are monitoring.
111 // There is no defined ordering of the return value.
112 base::DictionaryValue
* GetTimingInformation() const;
116 typedef std::map
<uintptr_t, TabTime
> TabTimeMap
;
117 typedef std::set
<uintptr_t> TabSet
;
121 content::NotificationRegistrar registrar_
;
123 base::WeakPtr
<AutomationProvider
> automation_
;
124 size_t crashed_tab_count_
;
125 size_t outstanding_tab_count_
;
126 base::TimeTicks init_time_
;
127 TabTimeMap loading_tabs_
;
128 TabSet finished_tabs_
;
130 DISALLOW_COPY_AND_ASSIGN(InitialLoadObserver
);
133 #if defined(OS_CHROMEOS)
134 // Observes when the ChromeOS login WebUI becomes ready (by showing the login
135 // form, account picker, a network error or the OOBE wizard, depending on Chrome
137 class OOBEWebuiReadyObserver
: public content::NotificationObserver
{
139 explicit OOBEWebuiReadyObserver(AutomationProvider
* automation
);
141 // Overridden from content::NotificationObserver:
142 virtual void Observe(int type
,
143 const content::NotificationSource
& source
,
144 const content::NotificationDetails
& details
) OVERRIDE
;
147 void OOBEWebuiReady();
149 content::NotificationRegistrar registrar_
;
150 base::WeakPtr
<AutomationProvider
> automation_
;
152 DISALLOW_COPY_AND_ASSIGN(OOBEWebuiReadyObserver
);
154 #endif // defined(OS_CHROMEOS)
156 class NavigationControllerRestoredObserver
157 : public content::NotificationObserver
{
159 NavigationControllerRestoredObserver(
160 AutomationProvider
* automation
,
161 content::NavigationController
* controller
,
162 IPC::Message
* reply_message
);
163 virtual ~NavigationControllerRestoredObserver();
165 // Overridden from content::NotificationObserver:
166 virtual void Observe(int type
,
167 const content::NotificationSource
& source
,
168 const content::NotificationDetails
& details
) OVERRIDE
;
171 bool FinishedRestoring();
174 content::NotificationRegistrar registrar_
;
175 base::WeakPtr
<AutomationProvider
> automation_
;
176 content::NavigationController
* controller_
;
177 scoped_ptr
<IPC::Message
> reply_message_
;
179 DISALLOW_COPY_AND_ASSIGN(NavigationControllerRestoredObserver
);
182 class NavigationNotificationObserver
: public content::NotificationObserver
{
184 NavigationNotificationObserver(content::NavigationController
* controller
,
185 AutomationProvider
* automation
,
186 IPC::Message
* reply_message
,
187 int number_of_navigations
,
188 bool include_current_navigation
,
189 bool use_json_interface
);
190 virtual ~NavigationNotificationObserver();
192 // Overridden from content::NotificationObserver:
193 virtual void Observe(int type
,
194 const content::NotificationSource
& source
,
195 const content::NotificationDetails
& details
) OVERRIDE
;
197 void ConditionMet(AutomationMsg_NavigationResponseValues navigation_result
);
200 content::NotificationRegistrar registrar_
;
201 base::WeakPtr
<AutomationProvider
> automation_
;
202 scoped_ptr
<IPC::Message
> reply_message_
;
203 content::NavigationController
* controller_
;
204 int navigations_remaining_
;
205 bool navigation_started_
;
206 bool use_json_interface_
;
208 DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver
);
211 class TabStripNotificationObserver
: public content::NotificationObserver
{
213 TabStripNotificationObserver(int notification
,
214 AutomationProvider
* automation
);
215 virtual ~TabStripNotificationObserver();
217 // Overridden from content::NotificationObserver:
218 virtual void Observe(int type
,
219 const content::NotificationSource
& source
,
220 const content::NotificationDetails
& details
) OVERRIDE
;
222 virtual void ObserveTab(content::NavigationController
* controller
) = 0;
225 content::NotificationRegistrar registrar_
;
226 base::WeakPtr
<AutomationProvider
> automation_
;
230 class TabAppendedNotificationObserver
: public TabStripNotificationObserver
{
232 TabAppendedNotificationObserver(Browser
* parent
,
233 AutomationProvider
* automation
,
234 IPC::Message
* reply_message
,
235 bool use_json_interface
);
236 virtual ~TabAppendedNotificationObserver();
238 virtual void ObserveTab(content::NavigationController
* controller
);
239 IPC::Message
* ReleaseReply();
243 scoped_ptr
<IPC::Message
> reply_message_
;
244 bool use_json_interface_
;
247 DISALLOW_COPY_AND_ASSIGN(TabAppendedNotificationObserver
);
250 class TabClosedNotificationObserver
: public TabStripNotificationObserver
{
252 TabClosedNotificationObserver(AutomationProvider
* automation
,
253 bool wait_until_closed
,
254 IPC::Message
* reply_message
,
255 bool use_json_interface
);
256 virtual ~TabClosedNotificationObserver();
258 virtual void ObserveTab(content::NavigationController
* controller
);
260 void set_for_browser_command(bool for_browser_command
);
263 scoped_ptr
<IPC::Message
> reply_message_
;
264 bool use_json_interface_
;
265 bool for_browser_command_
;
268 DISALLOW_COPY_AND_ASSIGN(TabClosedNotificationObserver
);
271 // Notifies when the tab count reaches the target number.
272 class TabCountChangeObserver
: public TabStripModelObserver
{
274 TabCountChangeObserver(AutomationProvider
* automation
,
276 IPC::Message
* reply_message
,
277 int target_tab_count
);
278 // Implementation of TabStripModelObserver.
279 virtual void TabInsertedAt(content::WebContents
* contents
,
281 bool foreground
) OVERRIDE
;
282 virtual void TabDetachedAt(content::WebContents
* contents
,
284 virtual void TabStripModelDeleted() OVERRIDE
;
287 virtual ~TabCountChangeObserver();
289 // Checks if the current tab count matches our target, and if so,
290 // sends the reply message and deletes self.
291 void CheckTabCount();
293 base::WeakPtr
<AutomationProvider
> automation_
;
294 scoped_ptr
<IPC::Message
> reply_message_
;
296 TabStripModel
* tab_strip_model_
;
298 const int target_tab_count_
;
300 DISALLOW_COPY_AND_ASSIGN(TabCountChangeObserver
);
303 // Observes when an extension has been uninstalled.
304 class ExtensionUninstallObserver
: public content::NotificationObserver
{
306 ExtensionUninstallObserver(AutomationProvider
* automation
,
307 IPC::Message
* reply_message
,
308 const std::string
& id
);
309 virtual ~ExtensionUninstallObserver();
311 // Overridden from content::NotificationObserver:
312 virtual void Observe(int type
,
313 const content::NotificationSource
& source
,
314 const content::NotificationDetails
& details
) OVERRIDE
;
317 content::NotificationRegistrar registrar_
;
318 base::WeakPtr
<AutomationProvider
> automation_
;
319 scoped_ptr
<IPC::Message
> reply_message_
;
322 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallObserver
);
325 // Observes when an extension has finished loading and is ready for use. Also
326 // checks for possible install errors.
327 class ExtensionReadyNotificationObserver
328 : public content::NotificationObserver
{
330 // Creates an observer that replies using the JSON automation interface.
331 ExtensionReadyNotificationObserver(extensions::ProcessManager
* manager
,
332 ExtensionService
* service
,
333 AutomationProvider
* automation
,
334 IPC::Message
* reply_message
);
335 virtual ~ExtensionReadyNotificationObserver();
337 // Overridden from content::NotificationObserver:
338 virtual void Observe(int type
,
339 const content::NotificationSource
& source
,
340 const content::NotificationDetails
& details
) OVERRIDE
;
345 content::NotificationRegistrar registrar_
;
346 extensions::ProcessManager
* manager_
;
347 ExtensionService
* service_
;
348 base::WeakPtr
<AutomationProvider
> automation_
;
349 scoped_ptr
<IPC::Message
> reply_message_
;
350 const extensions::Extension
* extension_
;
352 DISALLOW_COPY_AND_ASSIGN(ExtensionReadyNotificationObserver
);
355 class ExtensionUnloadNotificationObserver
356 : public content::NotificationObserver
{
358 ExtensionUnloadNotificationObserver();
359 virtual ~ExtensionUnloadNotificationObserver();
361 // Overridden from content::NotificationObserver:
362 virtual void Observe(int type
,
363 const content::NotificationSource
& source
,
364 const content::NotificationDetails
& details
) OVERRIDE
;
366 bool did_receive_unload_notification() {
367 return did_receive_unload_notification_
;
371 content::NotificationRegistrar registrar_
;
372 bool did_receive_unload_notification_
;
374 DISALLOW_COPY_AND_ASSIGN(ExtensionUnloadNotificationObserver
);
377 // Observes when the extensions have been fully updated. The ExtensionUpdater
378 // service provides a notification whem all the updated extensions have been
379 // installed, but it does not wait for all of them to be loaded too. This
380 // observer waits until all updated extensions have actually been loaded.
381 class ExtensionsUpdatedObserver
: public content::NotificationObserver
{
383 ExtensionsUpdatedObserver(extensions::ProcessManager
* manager
,
384 AutomationProvider
* automation
,
385 IPC::Message
* reply_message
);
386 virtual ~ExtensionsUpdatedObserver();
388 // Overridden from content::NotificationObserver:
389 virtual void Observe(int type
,
390 const content::NotificationSource
& source
,
391 const content::NotificationDetails
& details
) OVERRIDE
;
393 // Called by ExtensionUpdater when it has finished updating extensions.
394 void UpdateCheckFinished();
399 content::NotificationRegistrar registrar_
;
400 extensions::ProcessManager
* manager_
;
401 base::WeakPtr
<AutomationProvider
> automation_
;
402 scoped_ptr
<IPC::Message
> reply_message_
;
403 bool updater_finished_
;
405 DISALLOW_COPY_AND_ASSIGN(ExtensionsUpdatedObserver
);
408 // Observes when a new browser has been opened and a tab within it has stopped
410 class BrowserOpenedNotificationObserver
: public content::NotificationObserver
{
412 BrowserOpenedNotificationObserver(AutomationProvider
* automation
,
413 IPC::Message
* reply_message
,
414 bool use_json_interface
);
415 virtual ~BrowserOpenedNotificationObserver();
417 // Overridden from content::NotificationObserver:
418 virtual void Observe(int type
,
419 const content::NotificationSource
& source
,
420 const content::NotificationDetails
& details
) OVERRIDE
;
422 void set_for_browser_command(bool for_browser_command
);
425 content::NotificationRegistrar registrar_
;
426 base::WeakPtr
<AutomationProvider
> automation_
;
427 scoped_ptr
<IPC::Message
> reply_message_
;
429 bool use_json_interface_
;
430 bool for_browser_command_
;
432 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedNotificationObserver
);
435 class BrowserClosedNotificationObserver
: public content::NotificationObserver
{
437 BrowserClosedNotificationObserver(Browser
* browser
,
438 AutomationProvider
* automation
,
439 IPC::Message
* reply_message
,
440 bool use_json_interface
);
441 virtual ~BrowserClosedNotificationObserver();
443 // Overridden from content::NotificationObserver:
444 virtual void Observe(int type
,
445 const content::NotificationSource
& source
,
446 const content::NotificationDetails
& details
) OVERRIDE
;
448 void set_for_browser_command(bool for_browser_command
);
451 content::NotificationRegistrar registrar_
;
452 base::WeakPtr
<AutomationProvider
> automation_
;
453 scoped_ptr
<IPC::Message
> reply_message_
;
454 bool use_json_interface_
;
455 bool for_browser_command_
;
457 DISALLOW_COPY_AND_ASSIGN(BrowserClosedNotificationObserver
);
460 class BrowserCountChangeNotificationObserver
461 : public content::NotificationObserver
{
463 BrowserCountChangeNotificationObserver(int target_count
,
464 AutomationProvider
* automation
,
465 IPC::Message
* reply_message
);
466 virtual ~BrowserCountChangeNotificationObserver();
468 // Overridden from content::NotificationObserver:
469 virtual void Observe(int type
,
470 const content::NotificationSource
& source
,
471 const content::NotificationDetails
& details
) OVERRIDE
;
475 content::NotificationRegistrar registrar_
;
476 base::WeakPtr
<AutomationProvider
> automation_
;
477 scoped_ptr
<IPC::Message
> reply_message_
;
479 DISALLOW_COPY_AND_ASSIGN(BrowserCountChangeNotificationObserver
);
482 class ExecuteBrowserCommandObserver
: public content::NotificationObserver
{
484 virtual ~ExecuteBrowserCommandObserver();
486 static bool CreateAndRegisterObserver(AutomationProvider
* automation
,
489 IPC::Message
* reply_message
,
490 bool use_json_interface
);
492 // Overridden from content::NotificationObserver:
493 virtual void Observe(int type
,
494 const content::NotificationSource
& source
,
495 const content::NotificationDetails
& details
) OVERRIDE
;
498 ExecuteBrowserCommandObserver(AutomationProvider
* automation
,
499 IPC::Message
* reply_message
,
500 bool use_json_interface
);
502 bool Register(int command
);
504 bool Getint(int command
, int* type
);
506 IPC::Message
* ReleaseReply();
508 content::NotificationRegistrar registrar_
;
509 base::WeakPtr
<AutomationProvider
> automation_
;
510 int notification_type_
;
511 scoped_ptr
<IPC::Message
> reply_message_
;
512 bool use_json_interface_
;
514 DISALLOW_COPY_AND_ASSIGN(ExecuteBrowserCommandObserver
);
517 class FindInPageNotificationObserver
: public content::NotificationObserver
{
519 FindInPageNotificationObserver(AutomationProvider
* automation
,
520 content::WebContents
* parent_tab
,
521 bool reply_with_json
,
522 IPC::Message
* reply_message
);
523 virtual ~FindInPageNotificationObserver();
525 // Overridden from content::NotificationObserver:
526 virtual void Observe(int type
,
527 const content::NotificationSource
& source
,
528 const content::NotificationDetails
& details
) OVERRIDE
;
530 // The Find mechanism is over asynchronous IPC, so a search is kicked off and
531 // we wait for notification to find out what the results are. As the user is
532 // typing, new search requests can be issued and the Request ID helps us make
533 // sense of whether this is the current request or an old one. The unit tests,
534 // however, which uses this constant issues only one search at a time, so we
535 // don't need a rolling id to identify each search. But, we still need to
536 // specify one, so we just use a fixed one - its value does not matter.
537 static const int kFindInPageRequestId
;
540 content::NotificationRegistrar registrar_
;
541 base::WeakPtr
<AutomationProvider
> automation_
;
542 // We will at some point (before final update) be notified of the ordinal and
543 // we need to preserve it so we can send it later.
544 int active_match_ordinal_
;
545 // Send reply using json automation interface.
546 bool reply_with_json_
;
547 scoped_ptr
<IPC::Message
> reply_message_
;
549 DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver
);
552 class DomOperationObserver
: public content::NotificationObserver
{
554 explicit DomOperationObserver(int automation_id
);
555 virtual ~DomOperationObserver();
557 // Overridden from content::NotificationObserver:
558 virtual void Observe(int type
,
559 const content::NotificationSource
& source
,
560 const content::NotificationDetails
& details
) OVERRIDE
;
562 virtual void OnDomOperationCompleted(const std::string
& json
) = 0;
563 virtual void OnJavascriptBlocked() = 0;
567 content::NotificationRegistrar registrar_
;
569 DISALLOW_COPY_AND_ASSIGN(DomOperationObserver
);
572 // Sends a message back to the automation client with the results of the DOM
574 class DomOperationMessageSender
: public DomOperationObserver
{
576 DomOperationMessageSender(AutomationProvider
* automation
,
577 IPC::Message
* reply_message
,
578 bool use_json_interface
);
579 virtual ~DomOperationMessageSender();
581 virtual void OnDomOperationCompleted(const std::string
& json
) OVERRIDE
;
582 virtual void OnJavascriptBlocked() OVERRIDE
;
585 base::WeakPtr
<AutomationProvider
> automation_
;
586 scoped_ptr
<IPC::Message
> reply_message_
;
587 bool use_json_interface_
;
589 DISALLOW_COPY_AND_ASSIGN(DomOperationMessageSender
);
592 // Collects METRIC_EVENT_DURATION notifications and keep track of the times.
593 class MetricEventDurationObserver
: public content::NotificationObserver
{
595 MetricEventDurationObserver();
596 virtual ~MetricEventDurationObserver();
598 // Get the duration of an event. Returns -1 if we haven't seen the event.
599 int GetEventDurationMs(const std::string
& event_name
);
601 // Overridden from content::NotificationObserver:
602 virtual void Observe(int type
,
603 const content::NotificationSource
& source
,
604 const content::NotificationDetails
& details
) OVERRIDE
;
607 content::NotificationRegistrar registrar_
;
609 typedef std::map
<std::string
, int> EventDurationMap
;
610 EventDurationMap durations_
;
612 DISALLOW_COPY_AND_ASSIGN(MetricEventDurationObserver
);
615 class InfoBarCountObserver
: public content::NotificationObserver
{
617 InfoBarCountObserver(AutomationProvider
* automation
,
618 IPC::Message
* reply_message
,
619 content::WebContents
* web_contents
,
620 size_t target_count
);
621 virtual ~InfoBarCountObserver();
623 // Overridden from content::NotificationObserver:
624 virtual void Observe(int type
,
625 const content::NotificationSource
& source
,
626 const content::NotificationDetails
& details
) OVERRIDE
;
629 // Checks whether the infobar count matches our target, and if so
630 // sends the reply message and deletes itself.
633 content::NotificationRegistrar registrar_
;
634 base::WeakPtr
<AutomationProvider
> automation_
;
635 scoped_ptr
<IPC::Message
> reply_message_
;
636 content::WebContents
* web_contents_
;
638 const size_t target_count_
;
640 DISALLOW_COPY_AND_ASSIGN(InfoBarCountObserver
);
643 #if defined(OS_CHROMEOS)
644 class LoginObserver
: public chromeos::LoginStatusConsumer
{
646 LoginObserver(chromeos::ExistingUserController
* controller
,
647 AutomationProvider
* automation
,
648 IPC::Message
* reply_message
);
650 virtual ~LoginObserver();
652 virtual void OnLoginFailure(const chromeos::LoginFailure
& error
);
654 virtual void OnLoginSuccess(const chromeos::UserContext
& user_context
);
657 chromeos::ExistingUserController
* controller_
;
658 base::WeakPtr
<AutomationProvider
> automation_
;
659 scoped_ptr
<IPC::Message
> reply_message_
;
661 DISALLOW_COPY_AND_ASSIGN(LoginObserver
);
664 // Waits for a screen change notification from WizardController.
665 class WizardControllerObserver
: public chromeos::WizardController::Observer
,
666 public content::NotificationObserver
{
668 WizardControllerObserver(chromeos::WizardController
* wizard_controller
,
669 AutomationProvider
* automation
,
670 IPC::Message
* reply_message
);
671 virtual ~WizardControllerObserver();
673 // If non-empty, waits for a specific change to screen with this name.
674 std::string
screen_to_wait_for() { return screen_to_wait_for_
; }
675 void set_screen_to_wait_for(const std::string
& screen_name
) {
676 screen_to_wait_for_
= screen_name
;
680 // chromeos::WizardController::Observer overrides:
681 virtual void OnScreenChanged(chromeos::WizardScreen
* next_screen
) OVERRIDE
;
682 virtual void OnSessionStart() OVERRIDE
;
684 // content::NotificationObserver overrides:
685 void Observe(int type
,
686 const content::NotificationSource
& source
,
687 const content::NotificationDetails
& details
);
689 // Sends reply with the given screen name and deletes |this|.
690 void SendReply(const std::string
& screen_name
);
692 content::NotificationRegistrar registrar_
;
693 chromeos::WizardController
* wizard_controller_
;
694 base::WeakPtr
<AutomationProvider
> automation_
;
695 scoped_ptr
<IPC::Message
> reply_message_
;
696 std::string screen_to_wait_for_
;
698 DISALLOW_COPY_AND_ASSIGN(WizardControllerObserver
);
701 // Collects SCREEN_LOCK_STATE_CHANGED notifications and returns
702 // whether authentication succeeded to the automation provider.
703 class ScreenLockUnlockObserver
: public content::NotificationObserver
{
705 // Set lock_screen to true to observe lock screen events,
706 // false for unlock screen events.
707 ScreenLockUnlockObserver(AutomationProvider
* automation
,
708 IPC::Message
* reply_message
,
710 virtual ~ScreenLockUnlockObserver();
712 // Overridden from content::NotificationObserver:
713 virtual void Observe(int type
,
714 const content::NotificationSource
& source
,
715 const content::NotificationDetails
& details
) OVERRIDE
;
718 base::WeakPtr
<AutomationProvider
> automation_
;
719 scoped_ptr
<IPC::Message
> reply_message_
;
722 content::NotificationRegistrar registrar_
;
725 DISALLOW_COPY_AND_ASSIGN(ScreenLockUnlockObserver
);
728 // Watches SCREEN_LOCK_STATE_CHANGED notifications like the
729 // ScreenLockUnlockObserver, but additionally adds itself as an observer
730 // to a screen locker in order to monitor unlock failure cases.
731 class ScreenUnlockObserver
: public ScreenLockUnlockObserver
,
732 public chromeos::LoginStatusConsumer
{
734 ScreenUnlockObserver(AutomationProvider
* automation
,
735 IPC::Message
* reply_message
);
736 virtual ~ScreenUnlockObserver();
738 virtual void OnLoginFailure(const chromeos::LoginFailure
& error
);
740 virtual void OnLoginSuccess(const chromeos::UserContext
& user_context
) {}
743 DISALLOW_COPY_AND_ASSIGN(ScreenUnlockObserver
);
746 #endif // defined(OS_CHROMEOS)
748 // Waits for the bookmark model to load.
749 class AutomationProviderBookmarkModelObserver
: public BookmarkModelObserver
{
751 AutomationProviderBookmarkModelObserver(AutomationProvider
* provider
,
752 IPC::Message
* reply_message
,
753 BookmarkModel
* model
,
754 bool use_json_interface
);
755 virtual ~AutomationProviderBookmarkModelObserver();
757 // BookmarkModelObserver:
758 virtual void BookmarkModelLoaded(BookmarkModel
* model
,
759 bool ids_reassigned
) OVERRIDE
;
760 virtual void BookmarkModelBeingDeleted(BookmarkModel
* model
) OVERRIDE
;
761 virtual void BookmarkNodeMoved(BookmarkModel
* model
,
762 const BookmarkNode
* old_parent
,
764 const BookmarkNode
* new_parent
,
765 int new_index
) OVERRIDE
{}
766 virtual void BookmarkNodeAdded(BookmarkModel
* model
,
767 const BookmarkNode
* parent
,
768 int index
) OVERRIDE
{}
769 virtual void BookmarkNodeRemoved(BookmarkModel
* model
,
770 const BookmarkNode
* parent
,
772 const BookmarkNode
* node
) OVERRIDE
{}
773 virtual void BookmarkAllNodesRemoved(BookmarkModel
* model
) OVERRIDE
{}
774 virtual void BookmarkNodeChanged(BookmarkModel
* model
,
775 const BookmarkNode
* node
) OVERRIDE
{}
776 virtual void BookmarkNodeFaviconChanged(BookmarkModel
* model
,
777 const BookmarkNode
* node
) OVERRIDE
{}
778 virtual void BookmarkNodeChildrenReordered(
779 BookmarkModel
* model
,
780 const BookmarkNode
* node
) OVERRIDE
{}
782 IPC::Message
* ReleaseReply();
785 // Reply to the automation message with the given success value,
786 // then delete myself (which removes myself from the bookmark model
788 void ReplyAndDelete(bool success
);
790 base::WeakPtr
<AutomationProvider
> automation_provider_
;
791 scoped_ptr
<IPC::Message
> reply_message_
;
792 BookmarkModel
* model_
;
793 bool use_json_interface_
;
795 DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver
);
798 // Allows the automation provider to wait until the download has been updated
800 class AutomationProviderDownloadUpdatedObserver
801 : public content::DownloadItem::Observer
{
803 AutomationProviderDownloadUpdatedObserver(
804 AutomationProvider
* provider
,
805 IPC::Message
* reply_message
,
808 virtual ~AutomationProviderDownloadUpdatedObserver();
810 virtual void OnDownloadUpdated(content::DownloadItem
* download
);
811 virtual void OnDownloadOpened(content::DownloadItem
* download
);
814 base::WeakPtr
<AutomationProvider
> provider_
;
815 scoped_ptr
<IPC::Message
> reply_message_
;
819 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadUpdatedObserver
);
822 // Allows the automation provider to wait until the download model has changed
823 // (because a new download has been added or removed).
824 class AutomationProviderDownloadModelChangedObserver
825 : public AllDownloadItemNotifier::Observer
{
827 AutomationProviderDownloadModelChangedObserver(
828 AutomationProvider
* provider
,
829 IPC::Message
* reply_message
,
830 content::DownloadManager
* download_manager
);
831 virtual ~AutomationProviderDownloadModelChangedObserver();
833 virtual void OnDownloadCreated(
834 content::DownloadManager
* manager
, content::DownloadItem
* item
) OVERRIDE
;
835 virtual void OnDownloadRemoved(
836 content::DownloadManager
* manager
, content::DownloadItem
* item
) OVERRIDE
;
841 base::WeakPtr
<AutomationProvider
> provider_
;
842 scoped_ptr
<IPC::Message
> reply_message_
;
843 AllDownloadItemNotifier notifier_
;
845 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver
);
848 // Observes when all pending downloads have completed.
849 class AllDownloadsCompleteObserver
850 : public content::DownloadManager::Observer
,
851 public content::DownloadItem::Observer
{
853 AllDownloadsCompleteObserver(
854 AutomationProvider
* provider
,
855 IPC::Message
* reply_message
,
856 content::DownloadManager
* download_manager
,
857 base::ListValue
* pre_download_ids
);
858 virtual ~AllDownloadsCompleteObserver();
860 // content::DownloadManager::Observer.
861 virtual void OnDownloadCreated(
862 content::DownloadManager
* manager
, content::DownloadItem
* item
) OVERRIDE
;
863 virtual void ManagerGoingDown(content::DownloadManager
* manager
) OVERRIDE
;
865 // content::DownloadItem::Observer.
866 virtual void OnDownloadUpdated(content::DownloadItem
* download
) OVERRIDE
;
869 void ReplyIfNecessary();
871 base::WeakPtr
<AutomationProvider
> provider_
;
872 scoped_ptr
<IPC::Message
> reply_message_
;
873 content::DownloadManager
* download_manager_
;
874 std::set
<int> pre_download_ids_
;
875 std::set
<content::DownloadItem
*> pending_downloads_
;
877 DISALLOW_COPY_AND_ASSIGN(AllDownloadsCompleteObserver
);
880 // Allows automation provider to wait until TemplateURLService has loaded
881 // before looking up/returning search engine info.
882 class AutomationProviderSearchEngineObserver
883 : public TemplateURLServiceObserver
{
885 AutomationProviderSearchEngineObserver(
886 AutomationProvider
* provider
,
888 IPC::Message
* reply_message
);
889 virtual ~AutomationProviderSearchEngineObserver();
891 virtual void OnTemplateURLServiceChanged();
894 base::WeakPtr
<AutomationProvider
> provider_
;
896 scoped_ptr
<IPC::Message
> reply_message_
;
898 DISALLOW_COPY_AND_ASSIGN(AutomationProviderSearchEngineObserver
);
901 // Allows the automation provider to wait for history queries to finish.
902 class AutomationProviderHistoryObserver
{
904 AutomationProviderHistoryObserver(
905 AutomationProvider
* provider
,
906 IPC::Message
* reply_message
);
907 virtual ~AutomationProviderHistoryObserver();
909 void HistoryQueryComplete(HistoryService::Handle request_handle
,
910 history::QueryResults
* results
);
913 base::WeakPtr
<AutomationProvider
> provider_
;
914 scoped_ptr
<IPC::Message
> reply_message_
;
917 // Allows the automation provider to wait for import queries to finish.
918 class AutomationProviderImportSettingsObserver
919 : public importer::ImporterProgressObserver
{
921 AutomationProviderImportSettingsObserver(
922 AutomationProvider
* provider
,
923 IPC::Message
* reply_message
);
924 virtual ~AutomationProviderImportSettingsObserver();
926 // importer::ImporterProgressObserver:
927 virtual void ImportStarted() OVERRIDE
;
928 virtual void ImportItemStarted(importer::ImportItem item
) OVERRIDE
;
929 virtual void ImportItemEnded(importer::ImportItem item
) OVERRIDE
;
930 virtual void ImportEnded() OVERRIDE
;
933 base::WeakPtr
<AutomationProvider
> provider_
;
934 scoped_ptr
<IPC::Message
> reply_message_
;
937 // Allows automation provider to wait for getting passwords to finish.
938 class AutomationProviderGetPasswordsObserver
: public PasswordStoreConsumer
{
940 AutomationProviderGetPasswordsObserver(
941 AutomationProvider
* provider
,
942 IPC::Message
* reply_message
);
943 virtual ~AutomationProviderGetPasswordsObserver();
945 // PasswordStoreConsumer implementation.
946 virtual void OnPasswordStoreRequestDone(
947 CancelableRequestProvider::Handle handle
,
948 const std::vector
<autofill::PasswordForm
*>& result
) OVERRIDE
;
949 virtual void OnGetPasswordStoreResults(
950 const std::vector
<autofill::PasswordForm
*>& results
) OVERRIDE
;
953 base::WeakPtr
<AutomationProvider
> provider_
;
954 scoped_ptr
<IPC::Message
> reply_message_
;
957 // Observes when login entries stored in the password store are changed. The
958 // notifications are sent on the DB thread, the thread that interacts with the
960 class PasswordStoreLoginsChangedObserver
961 : public base::RefCountedThreadSafe
<
962 PasswordStoreLoginsChangedObserver
,
963 content::BrowserThread::DeleteOnUIThread
>,
964 public content::NotificationObserver
{
966 PasswordStoreLoginsChangedObserver(AutomationProvider
* automation
,
967 IPC::Message
* reply_message
,
968 PasswordStoreChange::Type expected_type
,
969 const std::string
& result_key
);
971 // Schedules a task on the DB thread to register the appropriate observers.
974 // Overridden from content::NotificationObserver:
975 virtual void Observe(int type
,
976 const content::NotificationSource
& source
,
977 const content::NotificationDetails
& details
) OVERRIDE
;
980 friend struct content::BrowserThread::DeleteOnThread
<
981 content::BrowserThread::UI
>;
982 ~PasswordStoreLoginsChangedObserver();
983 friend class base::DeleteHelper
<PasswordStoreLoginsChangedObserver
>;
985 // Registers the appropriate observers. Called on the DB thread.
986 void RegisterObserversTask();
988 // Sends the |reply_message_| to |automation_| indicating we're done. Called
992 // Sends an error reply to |automation_|. Called on the UI thread.
993 void IndicateError(const std::string
& error
);
995 base::WeakPtr
<AutomationProvider
> automation_
;
996 scoped_ptr
<IPC::Message
> reply_message_
;
997 scoped_ptr
<content::NotificationRegistrar
> registrar_
;
998 PasswordStoreChange::Type expected_type_
;
999 std::string result_key_
;
1001 // Used to ensure that the UI thread waits for the DB thread to finish
1002 // registering observers before proceeding.
1003 base::WaitableEvent done_event_
;
1005 DISALLOW_COPY_AND_ASSIGN(PasswordStoreLoginsChangedObserver
);
1008 // Allows automation provider to wait until page load after selecting an item
1009 // in the omnibox popup.
1010 class OmniboxAcceptNotificationObserver
: public content::NotificationObserver
{
1012 OmniboxAcceptNotificationObserver(content::NavigationController
* controller
,
1013 AutomationProvider
* automation
,
1014 IPC::Message
* reply_message
);
1015 virtual ~OmniboxAcceptNotificationObserver();
1017 // Overridden from content::NotificationObserver:
1018 virtual void Observe(int type
,
1019 const content::NotificationSource
& source
,
1020 const content::NotificationDetails
& details
) OVERRIDE
;
1023 content::NotificationRegistrar registrar_
;
1024 base::WeakPtr
<AutomationProvider
> automation_
;
1025 scoped_ptr
<IPC::Message
> reply_message_
;
1026 content::NavigationController
* controller_
;
1028 DISALLOW_COPY_AND_ASSIGN(OmniboxAcceptNotificationObserver
);
1031 // Allows the automation provider to wait for a save package notification.
1032 class SavePackageNotificationObserver
1033 : public content::DownloadManager::Observer
{
1035 SavePackageNotificationObserver(content::DownloadManager
* download_manager
,
1036 AutomationProvider
* automation
,
1037 IPC::Message
* reply_message
);
1038 virtual ~SavePackageNotificationObserver();
1040 // Overridden from content::DownloadManager::Observer:
1041 virtual void OnSavePackageSuccessfullyFinished(
1042 content::DownloadManager
* manager
, content::DownloadItem
* item
) OVERRIDE
;
1043 virtual void ManagerGoingDown(content::DownloadManager
* manager
) OVERRIDE
;
1046 content::DownloadManager
* download_manager_
;
1047 base::WeakPtr
<AutomationProvider
> automation_
;
1048 scoped_ptr
<IPC::Message
> reply_message_
;
1050 DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver
);
1053 class NTPInfoObserver
: public content::NotificationObserver
{
1055 NTPInfoObserver(AutomationProvider
* automation
, IPC::Message
* reply_message
);
1056 virtual ~NTPInfoObserver();
1058 // Overridden from content::NotificationObserver:
1059 virtual void Observe(int type
,
1060 const content::NotificationSource
& source
,
1061 const content::NotificationDetails
& details
) OVERRIDE
;
1064 void OnTopSitesLoaded();
1065 void OnTopSitesReceived(const history::MostVisitedURLList
& visited_list
);
1067 base::WeakPtr
<AutomationProvider
> automation_
;
1068 scoped_ptr
<IPC::Message
> reply_message_
;
1069 CancelableRequestProvider::Handle request_
;
1070 scoped_ptr
<base::DictionaryValue
> ntp_info_
;
1071 history::TopSites
* top_sites_
;
1072 content::NotificationRegistrar registrar_
;
1074 DISALLOW_COPY_AND_ASSIGN(NTPInfoObserver
);
1077 // Observes when an app has been launched, as indicated by a notification that
1078 // a content load in some tab has stopped.
1079 class AppLaunchObserver
: public content::NotificationObserver
{
1081 AppLaunchObserver(content::NavigationController
* controller
,
1082 AutomationProvider
* automation
,
1083 IPC::Message
* reply_message
,
1084 extensions::LaunchContainer launch_container
);
1085 virtual ~AppLaunchObserver();
1087 // Overridden from content::NotificationObserver:
1088 virtual void Observe(int type
,
1089 const content::NotificationSource
& source
,
1090 const content::NotificationDetails
& details
) OVERRIDE
;
1093 content::NavigationController
* controller_
;
1094 base::WeakPtr
<AutomationProvider
> automation_
;
1095 scoped_ptr
<IPC::Message
> reply_message_
;
1096 content::NotificationRegistrar registrar_
;
1097 extensions::LaunchContainer launch_container_
;
1100 DISALLOW_COPY_AND_ASSIGN(AppLaunchObserver
);
1103 // Allows the automation provider to wait until all the notification
1104 // processes are ready.
1105 class GetAllNotificationsObserver
: public content::NotificationObserver
{
1107 GetAllNotificationsObserver(AutomationProvider
* automation
,
1108 IPC::Message
* reply_message
);
1109 virtual ~GetAllNotificationsObserver();
1111 // Overridden from content::NotificationObserver:
1112 virtual void Observe(int type
,
1113 const content::NotificationSource
& source
,
1114 const content::NotificationDetails
& details
) OVERRIDE
;
1117 // Sends a message via the |AutomationProvider|. |automation_| must be valid.
1118 // Deletes itself after the message is sent.
1120 // Returns a new dictionary describing the given notification.
1121 base::DictionaryValue
* NotificationToJson(const Notification
* note
);
1123 content::NotificationRegistrar registrar_
;
1124 base::WeakPtr
<AutomationProvider
> automation_
;
1125 scoped_ptr
<IPC::Message
> reply_message_
;
1127 DISALLOW_COPY_AND_ASSIGN(GetAllNotificationsObserver
);
1130 // Allows the automation provider to wait for a new notification balloon
1131 // to appear and be ready.
1132 class NewNotificationBalloonObserver
: public content::NotificationObserver
{
1134 NewNotificationBalloonObserver(AutomationProvider
* provider
,
1135 IPC::Message
* reply_message
);
1136 virtual ~NewNotificationBalloonObserver();
1138 // Overridden from content::NotificationObserver:
1139 virtual void Observe(int type
,
1140 const content::NotificationSource
& source
,
1141 const content::NotificationDetails
& details
) OVERRIDE
;
1144 content::NotificationRegistrar registrar_
;
1145 base::WeakPtr
<AutomationProvider
> automation_
;
1146 scoped_ptr
<IPC::Message
> reply_message_
;
1148 DISALLOW_COPY_AND_ASSIGN(NewNotificationBalloonObserver
);
1151 // Allows the automation provider to wait for a given number of
1152 // notification balloons.
1153 class OnNotificationBalloonCountObserver
1154 : public content::NotificationObserver
{
1156 OnNotificationBalloonCountObserver(AutomationProvider
* provider
,
1157 IPC::Message
* reply_message
,
1159 virtual ~OnNotificationBalloonCountObserver();
1161 // Sends an automation reply message if |automation_| is still valid and the
1162 // number of ready balloons matches the desired count. Deletes itself if the
1163 // message is sent or if |automation_| is invalid.
1164 void CheckBalloonCount();
1166 // Overridden from content::NotificationObserver:
1167 virtual void Observe(int type
,
1168 const content::NotificationSource
& source
,
1169 const content::NotificationDetails
& details
) OVERRIDE
;
1172 content::NotificationRegistrar registrar_
;
1173 base::WeakPtr
<AutomationProvider
> automation_
;
1174 scoped_ptr
<IPC::Message
> reply_message_
;
1176 BalloonCollection
* collection_
;
1179 DISALLOW_COPY_AND_ASSIGN(OnNotificationBalloonCountObserver
);
1182 // Allows the automation provider to wait for a RENDERER_PROCESS_CLOSED
1184 class RendererProcessClosedObserver
: public content::NotificationObserver
{
1186 RendererProcessClosedObserver(AutomationProvider
* automation
,
1187 IPC::Message
* reply_message
);
1188 virtual ~RendererProcessClosedObserver();
1190 // Overridden from content::NotificationObserver:
1191 virtual void Observe(int type
,
1192 const content::NotificationSource
& source
,
1193 const content::NotificationDetails
& details
) OVERRIDE
;
1196 content::NotificationRegistrar registrar_
;
1197 base::WeakPtr
<AutomationProvider
> automation_
;
1198 scoped_ptr
<IPC::Message
> reply_message_
;
1200 DISALLOW_COPY_AND_ASSIGN(RendererProcessClosedObserver
);
1203 // Allows the automation provider to wait for acknowledgement that a certain
1204 // type and number of input events has been processed by the renderer.
1205 class InputEventAckNotificationObserver
: public content::NotificationObserver
{
1207 InputEventAckNotificationObserver(AutomationProvider
* automation
,
1208 IPC::Message
* reply_message
,
1209 int event_type
, int count
);
1210 virtual ~InputEventAckNotificationObserver();
1212 // Overridden from content::NotificationObserver:
1213 virtual void Observe(int type
,
1214 const content::NotificationSource
& source
,
1215 const content::NotificationDetails
& details
) OVERRIDE
;
1218 content::NotificationRegistrar registrar_
;
1219 base::WeakPtr
<AutomationProvider
> automation_
;
1220 scoped_ptr
<IPC::Message
> reply_message_
;
1224 DISALLOW_COPY_AND_ASSIGN(InputEventAckNotificationObserver
);
1227 // Observer used to listen for new tab creation to complete.
1228 class NewTabObserver
: public content::NotificationObserver
{
1230 NewTabObserver(AutomationProvider
* automation
,
1231 IPC::Message
* reply_message
,
1232 bool use_json_interface
);
1234 // Overridden from content::NotificationObserver:
1235 virtual void Observe(int type
,
1236 const content::NotificationSource
& source
,
1237 const content::NotificationDetails
& details
) OVERRIDE
;
1240 virtual ~NewTabObserver();
1242 content::NotificationRegistrar registrar_
;
1243 base::WeakPtr
<AutomationProvider
> automation_
;
1244 scoped_ptr
<IPC::Message
> reply_message_
;
1245 bool use_json_interface_
;
1247 DISALLOW_COPY_AND_ASSIGN(NewTabObserver
);
1250 // Posts a task to the PROCESS_LAUNCHER thread, once processed posts a task
1251 // back to the UI thread that notifies the provider we're done.
1252 class WaitForProcessLauncherThreadToGoIdleObserver
1253 : public base::RefCountedThreadSafe
<
1254 WaitForProcessLauncherThreadToGoIdleObserver
,
1255 content::BrowserThread::DeleteOnUIThread
> {
1257 WaitForProcessLauncherThreadToGoIdleObserver(
1258 AutomationProvider
* automation
, IPC::Message
* reply_message
);
1261 friend struct content::BrowserThread::DeleteOnThread
<
1262 content::BrowserThread::UI
>;
1263 friend class base::DeleteHelper
<WaitForProcessLauncherThreadToGoIdleObserver
>;
1265 virtual ~WaitForProcessLauncherThreadToGoIdleObserver();
1267 // Schedules a task on the PROCESS_LAUNCHER thread to execute
1268 // |RunOnProcessLauncherThread2|. By the time the task is executed the
1269 // PROCESS_LAUNCHER thread should be some what idle.
1270 void RunOnProcessLauncherThread();
1272 // When executed the PROCESS_LAUNCHER thread should have processed any pending
1273 // tasks. Schedules a task on the UI thread that sends the message saying
1275 void RunOnProcessLauncherThread2();
1277 // Sends the |reply_message_| to |automation_| indicating we're done.
1278 void RunOnUIThread();
1280 base::WeakPtr
<AutomationProvider
> automation_
;
1281 scoped_ptr
<IPC::Message
> reply_message_
;
1283 DISALLOW_COPY_AND_ASSIGN(WaitForProcessLauncherThreadToGoIdleObserver
);
1286 // Allows the automation provider to wait for acknowledgement that a drop
1287 // operation has been processed by the renderer.
1288 class DragTargetDropAckNotificationObserver
1289 : public content::NotificationObserver
{
1291 DragTargetDropAckNotificationObserver(AutomationProvider
* automation
,
1292 IPC::Message
* reply_message
);
1293 virtual ~DragTargetDropAckNotificationObserver();
1295 // Overridden from content::NotificationObserver:
1296 virtual void Observe(int type
,
1297 const content::NotificationSource
& source
,
1298 const content::NotificationDetails
& details
) OVERRIDE
;
1301 content::NotificationRegistrar registrar_
;
1302 base::WeakPtr
<AutomationProvider
> automation_
;
1303 scoped_ptr
<IPC::Message
> reply_message_
;
1305 DISALLOW_COPY_AND_ASSIGN(DragTargetDropAckNotificationObserver
);
1308 // Allows the automation provider to wait for process memory details to be
1309 // available before sending this information to the client.
1310 class ProcessInfoObserver
: public MemoryDetails
{
1312 ProcessInfoObserver(AutomationProvider
* automation
,
1313 IPC::Message
* reply_message
);
1315 virtual void OnDetailsAvailable() OVERRIDE
;
1318 virtual ~ProcessInfoObserver();
1319 base::WeakPtr
<AutomationProvider
> automation_
;
1320 scoped_ptr
<IPC::Message
> reply_message_
;
1322 DISALLOW_COPY_AND_ASSIGN(ProcessInfoObserver
);
1325 // Observes when new v8 heap statistics are computed for a renderer process.
1326 class V8HeapStatsObserver
: public content::NotificationObserver
{
1328 V8HeapStatsObserver(AutomationProvider
* automation
,
1329 IPC::Message
* reply_message
,
1330 base::ProcessId renderer_id
);
1331 virtual ~V8HeapStatsObserver();
1333 // Overridden from content::NotificationObserver:
1334 virtual void Observe(int type
,
1335 const content::NotificationSource
& source
,
1336 const content::NotificationDetails
& details
) OVERRIDE
;
1339 content::NotificationRegistrar registrar_
;
1340 base::WeakPtr
<AutomationProvider
> automation_
;
1341 scoped_ptr
<IPC::Message
> reply_message_
;
1342 base::ProcessId renderer_id_
;
1344 DISALLOW_COPY_AND_ASSIGN(V8HeapStatsObserver
);
1347 // Observes when a new FPS value is computed for a renderer process.
1348 class FPSObserver
: public content::NotificationObserver
{
1350 FPSObserver(AutomationProvider
* automation
,
1351 IPC::Message
* reply_message
,
1352 base::ProcessId renderer_id
,
1354 virtual ~FPSObserver();
1356 // Overridden from content::NotificationObserver:
1357 virtual void Observe(int type
,
1358 const content::NotificationSource
& source
,
1359 const content::NotificationDetails
& details
) OVERRIDE
;
1362 content::NotificationRegistrar registrar_
;
1363 base::WeakPtr
<AutomationProvider
> automation_
;
1364 scoped_ptr
<IPC::Message
> reply_message_
;
1365 base::ProcessId renderer_id_
;
1368 DISALLOW_COPY_AND_ASSIGN(FPSObserver
);
1371 // Manages the process of creating a new Profile and opening a new browser with
1372 // that profile. This observer should be created, and then a new Profile
1373 // should be created through the ProfileManager using
1374 // profile_manager->CreateMultiProfileAsync(). The Observer watches for profile
1375 // creation, upon which it creates a new browser window; after observing
1376 // window creation, it creates a new tab and then finally observes it finish
1378 class BrowserOpenedWithNewProfileNotificationObserver
1379 : public content::NotificationObserver
{
1381 BrowserOpenedWithNewProfileNotificationObserver(
1382 AutomationProvider
* automation
,
1383 IPC::Message
* reply_message
);
1384 virtual ~BrowserOpenedWithNewProfileNotificationObserver();
1386 // Overridden from content::NotificationObserver:
1387 virtual void Observe(int type
,
1388 const content::NotificationSource
& source
,
1389 const content::NotificationDetails
& details
) OVERRIDE
;
1392 content::NotificationRegistrar registrar_
;
1393 base::WeakPtr
<AutomationProvider
> automation_
;
1394 scoped_ptr
<IPC::Message
> reply_message_
;
1397 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedWithNewProfileNotificationObserver
);
1400 // Waits for an extension popup to appear and load.
1401 class ExtensionPopupObserver
: public content::NotificationObserver
{
1403 ExtensionPopupObserver(
1404 AutomationProvider
* automation
,
1405 IPC::Message
* reply_message
,
1406 const std::string
& extension_id
);
1407 ~ExtensionPopupObserver();
1409 // Overridden from content::NotificationObserver:
1410 virtual void Observe(int type
,
1411 const content::NotificationSource
& source
,
1412 const content::NotificationDetails
& details
) OVERRIDE
;
1415 base::WeakPtr
<AutomationProvider
> automation_
;
1416 scoped_ptr
<IPC::Message
> reply_message_
;
1417 std::string extension_id_
;
1418 content::NotificationRegistrar registrar_
;
1420 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupObserver
);
1423 #if defined(OS_LINUX)
1424 // Allows the automation provider to wait for a WINDOW_MAXIMIZED notification.
1425 class WindowMaximizedObserver
: public content::NotificationObserver
{
1427 WindowMaximizedObserver(AutomationProvider
* automation
,
1428 IPC::Message
* reply_message
);
1429 virtual ~WindowMaximizedObserver();
1431 // Overridden from content::NotificationObserver:
1432 virtual void Observe(int type
,
1433 const content::NotificationSource
& source
,
1434 const content::NotificationDetails
& details
) OVERRIDE
;
1437 content::NotificationRegistrar registrar_
;
1438 base::WeakPtr
<AutomationProvider
> automation_
;
1439 scoped_ptr
<IPC::Message
> reply_message_
;
1441 DISALLOW_COPY_AND_ASSIGN(WindowMaximizedObserver
);
1443 #endif // defined(OS_LINUX)
1445 // Wait for a new browser window to get created (for an existing profile).
1446 // Useful when reopening a multi-profile window.
1447 class BrowserOpenedWithExistingProfileNotificationObserver
1448 : public content::NotificationObserver
{
1450 BrowserOpenedWithExistingProfileNotificationObserver(
1451 AutomationProvider
* automation
,
1452 IPC::Message
* reply_message
,
1454 virtual ~BrowserOpenedWithExistingProfileNotificationObserver();
1456 virtual void Observe(int type
,
1457 const content::NotificationSource
& source
,
1458 const content::NotificationDetails
& details
);
1460 content::NotificationRegistrar registrar_
;
1461 base::WeakPtr
<AutomationProvider
> automation_
;
1462 scoped_ptr
<IPC::Message
> reply_message_
;
1466 DISALLOW_COPY_AND_ASSIGN(
1467 BrowserOpenedWithExistingProfileNotificationObserver
);
1470 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_