diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 04:50:52 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 04:50:52 +0000 |
commit | 1061321d6cd733eae7633bde7deb5eb1d6cbf3d0 (patch) | |
tree | 2ed062b45e39e049b73bdd6cfaea8ffc397479bd /chrome/browser/automation | |
parent | dd5684a027e4a3b2d74cb9eeebfb039171008503 (diff) | |
download | chromium_src-1061321d6cd733eae7633bde7deb5eb1d6cbf3d0.zip chromium_src-1061321d6cd733eae7633bde7deb5eb1d6cbf3d0.tar.gz chromium_src-1061321d6cd733eae7633bde7deb5eb1d6cbf3d0.tar.bz2 |
Reverting 7581.
Review URL: http://codereview.chromium.org/17069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7582 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 22 | ||||
-rw-r--r-- | chrome/browser/automation/automation_tab_tracker.h | 42 |
2 files changed, 36 insertions, 28 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index ec31959..ff96f55f0 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -29,7 +29,6 @@ #include "chrome/browser/views/bookmark_bar_view.h" #include "chrome/browser/views/location_bar_view.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/notification_registrar.h" #include "chrome/common/pref_service.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/views/app_modal_dialog_delegate.h" @@ -46,21 +45,30 @@ class InitialLoadObserver : public NotificationObserver { automation_(automation) { if (outstanding_tab_count_ > 0) { NotificationService* service = NotificationService::current(); - registrar_.Add(this, NOTIFY_LOAD_START, - NotificationService::AllSources()); - registrar_.Add(this, NOTIFY_LOAD_STOP, - NotificationService::AllSources()); + service->AddObserver(this, NOTIFY_LOAD_START, + NotificationService::AllSources()); + service->AddObserver(this, NOTIFY_LOAD_STOP, + NotificationService::AllSources()); } } ~InitialLoadObserver() { + Unregister(); } void ConditionMet() { - registrar_.RemoveAll(); + Unregister(); automation_->Send(new AutomationMsg_InitialLoadsComplete(0)); } + void Unregister() { + NotificationService* service = NotificationService::current(); + service->RemoveObserver(this, NOTIFY_LOAD_START, + NotificationService::AllSources()); + service->RemoveObserver(this, NOTIFY_LOAD_STOP, + NotificationService::AllSources()); + } + virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { @@ -82,8 +90,6 @@ class InitialLoadObserver : public NotificationObserver { private: typedef std::set<uintptr_t> TabSet; - NotificationRegistrar registrar_; - AutomationProvider* automation_; size_t outstanding_tab_count_; TabSet loading_tabs_; diff --git a/chrome/browser/automation/automation_tab_tracker.h b/chrome/browser/automation/automation_tab_tracker.h index 1033ad0..9e0c63c 100644 --- a/chrome/browser/automation/automation_tab_tracker.h +++ b/chrome/browser/automation/automation_tab_tracker.h @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H_ -#define CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H_ +#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H__ +#define CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H__ #include "chrome/browser/automation/automation_resource_tracker.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/navigation_controller.h" -#include "chrome/common/notification_registrar.h" class AutomationTabTracker : public AutomationResourceTracker<NavigationController*> { @@ -23,24 +22,28 @@ public: virtual void AddObserver(NavigationController* resource) { // This tab could either be a regular tab or an external tab - // Register for both notifications. - registrar_.Add(this, NOTIFY_TAB_CLOSING, - Source<NavigationController>(resource)); - registrar_.Add(this, NOTIFY_EXTERNAL_TAB_CLOSED, - Source<NavigationController>(resource)); + // Register for both notifications + NotificationService::current()->AddObserver( + this, NOTIFY_TAB_CLOSING, Source<NavigationController>(resource)); + NotificationService::current()->AddObserver( + this, NOTIFY_EXTERNAL_TAB_CLOSED, + Source<NavigationController>(resource)); // We also want to know about navigations so we can keep track of the last // navigation time. - registrar_.Add(this, NOTIFY_NAV_ENTRY_COMMITTED, - Source<NavigationController>(resource)); + NotificationService::current()->AddObserver( + this, NOTIFY_NAV_ENTRY_COMMITTED, + Source<NavigationController>(resource)); } virtual void RemoveObserver(NavigationController* resource) { - registrar_.Remove(this, NOTIFY_TAB_CLOSING, - Source<NavigationController>(resource)); - registrar_.Remove(this, NOTIFY_EXTERNAL_TAB_CLOSED, - Source<NavigationController>(resource)); - registrar_.Remove(this, NOTIFY_NAV_ENTRY_COMMITTED, - Source<NavigationController>(resource)); + NotificationService::current()->RemoveObserver( + this, NOTIFY_TAB_CLOSING, Source<NavigationController>(resource)); + NotificationService::current()->RemoveObserver( + this, NOTIFY_EXTERNAL_TAB_CLOSED, + Source<NavigationController>(resource)); + NotificationService::current()->RemoveObserver( + this, NOTIFY_NAV_ENTRY_COMMITTED, + Source<NavigationController>(resource)); } virtual void Observe(NotificationType type, @@ -77,12 +80,11 @@ public: } private: - NotificationRegistrar registrar_; - // Last time a navigation occurred. - std::map<NavigationController*, base::Time> last_navigation_times_; + std::map<NavigationController*, base::Time> last_navigation_times_; DISALLOW_COPY_AND_ASSIGN(AutomationTabTracker); }; -#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H_ +#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H__ + |