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 ExtensionProcessManager;
57 class ExtensionService;
62 namespace automation {
66 #if defined(OS_CHROMEOS)
68 class ExistingUserController;
71 #endif // defined(OS_CHROMEOS)
74 class NavigationController;
79 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 // Watches for NewTabUI page loads for performance timing purposes.
157 class NewTabUILoadObserver : public content::NotificationObserver {
159 explicit NewTabUILoadObserver(AutomationProvider* automation,
161 virtual ~NewTabUILoadObserver();
163 // Overridden from content::NotificationObserver:
164 virtual void Observe(int type,
165 const content::NotificationSource& source,
166 const content::NotificationDetails& details) OVERRIDE;
169 content::NotificationRegistrar registrar_;
170 base::WeakPtr<AutomationProvider> automation_;
172 DISALLOW_COPY_AND_ASSIGN(NewTabUILoadObserver);
175 class NavigationControllerRestoredObserver
176 : public content::NotificationObserver {
178 NavigationControllerRestoredObserver(
179 AutomationProvider* automation,
180 content::NavigationController* controller,
181 IPC::Message* reply_message);
182 virtual ~NavigationControllerRestoredObserver();
184 // Overridden from content::NotificationObserver:
185 virtual void Observe(int type,
186 const content::NotificationSource& source,
187 const content::NotificationDetails& details) OVERRIDE;
190 bool FinishedRestoring();
193 content::NotificationRegistrar registrar_;
194 base::WeakPtr<AutomationProvider> automation_;
195 content::NavigationController* controller_;
196 scoped_ptr<IPC::Message> reply_message_;
198 DISALLOW_COPY_AND_ASSIGN(NavigationControllerRestoredObserver);
201 class NavigationNotificationObserver : public content::NotificationObserver {
203 NavigationNotificationObserver(content::NavigationController* controller,
204 AutomationProvider* automation,
205 IPC::Message* reply_message,
206 int number_of_navigations,
207 bool include_current_navigation,
208 bool use_json_interface);
209 virtual ~NavigationNotificationObserver();
211 // Overridden from content::NotificationObserver:
212 virtual void Observe(int type,
213 const content::NotificationSource& source,
214 const content::NotificationDetails& details) OVERRIDE;
216 void ConditionMet(AutomationMsg_NavigationResponseValues navigation_result);
219 content::NotificationRegistrar registrar_;
220 base::WeakPtr<AutomationProvider> automation_;
221 scoped_ptr<IPC::Message> reply_message_;
222 content::NavigationController* controller_;
223 int navigations_remaining_;
224 bool navigation_started_;
225 bool use_json_interface_;
227 DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver);
230 class TabStripNotificationObserver : public content::NotificationObserver {
232 TabStripNotificationObserver(int notification,
233 AutomationProvider* automation);
234 virtual ~TabStripNotificationObserver();
236 // Overridden from content::NotificationObserver:
237 virtual void Observe(int type,
238 const content::NotificationSource& source,
239 const content::NotificationDetails& details) OVERRIDE;
241 virtual void ObserveTab(content::NavigationController* controller) = 0;
244 content::NotificationRegistrar registrar_;
245 base::WeakPtr<AutomationProvider> automation_;
249 class TabAppendedNotificationObserver : public TabStripNotificationObserver {
251 TabAppendedNotificationObserver(Browser* parent,
252 AutomationProvider* automation,
253 IPC::Message* reply_message,
254 bool use_json_interface);
255 virtual ~TabAppendedNotificationObserver();
257 virtual void ObserveTab(content::NavigationController* controller);
258 IPC::Message* ReleaseReply();
262 scoped_ptr<IPC::Message> reply_message_;
263 bool use_json_interface_;
266 DISALLOW_COPY_AND_ASSIGN(TabAppendedNotificationObserver);
269 class TabClosedNotificationObserver : public TabStripNotificationObserver {
271 TabClosedNotificationObserver(AutomationProvider* automation,
272 bool wait_until_closed,
273 IPC::Message* reply_message,
274 bool use_json_interface);
275 virtual ~TabClosedNotificationObserver();
277 virtual void ObserveTab(content::NavigationController* controller);
279 void set_for_browser_command(bool for_browser_command);
282 scoped_ptr<IPC::Message> reply_message_;
283 bool use_json_interface_;
284 bool for_browser_command_;
287 DISALLOW_COPY_AND_ASSIGN(TabClosedNotificationObserver);
290 // Notifies when the tab count reaches the target number.
291 class TabCountChangeObserver : public TabStripModelObserver {
293 TabCountChangeObserver(AutomationProvider* automation,
295 IPC::Message* reply_message,
296 int target_tab_count);
297 // Implementation of TabStripModelObserver.
298 virtual void TabInsertedAt(content::WebContents* contents,
300 bool foreground) OVERRIDE;
301 virtual void TabDetachedAt(content::WebContents* contents,
303 virtual void TabStripModelDeleted() OVERRIDE;
306 virtual ~TabCountChangeObserver();
308 // Checks if the current tab count matches our target, and if so,
309 // sends the reply message and deletes self.
310 void CheckTabCount();
312 base::WeakPtr<AutomationProvider> automation_;
313 scoped_ptr<IPC::Message> reply_message_;
315 TabStripModel* tab_strip_model_;
317 const int target_tab_count_;
319 DISALLOW_COPY_AND_ASSIGN(TabCountChangeObserver);
322 // Observes when an extension has been uninstalled.
323 class ExtensionUninstallObserver : public content::NotificationObserver {
325 ExtensionUninstallObserver(AutomationProvider* automation,
326 IPC::Message* reply_message,
327 const std::string& id);
328 virtual ~ExtensionUninstallObserver();
330 // Overridden from content::NotificationObserver:
331 virtual void Observe(int type,
332 const content::NotificationSource& source,
333 const content::NotificationDetails& details) OVERRIDE;
336 content::NotificationRegistrar registrar_;
337 base::WeakPtr<AutomationProvider> automation_;
338 scoped_ptr<IPC::Message> reply_message_;
341 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallObserver);
344 // Observes when an extension has finished loading and is ready for use. Also
345 // checks for possible install errors.
346 class ExtensionReadyNotificationObserver
347 : public content::NotificationObserver {
349 // Creates an observer that replies using the JSON automation interface.
350 ExtensionReadyNotificationObserver(ExtensionProcessManager* manager,
351 ExtensionService* service,
352 AutomationProvider* automation,
353 IPC::Message* reply_message);
354 virtual ~ExtensionReadyNotificationObserver();
356 // Overridden from content::NotificationObserver:
357 virtual void Observe(int type,
358 const content::NotificationSource& source,
359 const content::NotificationDetails& details) OVERRIDE;
364 content::NotificationRegistrar registrar_;
365 ExtensionProcessManager* manager_;
366 ExtensionService* service_;
367 base::WeakPtr<AutomationProvider> automation_;
368 scoped_ptr<IPC::Message> reply_message_;
369 const extensions::Extension* extension_;
371 DISALLOW_COPY_AND_ASSIGN(ExtensionReadyNotificationObserver);
374 class ExtensionUnloadNotificationObserver
375 : public content::NotificationObserver {
377 ExtensionUnloadNotificationObserver();
378 virtual ~ExtensionUnloadNotificationObserver();
380 // Overridden from content::NotificationObserver:
381 virtual void Observe(int type,
382 const content::NotificationSource& source,
383 const content::NotificationDetails& details) OVERRIDE;
385 bool did_receive_unload_notification() {
386 return did_receive_unload_notification_;
390 content::NotificationRegistrar registrar_;
391 bool did_receive_unload_notification_;
393 DISALLOW_COPY_AND_ASSIGN(ExtensionUnloadNotificationObserver);
396 // Observes when the extensions have been fully updated. The ExtensionUpdater
397 // service provides a notification whem all the updated extensions have been
398 // installed, but it does not wait for all of them to be loaded too. This
399 // observer waits until all updated extensions have actually been loaded.
400 class ExtensionsUpdatedObserver : public content::NotificationObserver {
402 ExtensionsUpdatedObserver(ExtensionProcessManager* manager,
403 AutomationProvider* automation,
404 IPC::Message* reply_message);
405 virtual ~ExtensionsUpdatedObserver();
407 // Overridden from content::NotificationObserver:
408 virtual void Observe(int type,
409 const content::NotificationSource& source,
410 const content::NotificationDetails& details) OVERRIDE;
412 // Called by ExtensionUpdater when it has finished updating extensions.
413 void UpdateCheckFinished();
418 content::NotificationRegistrar registrar_;
419 ExtensionProcessManager* manager_;
420 base::WeakPtr<AutomationProvider> automation_;
421 scoped_ptr<IPC::Message> reply_message_;
422 bool updater_finished_;
424 DISALLOW_COPY_AND_ASSIGN(ExtensionsUpdatedObserver);
427 // Observes when a new browser has been opened and a tab within it has stopped
429 class BrowserOpenedNotificationObserver : public content::NotificationObserver {
431 BrowserOpenedNotificationObserver(AutomationProvider* automation,
432 IPC::Message* reply_message,
433 bool use_json_interface);
434 virtual ~BrowserOpenedNotificationObserver();
436 // Overridden from content::NotificationObserver:
437 virtual void Observe(int type,
438 const content::NotificationSource& source,
439 const content::NotificationDetails& details) OVERRIDE;
441 void set_for_browser_command(bool for_browser_command);
444 content::NotificationRegistrar registrar_;
445 base::WeakPtr<AutomationProvider> automation_;
446 scoped_ptr<IPC::Message> reply_message_;
448 bool use_json_interface_;
449 bool for_browser_command_;
451 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedNotificationObserver);
454 class BrowserClosedNotificationObserver : public content::NotificationObserver {
456 BrowserClosedNotificationObserver(Browser* browser,
457 AutomationProvider* automation,
458 IPC::Message* reply_message,
459 bool use_json_interface);
460 virtual ~BrowserClosedNotificationObserver();
462 // Overridden from content::NotificationObserver:
463 virtual void Observe(int type,
464 const content::NotificationSource& source,
465 const content::NotificationDetails& details) OVERRIDE;
467 void set_for_browser_command(bool for_browser_command);
470 content::NotificationRegistrar registrar_;
471 base::WeakPtr<AutomationProvider> automation_;
472 scoped_ptr<IPC::Message> reply_message_;
473 bool use_json_interface_;
474 bool for_browser_command_;
476 DISALLOW_COPY_AND_ASSIGN(BrowserClosedNotificationObserver);
479 class BrowserCountChangeNotificationObserver
480 : public content::NotificationObserver {
482 BrowserCountChangeNotificationObserver(int target_count,
483 AutomationProvider* automation,
484 IPC::Message* reply_message);
485 virtual ~BrowserCountChangeNotificationObserver();
487 // Overridden from content::NotificationObserver:
488 virtual void Observe(int type,
489 const content::NotificationSource& source,
490 const content::NotificationDetails& details) OVERRIDE;
494 content::NotificationRegistrar registrar_;
495 base::WeakPtr<AutomationProvider> automation_;
496 scoped_ptr<IPC::Message> reply_message_;
498 DISALLOW_COPY_AND_ASSIGN(BrowserCountChangeNotificationObserver);
501 class ExecuteBrowserCommandObserver : public content::NotificationObserver {
503 virtual ~ExecuteBrowserCommandObserver();
505 static bool CreateAndRegisterObserver(AutomationProvider* automation,
508 IPC::Message* reply_message,
509 bool use_json_interface);
511 // Overridden from content::NotificationObserver:
512 virtual void Observe(int type,
513 const content::NotificationSource& source,
514 const content::NotificationDetails& details) OVERRIDE;
517 ExecuteBrowserCommandObserver(AutomationProvider* automation,
518 IPC::Message* reply_message,
519 bool use_json_interface);
521 bool Register(int command);
523 bool Getint(int command, int* type);
525 IPC::Message* ReleaseReply();
527 content::NotificationRegistrar registrar_;
528 base::WeakPtr<AutomationProvider> automation_;
529 int notification_type_;
530 scoped_ptr<IPC::Message> reply_message_;
531 bool use_json_interface_;
533 DISALLOW_COPY_AND_ASSIGN(ExecuteBrowserCommandObserver);
536 class FindInPageNotificationObserver : public content::NotificationObserver {
538 FindInPageNotificationObserver(AutomationProvider* automation,
539 content::WebContents* parent_tab,
540 bool reply_with_json,
541 IPC::Message* reply_message);
542 virtual ~FindInPageNotificationObserver();
544 // Overridden from content::NotificationObserver:
545 virtual void Observe(int type,
546 const content::NotificationSource& source,
547 const content::NotificationDetails& details) OVERRIDE;
549 // The Find mechanism is over asynchronous IPC, so a search is kicked off and
550 // we wait for notification to find out what the results are. As the user is
551 // typing, new search requests can be issued and the Request ID helps us make
552 // sense of whether this is the current request or an old one. The unit tests,
553 // however, which uses this constant issues only one search at a time, so we
554 // don't need a rolling id to identify each search. But, we still need to
555 // specify one, so we just use a fixed one - its value does not matter.
556 static const int kFindInPageRequestId;
559 content::NotificationRegistrar registrar_;
560 base::WeakPtr<AutomationProvider> automation_;
561 // We will at some point (before final update) be notified of the ordinal and
562 // we need to preserve it so we can send it later.
563 int active_match_ordinal_;
564 // Send reply using json automation interface.
565 bool reply_with_json_;
566 scoped_ptr<IPC::Message> reply_message_;
568 DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
571 class DomOperationObserver : public content::NotificationObserver {
573 explicit DomOperationObserver(int automation_id);
574 virtual ~DomOperationObserver();
576 // Overridden from content::NotificationObserver:
577 virtual void Observe(int type,
578 const content::NotificationSource& source,
579 const content::NotificationDetails& details) OVERRIDE;
581 virtual void OnDomOperationCompleted(const std::string& json) = 0;
582 virtual void OnJavascriptBlocked() = 0;
586 content::NotificationRegistrar registrar_;
588 DISALLOW_COPY_AND_ASSIGN(DomOperationObserver);
591 // Sends a message back to the automation client with the results of the DOM
593 class DomOperationMessageSender : public DomOperationObserver {
595 DomOperationMessageSender(AutomationProvider* automation,
596 IPC::Message* reply_message,
597 bool use_json_interface);
598 virtual ~DomOperationMessageSender();
600 virtual void OnDomOperationCompleted(const std::string& json) OVERRIDE;
601 virtual void OnJavascriptBlocked() OVERRIDE;
604 base::WeakPtr<AutomationProvider> automation_;
605 scoped_ptr<IPC::Message> reply_message_;
606 bool use_json_interface_;
608 DISALLOW_COPY_AND_ASSIGN(DomOperationMessageSender);
611 // Collects METRIC_EVENT_DURATION notifications and keep track of the times.
612 class MetricEventDurationObserver : public content::NotificationObserver {
614 MetricEventDurationObserver();
615 virtual ~MetricEventDurationObserver();
617 // Get the duration of an event. Returns -1 if we haven't seen the event.
618 int GetEventDurationMs(const std::string& event_name);
620 // Overridden from content::NotificationObserver:
621 virtual void Observe(int type,
622 const content::NotificationSource& source,
623 const content::NotificationDetails& details) OVERRIDE;
626 content::NotificationRegistrar registrar_;
628 typedef std::map<std::string, int> EventDurationMap;
629 EventDurationMap durations_;
631 DISALLOW_COPY_AND_ASSIGN(MetricEventDurationObserver);
634 class InfoBarCountObserver : public content::NotificationObserver {
636 InfoBarCountObserver(AutomationProvider* automation,
637 IPC::Message* reply_message,
638 content::WebContents* web_contents,
639 size_t target_count);
640 virtual ~InfoBarCountObserver();
642 // Overridden from content::NotificationObserver:
643 virtual void Observe(int type,
644 const content::NotificationSource& source,
645 const content::NotificationDetails& details) OVERRIDE;
648 // Checks whether the infobar count matches our target, and if so
649 // sends the reply message and deletes itself.
652 content::NotificationRegistrar registrar_;
653 base::WeakPtr<AutomationProvider> automation_;
654 scoped_ptr<IPC::Message> reply_message_;
655 content::WebContents* web_contents_;
657 const size_t target_count_;
659 DISALLOW_COPY_AND_ASSIGN(InfoBarCountObserver);
662 #if defined(OS_CHROMEOS)
663 class LoginObserver : public chromeos::LoginStatusConsumer {
665 LoginObserver(chromeos::ExistingUserController* controller,
666 AutomationProvider* automation,
667 IPC::Message* reply_message);
669 virtual ~LoginObserver();
671 virtual void OnLoginFailure(const chromeos::LoginFailure& error);
673 virtual void OnLoginSuccess(const chromeos::UserContext& user_context);
676 chromeos::ExistingUserController* controller_;
677 base::WeakPtr<AutomationProvider> automation_;
678 scoped_ptr<IPC::Message> reply_message_;
680 DISALLOW_COPY_AND_ASSIGN(LoginObserver);
683 // Waits for a screen change notification from WizardController.
684 class WizardControllerObserver : public chromeos::WizardController::Observer,
685 public content::NotificationObserver {
687 WizardControllerObserver(chromeos::WizardController* wizard_controller,
688 AutomationProvider* automation,
689 IPC::Message* reply_message);
690 virtual ~WizardControllerObserver();
692 // If non-empty, waits for a specific change to screen with this name.
693 std::string screen_to_wait_for() { return screen_to_wait_for_; }
694 void set_screen_to_wait_for(const std::string& screen_name) {
695 screen_to_wait_for_ = screen_name;
699 // chromeos::WizardController::Observer overrides:
700 virtual void OnScreenChanged(chromeos::WizardScreen* next_screen) OVERRIDE;
701 virtual void OnSessionStart() OVERRIDE;
703 // content::NotificationObserver overrides:
704 void Observe(int type,
705 const content::NotificationSource& source,
706 const content::NotificationDetails& details);
708 // Sends reply with the given screen name and deletes |this|.
709 void SendReply(const std::string& screen_name);
711 content::NotificationRegistrar registrar_;
712 chromeos::WizardController* wizard_controller_;
713 base::WeakPtr<AutomationProvider> automation_;
714 scoped_ptr<IPC::Message> reply_message_;
715 std::string screen_to_wait_for_;
717 DISALLOW_COPY_AND_ASSIGN(WizardControllerObserver);
720 // Collects SCREEN_LOCK_STATE_CHANGED notifications and returns
721 // whether authentication succeeded to the automation provider.
722 class ScreenLockUnlockObserver : public content::NotificationObserver {
724 // Set lock_screen to true to observe lock screen events,
725 // false for unlock screen events.
726 ScreenLockUnlockObserver(AutomationProvider* automation,
727 IPC::Message* reply_message,
729 virtual ~ScreenLockUnlockObserver();
731 // Overridden from content::NotificationObserver:
732 virtual void Observe(int type,
733 const content::NotificationSource& source,
734 const content::NotificationDetails& details) OVERRIDE;
737 base::WeakPtr<AutomationProvider> automation_;
738 scoped_ptr<IPC::Message> reply_message_;
741 content::NotificationRegistrar registrar_;
744 DISALLOW_COPY_AND_ASSIGN(ScreenLockUnlockObserver);
747 // Watches SCREEN_LOCK_STATE_CHANGED notifications like the
748 // ScreenLockUnlockObserver, but additionally adds itself as an observer
749 // to a screen locker in order to monitor unlock failure cases.
750 class ScreenUnlockObserver : public ScreenLockUnlockObserver,
751 public chromeos::LoginStatusConsumer {
753 ScreenUnlockObserver(AutomationProvider* automation,
754 IPC::Message* reply_message);
755 virtual ~ScreenUnlockObserver();
757 virtual void OnLoginFailure(const chromeos::LoginFailure& error);
759 virtual void OnLoginSuccess(const chromeos::UserContext& user_context) {}
762 DISALLOW_COPY_AND_ASSIGN(ScreenUnlockObserver);
765 #endif // defined(OS_CHROMEOS)
767 // Waits for the bookmark model to load.
768 class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver {
770 AutomationProviderBookmarkModelObserver(AutomationProvider* provider,
771 IPC::Message* reply_message,
772 BookmarkModel* model,
773 bool use_json_interface);
774 virtual ~AutomationProviderBookmarkModelObserver();
776 // BookmarkModelObserver:
777 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
778 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
779 virtual void BookmarkNodeMoved(BookmarkModel* model,
780 const BookmarkNode* old_parent,
782 const BookmarkNode* new_parent,
783 int new_index) OVERRIDE {}
784 virtual void BookmarkNodeAdded(BookmarkModel* model,
785 const BookmarkNode* parent,
786 int index) OVERRIDE {}
787 virtual void BookmarkNodeRemoved(BookmarkModel* model,
788 const BookmarkNode* parent,
790 const BookmarkNode* node) OVERRIDE {}
791 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) OVERRIDE {}
792 virtual void BookmarkNodeChanged(BookmarkModel* model,
793 const BookmarkNode* node) OVERRIDE {}
794 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
795 const BookmarkNode* node) OVERRIDE {}
796 virtual void BookmarkNodeChildrenReordered(
797 BookmarkModel* model,
798 const BookmarkNode* node) OVERRIDE {}
800 IPC::Message* ReleaseReply();
803 // Reply to the automation message with the given success value,
804 // then delete myself (which removes myself from the bookmark model
806 void ReplyAndDelete(bool success);
808 base::WeakPtr<AutomationProvider> automation_provider_;
809 scoped_ptr<IPC::Message> reply_message_;
810 BookmarkModel* model_;
811 bool use_json_interface_;
813 DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver);
816 // Allows the automation provider to wait until the download has been updated
818 class AutomationProviderDownloadUpdatedObserver
819 : public content::DownloadItem::Observer {
821 AutomationProviderDownloadUpdatedObserver(
822 AutomationProvider* provider,
823 IPC::Message* reply_message,
826 virtual ~AutomationProviderDownloadUpdatedObserver();
828 virtual void OnDownloadUpdated(content::DownloadItem* download);
829 virtual void OnDownloadOpened(content::DownloadItem* download);
832 base::WeakPtr<AutomationProvider> provider_;
833 scoped_ptr<IPC::Message> reply_message_;
837 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadUpdatedObserver);
840 // Allows the automation provider to wait until the download model has changed
841 // (because a new download has been added or removed).
842 class AutomationProviderDownloadModelChangedObserver
843 : public AllDownloadItemNotifier::Observer {
845 AutomationProviderDownloadModelChangedObserver(
846 AutomationProvider* provider,
847 IPC::Message* reply_message,
848 content::DownloadManager* download_manager);
849 virtual ~AutomationProviderDownloadModelChangedObserver();
851 virtual void OnDownloadCreated(
852 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
853 virtual void OnDownloadRemoved(
854 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
859 base::WeakPtr<AutomationProvider> provider_;
860 scoped_ptr<IPC::Message> reply_message_;
861 AllDownloadItemNotifier notifier_;
863 DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver);
866 // Observes when all pending downloads have completed.
867 class AllDownloadsCompleteObserver
868 : public content::DownloadManager::Observer,
869 public content::DownloadItem::Observer {
871 AllDownloadsCompleteObserver(
872 AutomationProvider* provider,
873 IPC::Message* reply_message,
874 content::DownloadManager* download_manager,
875 ListValue* pre_download_ids);
876 virtual ~AllDownloadsCompleteObserver();
878 // content::DownloadManager::Observer.
879 virtual void OnDownloadCreated(
880 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
881 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE;
883 // content::DownloadItem::Observer.
884 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
887 void ReplyIfNecessary();
889 base::WeakPtr<AutomationProvider> provider_;
890 scoped_ptr<IPC::Message> reply_message_;
891 content::DownloadManager* download_manager_;
892 std::set<int> pre_download_ids_;
893 std::set<content::DownloadItem*> pending_downloads_;
895 DISALLOW_COPY_AND_ASSIGN(AllDownloadsCompleteObserver);
898 // Allows automation provider to wait until TemplateURLService has loaded
899 // before looking up/returning search engine info.
900 class AutomationProviderSearchEngineObserver
901 : public TemplateURLServiceObserver {
903 AutomationProviderSearchEngineObserver(
904 AutomationProvider* provider,
906 IPC::Message* reply_message);
907 virtual ~AutomationProviderSearchEngineObserver();
909 virtual void OnTemplateURLServiceChanged();
912 base::WeakPtr<AutomationProvider> provider_;
914 scoped_ptr<IPC::Message> reply_message_;
916 DISALLOW_COPY_AND_ASSIGN(AutomationProviderSearchEngineObserver);
919 // Allows the automation provider to wait for history queries to finish.
920 class AutomationProviderHistoryObserver {
922 AutomationProviderHistoryObserver(
923 AutomationProvider* provider,
924 IPC::Message* reply_message);
925 virtual ~AutomationProviderHistoryObserver();
927 void HistoryQueryComplete(HistoryService::Handle request_handle,
928 history::QueryResults* results);
931 base::WeakPtr<AutomationProvider> provider_;
932 scoped_ptr<IPC::Message> reply_message_;
935 // Allows the automation provider to wait for import queries to finish.
936 class AutomationProviderImportSettingsObserver
937 : public importer::ImporterProgressObserver {
939 AutomationProviderImportSettingsObserver(
940 AutomationProvider* provider,
941 IPC::Message* reply_message);
942 virtual ~AutomationProviderImportSettingsObserver();
944 // importer::ImporterProgressObserver:
945 virtual void ImportStarted() OVERRIDE;
946 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE;
947 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE;
948 virtual void ImportEnded() OVERRIDE;
951 base::WeakPtr<AutomationProvider> provider_;
952 scoped_ptr<IPC::Message> reply_message_;
955 // Allows automation provider to wait for getting passwords to finish.
956 class AutomationProviderGetPasswordsObserver : public PasswordStoreConsumer {
958 AutomationProviderGetPasswordsObserver(
959 AutomationProvider* provider,
960 IPC::Message* reply_message);
961 virtual ~AutomationProviderGetPasswordsObserver();
963 // PasswordStoreConsumer implementation.
964 virtual void OnPasswordStoreRequestDone(
965 CancelableRequestProvider::Handle handle,
966 const std::vector<autofill::PasswordForm*>& result) OVERRIDE;
967 virtual void OnGetPasswordStoreResults(
968 const std::vector<autofill::PasswordForm*>& results) OVERRIDE;
971 base::WeakPtr<AutomationProvider> provider_;
972 scoped_ptr<IPC::Message> reply_message_;
975 // Observes when login entries stored in the password store are changed. The
976 // notifications are sent on the DB thread, the thread that interacts with the
978 class PasswordStoreLoginsChangedObserver
979 : public base::RefCountedThreadSafe<
980 PasswordStoreLoginsChangedObserver,
981 content::BrowserThread::DeleteOnUIThread>,
982 public content::NotificationObserver {
984 PasswordStoreLoginsChangedObserver(AutomationProvider* automation,
985 IPC::Message* reply_message,
986 PasswordStoreChange::Type expected_type,
987 const std::string& result_key);
989 // Schedules a task on the DB thread to register the appropriate observers.
992 // Overridden from content::NotificationObserver:
993 virtual void Observe(int type,
994 const content::NotificationSource& source,
995 const content::NotificationDetails& details) OVERRIDE;
998 friend struct content::BrowserThread::DeleteOnThread<
999 content::BrowserThread::UI>;
1000 ~PasswordStoreLoginsChangedObserver();
1001 friend class base::DeleteHelper<PasswordStoreLoginsChangedObserver>;
1003 // Registers the appropriate observers. Called on the DB thread.
1004 void RegisterObserversTask();
1006 // Sends the |reply_message_| to |automation_| indicating we're done. Called
1007 // on the UI thread.
1008 void IndicateDone();
1010 // Sends an error reply to |automation_|. Called on the UI thread.
1011 void IndicateError(const std::string& error);
1013 base::WeakPtr<AutomationProvider> automation_;
1014 scoped_ptr<IPC::Message> reply_message_;
1015 scoped_ptr<content::NotificationRegistrar> registrar_;
1016 PasswordStoreChange::Type expected_type_;
1017 std::string result_key_;
1019 // Used to ensure that the UI thread waits for the DB thread to finish
1020 // registering observers before proceeding.
1021 base::WaitableEvent done_event_;
1023 DISALLOW_COPY_AND_ASSIGN(PasswordStoreLoginsChangedObserver);
1026 // Allows automation provider to wait until page load after selecting an item
1027 // in the omnibox popup.
1028 class OmniboxAcceptNotificationObserver : public content::NotificationObserver {
1030 OmniboxAcceptNotificationObserver(content::NavigationController* controller,
1031 AutomationProvider* automation,
1032 IPC::Message* reply_message);
1033 virtual ~OmniboxAcceptNotificationObserver();
1035 // Overridden from content::NotificationObserver:
1036 virtual void Observe(int type,
1037 const content::NotificationSource& source,
1038 const content::NotificationDetails& details) OVERRIDE;
1041 content::NotificationRegistrar registrar_;
1042 base::WeakPtr<AutomationProvider> automation_;
1043 scoped_ptr<IPC::Message> reply_message_;
1044 content::NavigationController* controller_;
1046 DISALLOW_COPY_AND_ASSIGN(OmniboxAcceptNotificationObserver);
1049 // Allows the automation provider to wait for a save package notification.
1050 class SavePackageNotificationObserver
1051 : public content::DownloadManager::Observer {
1053 SavePackageNotificationObserver(content::DownloadManager* download_manager,
1054 AutomationProvider* automation,
1055 IPC::Message* reply_message);
1056 virtual ~SavePackageNotificationObserver();
1058 // Overridden from content::DownloadManager::Observer:
1059 virtual void OnSavePackageSuccessfullyFinished(
1060 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE;
1061 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE;
1064 content::DownloadManager* download_manager_;
1065 base::WeakPtr<AutomationProvider> automation_;
1066 scoped_ptr<IPC::Message> reply_message_;
1068 DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver);
1071 class NTPInfoObserver : public content::NotificationObserver {
1073 NTPInfoObserver(AutomationProvider* automation, IPC::Message* reply_message);
1074 virtual ~NTPInfoObserver();
1076 // Overridden from content::NotificationObserver:
1077 virtual void Observe(int type,
1078 const content::NotificationSource& source,
1079 const content::NotificationDetails& details) OVERRIDE;
1082 void OnTopSitesLoaded();
1083 void OnTopSitesReceived(const history::MostVisitedURLList& visited_list);
1085 base::WeakPtr<AutomationProvider> automation_;
1086 scoped_ptr<IPC::Message> reply_message_;
1087 CancelableRequestProvider::Handle request_;
1088 scoped_ptr<base::DictionaryValue> ntp_info_;
1089 history::TopSites* top_sites_;
1090 content::NotificationRegistrar registrar_;
1092 DISALLOW_COPY_AND_ASSIGN(NTPInfoObserver);
1095 // Observes when an app has been launched, as indicated by a notification that
1096 // a content load in some tab has stopped.
1097 class AppLaunchObserver : public content::NotificationObserver {
1099 AppLaunchObserver(content::NavigationController* controller,
1100 AutomationProvider* automation,
1101 IPC::Message* reply_message,
1102 extension_misc::LaunchContainer launch_container);
1103 virtual ~AppLaunchObserver();
1105 // Overridden from content::NotificationObserver:
1106 virtual void Observe(int type,
1107 const content::NotificationSource& source,
1108 const content::NotificationDetails& details) OVERRIDE;
1111 content::NavigationController* controller_;
1112 base::WeakPtr<AutomationProvider> automation_;
1113 scoped_ptr<IPC::Message> reply_message_;
1114 content::NotificationRegistrar registrar_;
1115 extension_misc::LaunchContainer launch_container_;
1118 DISALLOW_COPY_AND_ASSIGN(AppLaunchObserver);
1121 // Allows the automation provider to wait until all the notification
1122 // processes are ready.
1123 class GetAllNotificationsObserver : public content::NotificationObserver {
1125 GetAllNotificationsObserver(AutomationProvider* automation,
1126 IPC::Message* reply_message);
1127 virtual ~GetAllNotificationsObserver();
1129 // Overridden from content::NotificationObserver:
1130 virtual void Observe(int type,
1131 const content::NotificationSource& source,
1132 const content::NotificationDetails& details) OVERRIDE;
1135 // Sends a message via the |AutomationProvider|. |automation_| must be valid.
1136 // Deletes itself after the message is sent.
1138 // Returns a new dictionary describing the given notification.
1139 base::DictionaryValue* NotificationToJson(const Notification* note);
1141 content::NotificationRegistrar registrar_;
1142 base::WeakPtr<AutomationProvider> automation_;
1143 scoped_ptr<IPC::Message> reply_message_;
1145 DISALLOW_COPY_AND_ASSIGN(GetAllNotificationsObserver);
1148 // Allows the automation provider to wait for a new notification balloon
1149 // to appear and be ready.
1150 class NewNotificationBalloonObserver : public content::NotificationObserver {
1152 NewNotificationBalloonObserver(AutomationProvider* provider,
1153 IPC::Message* reply_message);
1154 virtual ~NewNotificationBalloonObserver();
1156 // Overridden from content::NotificationObserver:
1157 virtual void Observe(int type,
1158 const content::NotificationSource& source,
1159 const content::NotificationDetails& details) OVERRIDE;
1162 content::NotificationRegistrar registrar_;
1163 base::WeakPtr<AutomationProvider> automation_;
1164 scoped_ptr<IPC::Message> reply_message_;
1166 DISALLOW_COPY_AND_ASSIGN(NewNotificationBalloonObserver);
1169 // Allows the automation provider to wait for a given number of
1170 // notification balloons.
1171 class OnNotificationBalloonCountObserver
1172 : public content::NotificationObserver {
1174 OnNotificationBalloonCountObserver(AutomationProvider* provider,
1175 IPC::Message* reply_message,
1177 virtual ~OnNotificationBalloonCountObserver();
1179 // Sends an automation reply message if |automation_| is still valid and the
1180 // number of ready balloons matches the desired count. Deletes itself if the
1181 // message is sent or if |automation_| is invalid.
1182 void CheckBalloonCount();
1184 // Overridden from content::NotificationObserver:
1185 virtual void Observe(int type,
1186 const content::NotificationSource& source,
1187 const content::NotificationDetails& details) OVERRIDE;
1190 content::NotificationRegistrar registrar_;
1191 base::WeakPtr<AutomationProvider> automation_;
1192 scoped_ptr<IPC::Message> reply_message_;
1194 BalloonCollection* collection_;
1197 DISALLOW_COPY_AND_ASSIGN(OnNotificationBalloonCountObserver);
1200 // Allows the automation provider to wait for a RENDERER_PROCESS_CLOSED
1202 class RendererProcessClosedObserver : public content::NotificationObserver {
1204 RendererProcessClosedObserver(AutomationProvider* automation,
1205 IPC::Message* reply_message);
1206 virtual ~RendererProcessClosedObserver();
1208 // Overridden from content::NotificationObserver:
1209 virtual void Observe(int type,
1210 const content::NotificationSource& source,
1211 const content::NotificationDetails& details) OVERRIDE;
1214 content::NotificationRegistrar registrar_;
1215 base::WeakPtr<AutomationProvider> automation_;
1216 scoped_ptr<IPC::Message> reply_message_;
1218 DISALLOW_COPY_AND_ASSIGN(RendererProcessClosedObserver);
1221 // Allows the automation provider to wait for acknowledgement that a certain
1222 // type and number of input events has been processed by the renderer.
1223 class InputEventAckNotificationObserver : public content::NotificationObserver {
1225 InputEventAckNotificationObserver(AutomationProvider* automation,
1226 IPC::Message* reply_message,
1227 int event_type, int count);
1228 virtual ~InputEventAckNotificationObserver();
1230 // Overridden from content::NotificationObserver:
1231 virtual void Observe(int type,
1232 const content::NotificationSource& source,
1233 const content::NotificationDetails& details) OVERRIDE;
1236 content::NotificationRegistrar registrar_;
1237 base::WeakPtr<AutomationProvider> automation_;
1238 scoped_ptr<IPC::Message> reply_message_;
1242 DISALLOW_COPY_AND_ASSIGN(InputEventAckNotificationObserver);
1245 // Observer used to listen for new tab creation to complete.
1246 class NewTabObserver : public content::NotificationObserver {
1248 NewTabObserver(AutomationProvider* automation,
1249 IPC::Message* reply_message,
1250 bool use_json_interface);
1252 // Overridden from content::NotificationObserver:
1253 virtual void Observe(int type,
1254 const content::NotificationSource& source,
1255 const content::NotificationDetails& details) OVERRIDE;
1258 virtual ~NewTabObserver();
1260 content::NotificationRegistrar registrar_;
1261 base::WeakPtr<AutomationProvider> automation_;
1262 scoped_ptr<IPC::Message> reply_message_;
1263 bool use_json_interface_;
1265 DISALLOW_COPY_AND_ASSIGN(NewTabObserver);
1268 // Posts a task to the PROCESS_LAUNCHER thread, once processed posts a task
1269 // back to the UI thread that notifies the provider we're done.
1270 class WaitForProcessLauncherThreadToGoIdleObserver
1271 : public base::RefCountedThreadSafe<
1272 WaitForProcessLauncherThreadToGoIdleObserver,
1273 content::BrowserThread::DeleteOnUIThread> {
1275 WaitForProcessLauncherThreadToGoIdleObserver(
1276 AutomationProvider* automation, IPC::Message* reply_message);
1279 friend struct content::BrowserThread::DeleteOnThread<
1280 content::BrowserThread::UI>;
1281 friend class base::DeleteHelper<WaitForProcessLauncherThreadToGoIdleObserver>;
1283 virtual ~WaitForProcessLauncherThreadToGoIdleObserver();
1285 // Schedules a task on the PROCESS_LAUNCHER thread to execute
1286 // |RunOnProcessLauncherThread2|. By the time the task is executed the
1287 // PROCESS_LAUNCHER thread should be some what idle.
1288 void RunOnProcessLauncherThread();
1290 // When executed the PROCESS_LAUNCHER thread should have processed any pending
1291 // tasks. Schedules a task on the UI thread that sends the message saying
1293 void RunOnProcessLauncherThread2();
1295 // Sends the |reply_message_| to |automation_| indicating we're done.
1296 void RunOnUIThread();
1298 base::WeakPtr<AutomationProvider> automation_;
1299 scoped_ptr<IPC::Message> reply_message_;
1301 DISALLOW_COPY_AND_ASSIGN(WaitForProcessLauncherThreadToGoIdleObserver);
1304 // Allows the automation provider to wait for acknowledgement that a drop
1305 // operation has been processed by the renderer.
1306 class DragTargetDropAckNotificationObserver
1307 : public content::NotificationObserver {
1309 DragTargetDropAckNotificationObserver(AutomationProvider* automation,
1310 IPC::Message* reply_message);
1311 virtual ~DragTargetDropAckNotificationObserver();
1313 // Overridden from content::NotificationObserver:
1314 virtual void Observe(int type,
1315 const content::NotificationSource& source,
1316 const content::NotificationDetails& details) OVERRIDE;
1319 content::NotificationRegistrar registrar_;
1320 base::WeakPtr<AutomationProvider> automation_;
1321 scoped_ptr<IPC::Message> reply_message_;
1323 DISALLOW_COPY_AND_ASSIGN(DragTargetDropAckNotificationObserver);
1326 // Allows the automation provider to wait for process memory details to be
1327 // available before sending this information to the client.
1328 class ProcessInfoObserver : public MemoryDetails {
1330 ProcessInfoObserver(AutomationProvider* automation,
1331 IPC::Message* reply_message);
1333 virtual void OnDetailsAvailable() OVERRIDE;
1336 virtual ~ProcessInfoObserver();
1337 base::WeakPtr<AutomationProvider> automation_;
1338 scoped_ptr<IPC::Message> reply_message_;
1340 DISALLOW_COPY_AND_ASSIGN(ProcessInfoObserver);
1343 // Observes when new v8 heap statistics are computed for a renderer process.
1344 class V8HeapStatsObserver : public content::NotificationObserver {
1346 V8HeapStatsObserver(AutomationProvider* automation,
1347 IPC::Message* reply_message,
1348 base::ProcessId renderer_id);
1349 virtual ~V8HeapStatsObserver();
1351 // Overridden from content::NotificationObserver:
1352 virtual void Observe(int type,
1353 const content::NotificationSource& source,
1354 const content::NotificationDetails& details) OVERRIDE;
1357 content::NotificationRegistrar registrar_;
1358 base::WeakPtr<AutomationProvider> automation_;
1359 scoped_ptr<IPC::Message> reply_message_;
1360 base::ProcessId renderer_id_;
1362 DISALLOW_COPY_AND_ASSIGN(V8HeapStatsObserver);
1365 // Observes when a new FPS value is computed for a renderer process.
1366 class FPSObserver : public content::NotificationObserver {
1368 FPSObserver(AutomationProvider* automation,
1369 IPC::Message* reply_message,
1370 base::ProcessId renderer_id,
1372 virtual ~FPSObserver();
1374 // Overridden from content::NotificationObserver:
1375 virtual void Observe(int type,
1376 const content::NotificationSource& source,
1377 const content::NotificationDetails& details) OVERRIDE;
1380 content::NotificationRegistrar registrar_;
1381 base::WeakPtr<AutomationProvider> automation_;
1382 scoped_ptr<IPC::Message> reply_message_;
1383 base::ProcessId renderer_id_;
1386 DISALLOW_COPY_AND_ASSIGN(FPSObserver);
1389 // Manages the process of creating a new Profile and opening a new browser with
1390 // that profile. This observer should be created, and then a new Profile
1391 // should be created through the ProfileManager using
1392 // profile_manager->CreateMultiProfileAsync(). The Observer watches for profile
1393 // creation, upon which it creates a new browser window; after observing
1394 // window creation, it creates a new tab and then finally observes it finish
1396 class BrowserOpenedWithNewProfileNotificationObserver
1397 : public content::NotificationObserver {
1399 BrowserOpenedWithNewProfileNotificationObserver(
1400 AutomationProvider* automation,
1401 IPC::Message* reply_message);
1402 virtual ~BrowserOpenedWithNewProfileNotificationObserver();
1404 // Overridden from content::NotificationObserver:
1405 virtual void Observe(int type,
1406 const content::NotificationSource& source,
1407 const content::NotificationDetails& details) OVERRIDE;
1410 content::NotificationRegistrar registrar_;
1411 base::WeakPtr<AutomationProvider> automation_;
1412 scoped_ptr<IPC::Message> reply_message_;
1415 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedWithNewProfileNotificationObserver);
1418 // Waits for an extension popup to appear and load.
1419 class ExtensionPopupObserver : public content::NotificationObserver {
1421 ExtensionPopupObserver(
1422 AutomationProvider* automation,
1423 IPC::Message* reply_message,
1424 const std::string& extension_id);
1425 ~ExtensionPopupObserver();
1427 // Overridden from content::NotificationObserver:
1428 virtual void Observe(int type,
1429 const content::NotificationSource& source,
1430 const content::NotificationDetails& details) OVERRIDE;
1433 base::WeakPtr<AutomationProvider> automation_;
1434 scoped_ptr<IPC::Message> reply_message_;
1435 std::string extension_id_;
1436 content::NotificationRegistrar registrar_;
1438 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupObserver);
1441 #if defined(OS_LINUX)
1442 // Allows the automation provider to wait for a WINDOW_MAXIMIZED notification.
1443 class WindowMaximizedObserver : public content::NotificationObserver {
1445 WindowMaximizedObserver(AutomationProvider* automation,
1446 IPC::Message* reply_message);
1447 virtual ~WindowMaximizedObserver();
1449 // Overridden from content::NotificationObserver:
1450 virtual void Observe(int type,
1451 const content::NotificationSource& source,
1452 const content::NotificationDetails& details) OVERRIDE;
1455 content::NotificationRegistrar registrar_;
1456 base::WeakPtr<AutomationProvider> automation_;
1457 scoped_ptr<IPC::Message> reply_message_;
1459 DISALLOW_COPY_AND_ASSIGN(WindowMaximizedObserver);
1461 #endif // defined(OS_LINUX)
1463 // Wait for a new browser window to get created (for an existing profile).
1464 // Useful when reopening a multi-profile window.
1465 class BrowserOpenedWithExistingProfileNotificationObserver
1466 : public content::NotificationObserver {
1468 BrowserOpenedWithExistingProfileNotificationObserver(
1469 AutomationProvider* automation,
1470 IPC::Message* reply_message,
1472 virtual ~BrowserOpenedWithExistingProfileNotificationObserver();
1474 virtual void Observe(int type,
1475 const content::NotificationSource& source,
1476 const content::NotificationDetails& details);
1478 content::NotificationRegistrar registrar_;
1479 base::WeakPtr<AutomationProvider> automation_;
1480 scoped_ptr<IPC::Message> reply_message_;
1484 DISALLOW_COPY_AND_ASSIGN(
1485 BrowserOpenedWithExistingProfileNotificationObserver);
1488 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_