summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation/automation_provider.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 16:58:03 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 16:58:03 +0000
commit6a02963e645852d8ce70b53aa6199ec1780f31c2 (patch)
tree7df60ab260a074368dbe29ad11f61344b218cac4 /chrome/browser/automation/automation_provider.cc
parent690a99c80e4fe4e6eda9010b88e4438f57912336 (diff)
downloadchromium_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_provider.cc')
-rw-r--r--chrome/browser/automation/automation_provider.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index ff96f55f0..ec31959 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -29,6 +29,7 @@
#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"
@@ -45,30 +46,21 @@ class InitialLoadObserver : public NotificationObserver {
automation_(automation) {
if (outstanding_tab_count_ > 0) {
NotificationService* service = NotificationService::current();
- service->AddObserver(this, NOTIFY_LOAD_START,
- NotificationService::AllSources());
- service->AddObserver(this, NOTIFY_LOAD_STOP,
- NotificationService::AllSources());
+ registrar_.Add(this, NOTIFY_LOAD_START,
+ NotificationService::AllSources());
+ registrar_.Add(this, NOTIFY_LOAD_STOP,
+ NotificationService::AllSources());
}
}
~InitialLoadObserver() {
- Unregister();
}
void ConditionMet() {
- Unregister();
+ registrar_.RemoveAll();
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) {
@@ -90,6 +82,8 @@ class InitialLoadObserver : public NotificationObserver {
private:
typedef std::set<uintptr_t> TabSet;
+ NotificationRegistrar registrar_;
+
AutomationProvider* automation_;
size_t outstanding_tab_count_;
TabSet loading_tabs_;