Index: chrome/browser/extensions/api/declarative/rules_registry_service.cc |
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.cc b/chrome/browser/extensions/api/declarative/rules_registry_service.cc |
index 1fd7e0cef90cc422df24fd21be794263cc25ba24..ab3fa2d55b915dc953cc2bce7ba2df19fbf275cc 100644 |
--- a/chrome/browser/extensions/api/declarative/rules_registry_service.cc |
+++ b/chrome/browser/extensions/api/declarative/rules_registry_service.cc |
@@ -46,6 +46,11 @@ RulesRegistryService::RulesRegistryService(Profile* profile) |
if (profile) { |
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
content::Source<Profile>(profile->GetOriginalProfile())); |
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
+ content::Source<Profile>(profile->GetOriginalProfile())); |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_EXTENSION_LOADED, |
+ content::Source<Profile>(profile_->GetOriginalProfile())); |
registrar_.Add( |
this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
content::NotificationService::AllBrowserContextsAndSources()); |
@@ -175,28 +180,42 @@ void RulesRegistryService::RemoveWebViewRulesRegistries(int process_id) { |
} |
} |
-void RulesRegistryService::SimulateExtensionUnloaded( |
+void RulesRegistryService::SimulateExtensionUninstalled( |
const std::string& extension_id) { |
- OnExtensionUnloaded(extension_id); |
+ OnExtensionUninstalled(extension_id); |
} |
-void RulesRegistryService::OnExtensionUnloaded( |
+void RulesRegistryService::NotifyRegistriesHelper( |
+ void (RulesRegistry::*notification_callback)(const std::string&), |
const std::string& extension_id) { |
RulesRegistryMap::iterator i; |
for (i = rule_registries_.begin(); i != rule_registries_.end(); ++i) { |
scoped_refptr<RulesRegistry> registry = i->second; |
if (content::BrowserThread::CurrentlyOn(registry->owner_thread())) { |
- registry->OnExtensionUnloaded(extension_id); |
+ (registry->*notification_callback)(extension_id); |
} else { |
content::BrowserThread::PostTask( |
registry->owner_thread(), |
FROM_HERE, |
- base::Bind( |
- &RulesRegistry::OnExtensionUnloaded, registry, extension_id)); |
+ base::Bind(notification_callback, registry, extension_id)); |
} |
} |
} |
+void RulesRegistryService::OnExtensionUninstalled( |
Jeffrey Yasskin
2013/11/20 05:55:28
I would consider inlining these 1-line functions t
|
+ const std::string& extension_id) { |
+ NotifyRegistriesHelper(&RulesRegistry::OnExtensionUninstalled, extension_id); |
+} |
+ |
+void RulesRegistryService::OnExtensionUnloaded( |
+ const std::string& extension_id) { |
+ NotifyRegistriesHelper(&RulesRegistry::OnExtensionUnloaded, extension_id); |
+} |
+ |
+void RulesRegistryService::OnExtensionLoaded(const std::string& extension_id) { |
+ NotifyRegistriesHelper(&RulesRegistry::OnExtensionLoaded, extension_id); |
+} |
+ |
void RulesRegistryService::Observe( |
int type, |
const content::NotificationSource& source, |
@@ -208,6 +227,18 @@ void RulesRegistryService::Observe( |
OnExtensionUnloaded(extension->id()); |
break; |
} |
+ case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
+ const Extension* extension = |
+ content::Details<const Extension>(details).ptr(); |
+ OnExtensionUninstalled(extension->id()); |
+ break; |
+ } |
+ case chrome::NOTIFICATION_EXTENSION_LOADED: { |
+ const Extension* extension = |
+ content::Details<const Extension>(details).ptr(); |
+ OnExtensionLoaded(extension->id()); |
+ break; |
+ } |
case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
content::RenderProcessHost* process = |
content::Source<content::RenderProcessHost>(source).ptr(); |