diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 16:58:03 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 16:58:03 +0000 |
commit | 6a02963e645852d8ce70b53aa6199ec1780f31c2 (patch) | |
tree | 7df60ab260a074368dbe29ad11f61344b218cac4 /chrome/browser/automation/automation_tab_tracker.h | |
parent | 690a99c80e4fe4e6eda9010b88e4438f57912336 (diff) | |
download | chromium_src-6a02963e645852d8ce70b53aa6199ec1780f31c2.zip chromium_src-6a02963e645852d8ce70b53aa6199ec1780f31c2.tar.gz chromium_src-6a02963e645852d8ce70b53aa6199ec1780f31c2.tar.bz2 |
This is a redo of my previous notification registrar change. I saw a crash in handling NAV_ENTRY_COMMITTED, so am changing all consumers of this to use the registrar so that it is impossible to forget to unregister.
The difference is that in tab_contents I moved the removal code in RemoveInfoBar to only remove the listener if an infobar was actually removed.
Review URL: http://codereview.chromium.org/16534
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/automation_tab_tracker.h')
-rw-r--r-- | chrome/browser/automation/automation_tab_tracker.h | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/chrome/browser/automation/automation_tab_tracker.h b/chrome/browser/automation/automation_tab_tracker.h index 9e0c63c..1033ad0 100644 --- a/chrome/browser/automation/automation_tab_tracker.h +++ b/chrome/browser/automation/automation_tab_tracker.h @@ -2,13 +2,14 @@ // 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*> { @@ -22,28 +23,24 @@ public: virtual void AddObserver(NavigationController* resource) { // This tab could either be a regular tab or an external tab - // 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)); + // Register for both notifications. + registrar_.Add(this, NOTIFY_TAB_CLOSING, + Source<NavigationController>(resource)); + registrar_.Add(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. - NotificationService::current()->AddObserver( - this, NOTIFY_NAV_ENTRY_COMMITTED, - Source<NavigationController>(resource)); + registrar_.Add(this, NOTIFY_NAV_ENTRY_COMMITTED, + Source<NavigationController>(resource)); } virtual void RemoveObserver(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)); + 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)); } virtual void Observe(NotificationType type, @@ -80,11 +77,12 @@ 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_ |