summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_management_api.cc
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-28 17:36:10 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-28 17:36:10 +0000
commitf825df2b1438559506e0a8511ad371daac41d2d1 (patch)
tree36a7964f87d0b6ab6c6ee64344c165112948d410 /chrome/browser/extensions/extension_management_api.cc
parentbe843e26b00f611d3bcf3b2652b8eccf95310346 (diff)
downloadchromium_src-f825df2b1438559506e0a8511ad371daac41d2d1.zip
chromium_src-f825df2b1438559506e0a8511ad371daac41d2d1.tar.gz
chromium_src-f825df2b1438559506e0a8511ad371daac41d2d1.tar.bz2
Revert "Revert "Change extension event routers to not be singletons and to be more profile-aware.""
This time, we handle incognito profiles correctly (see comment in 57186). This reverts commit 4b62f4fb0fe15eee4e573f7182552a7bd2125262. BUG=57186, 87145 TEST=existing tests Review URL: http://codereview.chromium.org/7230035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_management_api.cc')
-rw-r--r--chrome/browser/extensions/extension_management_api.cc29
1 files changed, 13 insertions, 16 deletions
diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc
index b67b03f..4dd6726 100644
--- a/chrome/browser/extensions/extension_management_api.cc
+++ b/chrome/browser/extensions/extension_management_api.cc
@@ -250,12 +250,8 @@ bool UninstallFunction::RunImpl() {
return true;
}
-// static
-ExtensionManagementEventRouter* ExtensionManagementEventRouter::GetInstance() {
- return Singleton<ExtensionManagementEventRouter>::get();
-}
-
-ExtensionManagementEventRouter::ExtensionManagementEventRouter() {}
+ExtensionManagementEventRouter::ExtensionManagementEventRouter(Profile* profile)
+ : profile_(profile) {}
ExtensionManagementEventRouter::~ExtensionManagementEventRouter() {}
@@ -267,13 +263,11 @@ void ExtensionManagementEventRouter::Init() {
NotificationType::EXTENSION_UNLOADED
};
- // Don't re-init (eg in the case of multiple profiles).
- if (registrar_.IsEmpty()) {
- for (size_t i = 0; i < arraysize(types); i++) {
- registrar_.Add(this,
- types[i],
- NotificationService::AllSources());
- }
+ CHECK(registrar_.IsEmpty());
+ for (size_t i = 0; i < arraysize(types); i++) {
+ registrar_.Add(this,
+ types[i],
+ NotificationService::AllSources());
}
}
@@ -282,6 +276,12 @@ void ExtensionManagementEventRouter::Observe(
const NotificationSource& source,
const NotificationDetails& details) {
const char* event_name = NULL;
+ Profile* profile = Source<Profile>(source).ptr();
+ CHECK(profile);
+ if (!profile_->IsSameProfile(profile)) {
+ return;
+ }
+
switch (type.value) {
case NotificationType::EXTENSION_INSTALLED:
event_name = events::kOnExtensionInstalled;
@@ -300,9 +300,6 @@ void ExtensionManagementEventRouter::Observe(
return;
}
- Profile* profile = Source<Profile>(source).ptr();
- CHECK(profile);
-
ListValue args;
if (event_name == events::kOnExtensionUninstalled) {
const std::string& extension_id =