Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2326)

Unified Diff: chrome/browser/extensions/extension_history_api.cc

Issue 6961027: Change event routers from singletons to being owned by the ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all is built on sand Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_history_api.cc
diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc
index 9ead42236424d59ca9d069b177533b4600ca286a..3287184bb562b55a5da1f9289eb4d54dbffde397 100644
--- a/chrome/browser/extensions/extension_history_api.cc
+++ b/chrome/browser/extensions/extension_history_api.cc
@@ -64,49 +64,39 @@ void AddVisitNode(const history::VisitRow& row, ListValue* list) {
} // namespace
-ExtensionHistoryEventRouter* ExtensionHistoryEventRouter::GetInstance() {
- return Singleton<ExtensionHistoryEventRouter>::get();
-}
+ExtensionHistoryEventRouter::ExtensionHistoryEventRouter(Profile* profile)
+ : profile_(profile) {}
-void ExtensionHistoryEventRouter::ObserveProfile(Profile* profile) {
- NotificationSource source = Source<Profile>(profile);
- if (profiles_.find(source.map_key()) == profiles_.end())
- profiles_[source.map_key()] = profile;
+ExtensionHistoryEventRouter::~ExtensionHistoryEventRouter() {}
+void ExtensionHistoryEventRouter::Init() {
+ NotificationSource source = Source<Profile>(profile_);
if (registrar_.IsEmpty()) {
registrar_.Add(this,
NotificationType::HISTORY_URL_VISITED,
- NotificationService::AllSources());
+ source);
registrar_.Add(this,
NotificationType::HISTORY_URLS_DELETED,
- NotificationService::AllSources());
+ source);
}
}
-ExtensionHistoryEventRouter::ExtensionHistoryEventRouter() {}
-
-ExtensionHistoryEventRouter::~ExtensionHistoryEventRouter() {}
-
void ExtensionHistoryEventRouter::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- ProfileMap::iterator it = profiles_.find(source.map_key());
- if (it != profiles_.end()) {
- Profile* profile = it->second;
- switch (type.value) {
- case NotificationType::HISTORY_URL_VISITED:
- HistoryUrlVisited(
- profile,
- Details<const history::URLVisitedDetails>(details).ptr());
- break;
- case NotificationType::HISTORY_URLS_DELETED:
- HistoryUrlsRemoved(
- profile,
- Details<const history::URLsDeletedDetails>(details).ptr());
- break;
- default:
- NOTREACHED();
- }
+ switch (type.value) {
+ case NotificationType::HISTORY_URL_VISITED:
+ HistoryUrlVisited(
+ profile_,
+ Details<const history::URLVisitedDetails>(details).ptr());
+ break;
+ case NotificationType::HISTORY_URLS_DELETED:
+ HistoryUrlsRemoved(
+ profile_,
+ Details<const history::URLsDeletedDetails>(details).ptr());
+ break;
+ default:
+ NOTREACHED();
}
}
« no previous file with comments | « chrome/browser/extensions/extension_history_api.h ('k') | chrome/browser/extensions/extension_management_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698