summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 00:47:20 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 00:47:20 +0000
commit59316ec0027a6e6eec0f71405edc8d2a53039db0 (patch)
treed63d252793ec2d32568c248babda8fc07cfd2080
parent628be586f84f4b85d51463c03224bf642ade0f28 (diff)
downloadchromium_src-59316ec0027a6e6eec0f71405edc8d2a53039db0.zip
chromium_src-59316ec0027a6e6eec0f71405edc8d2a53039db0.tar.gz
chromium_src-59316ec0027a6e6eec0f71405edc8d2a53039db0.tar.bz2
Use a NotificationRegistrar to handle notification observing.
BUG=2381 Review URL: http://codereview.chromium.org/115607 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/history_ui.cc12
-rw-r--r--chrome/browser/dom_ui/history_ui.h3
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc7
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.h4
4 files changed, 10 insertions, 16 deletions
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index 1c37d12..1fbbb38 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -113,20 +113,12 @@ BrowsingHistoryHandler::BrowsingHistoryHandler(DOMUI* dom_ui)
new DOMUIFavIconSource(dom_ui_->GetProfile())));
// Get notifications when history is cleared.
- NotificationService* service = NotificationService::current();
- service->AddObserver(this, NotificationType::HISTORY_URLS_DELETED,
- Source<Profile>(
- dom_ui_->GetProfile()->GetOriginalProfile()));
+ registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
+ Source<Profile>(dom_ui_->GetProfile()->GetOriginalProfile()));
}
BrowsingHistoryHandler::~BrowsingHistoryHandler() {
cancelable_consumer_.CancelAllRequests();
-
- NotificationService* service = NotificationService::current();
- service->RemoveObserver(this, NotificationType::HISTORY_URLS_DELETED,
- Source<Profile>(
- dom_ui_->GetProfile()->GetOriginalProfile()));
-
if (remover_.get())
remover_->RemoveObserver(this);
}
diff --git a/chrome/browser/dom_ui/history_ui.h b/chrome/browser/dom_ui/history_ui.h
index a4f201c..f44e033 100644
--- a/chrome/browser/dom_ui/history_ui.h
+++ b/chrome/browser/dom_ui/history_ui.h
@@ -11,6 +11,7 @@
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/history/history.h"
+#include "chrome/common/notification_registrar.h"
class GURL;
@@ -67,6 +68,8 @@ class BrowsingHistoryHandler : public DOMMessageHandler,
// Figure out the query options for a month-wide query.
history::QueryOptions CreateMonthQueryOptions(int month);
+ NotificationRegistrar registrar_;
+
// Current search text.
std::wstring search_text_;
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index e64f02e..ccef07f 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -1193,14 +1193,11 @@ NewTabUI::NewTabUI(TabContents* contents)
}
// Listen for theme installation.
- NotificationService::current()->AddObserver(this,
- NotificationType::THEME_INSTALLED, NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::THEME_INSTALLED,
+ NotificationService::AllSources());
}
NewTabUI::~NewTabUI() {
- // Remove theme observer.
- NotificationService::current()->RemoveObserver(this,
- NotificationType::THEME_INSTALLED, NotificationService::AllSources());
}
void NewTabUI::Observe(NotificationType type,
diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h
index 1efb8dd..6c3a2f1 100644
--- a/chrome/browser/dom_ui/new_tab_ui.h
+++ b/chrome/browser/dom_ui/new_tab_ui.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H_
#include "chrome/browser/dom_ui/dom_ui.h"
-#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
class GURL;
class PrefService;
@@ -33,6 +33,8 @@ class NewTabUI : public DOMUI,
const NotificationSource& source,
const NotificationDetails& details);
+ NotificationRegistrar registrar_;
+
// The message id that should be displayed in this NewTabUIContents
// instance's motd area.
int motd_message_id_;