Chromium Code Reviews| Index: chrome/browser/extensions/extension_process_manager.cc |
| =================================================================== |
| --- chrome/browser/extensions/extension_process_manager.cc (revision 19016) |
| +++ chrome/browser/extensions/extension_process_manager.cc (working copy) |
| @@ -25,19 +25,22 @@ |
| ExtensionProcessManager::ExtensionProcessManager(Profile* profile) |
| : browsing_instance_(new BrowsingInstance(profile)) { |
| + registrar_.Add(this, NotificationType::EXTENSIONS_READY, |
| + NotificationService::AllSources()); |
| registrar_.Add(this, NotificationType::EXTENSIONS_LOADED, |
| NotificationService::AllSources()); |
| registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| NotificationService::AllSources()); |
| - if (profile->GetExtensionsService()) |
| - CreateBackgroundHosts(this, profile->GetExtensionsService()->extensions()); |
| + ExtensionsService* service = profile->GetExtensionsService(); |
| + if (service && service->is_ready()) |
|
rafaelw
2009/06/24 23:04:22
Can this test ever return true?
Erik does not do reviews
2009/06/25 16:19:08
Good point. It can't any more. I'll fix this in
|
| + CreateBackgroundHosts(this, service->extensions()); |
| } |
| ExtensionProcessManager::~ExtensionProcessManager() { |
| // Copy all_hosts_ to avoid iterator invalidation issues. |
| - ExtensionHostSet to_delete(all_hosts_.begin(), |
| - all_hosts_.end()); |
| + ExtensionHostSet to_delete(background_hosts_.begin(), |
| + background_hosts_.end()); |
| ExtensionHostSet::iterator iter; |
| for (iter = to_delete.begin(); iter != to_delete.end(); ++iter) |
| delete *iter; |
| @@ -85,9 +88,17 @@ |
| const NotificationSource& source, |
| const NotificationDetails& details) { |
| switch (type.value) { |
| + case NotificationType::EXTENSIONS_READY: |
| + CreateBackgroundHosts(this, |
| + Source<ExtensionsService>(source).ptr()->extensions()); |
| + break; |
| + |
| case NotificationType::EXTENSIONS_LOADED: { |
| - const ExtensionList* extensions = Details<ExtensionList>(details).ptr(); |
| - CreateBackgroundHosts(this, extensions); |
| + ExtensionsService* service = Source<ExtensionsService>(source).ptr(); |
| + if (service->is_ready()) { |
| + const ExtensionList* extensions = Details<ExtensionList>(details).ptr(); |
| + CreateBackgroundHosts(this, extensions); |
| + } |
| break; |
| } |