diff options
Diffstat (limited to 'chrome/browser/extensions/extension_process_manager.cc')
-rw-r--r-- | chrome/browser/extensions/extension_process_manager.cc | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 79b2e0f..369150c 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -30,6 +30,9 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile) NotificationService::current()->AddObserver(this, NotificationType::EXTENSIONS_LOADED, NotificationService::AllSources()); + NotificationService::current()->AddObserver(this, + NotificationType::EXTENSION_UNLOADED, + NotificationService::AllSources()); if (profile->GetExtensionsService()) { CreateBackgroundHosts(this, profile->GetExtensionsService()->extensions()); @@ -65,7 +68,28 @@ SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { void ExtensionProcessManager::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(type == NotificationType::EXTENSIONS_LOADED); - const ExtensionList* extensions = Details<ExtensionList>(details).ptr(); - CreateBackgroundHosts(this, extensions); + switch (type.value) { + case NotificationType::EXTENSIONS_LOADED: { + const ExtensionList* extensions = Details<ExtensionList>(details).ptr(); + CreateBackgroundHosts(this, extensions); + break; + } + + case NotificationType::EXTENSION_UNLOADED: { + Extension* extension = Details<Extension>(details).ptr(); + for (ExtensionHostList::iterator iter = background_hosts_.begin(); + iter != background_hosts_.end(); ++iter) { + ExtensionHost* host = *iter; + if (host->extension()->id() == extension->id()) { + background_hosts_.erase(iter); + delete host; + break; + } + } + break; + } + + default: + NOTREACHED(); + } } |