diff options
-rw-r--r-- | apps/app_load_service.cc | 11 | ||||
-rw-r--r-- | apps/launcher.cc | 14 |
2 files changed, 11 insertions, 14 deletions
diff --git a/apps/app_load_service.cc b/apps/app_load_service.cc index 496b4da..ecf0636 100644 --- a/apps/app_load_service.cc +++ b/apps/app_load_service.cc @@ -33,7 +33,7 @@ AppLoadService::PostReloadAction::PostReloadAction() AppLoadService::AppLoadService(Profile* profile) : profile_(profile) { registrar_.Add( - this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, + this, chrome::NOTIFICATION_EXTENSION_LOADED, content::NotificationService::AllSources()); registrar_.Add( this, chrome::NOTIFICATION_EXTENSION_UNLOADED, @@ -78,13 +78,8 @@ void AppLoadService::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { - case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { - extensions::ExtensionHost* host = - content::Details<extensions::ExtensionHost>(details).ptr(); - const Extension* extension = host->extension(); - // It is possible for an extension to be unloaded before it stops loading. - if (!extension) - break; + case chrome::NOTIFICATION_EXTENSION_LOADED: { + Extension* extension = content::Details<Extension>(details).ptr(); std::map<std::string, PostReloadAction>::iterator it = post_reload_actions_.find(extension->id()); if (it == post_reload_actions_.end()) diff --git a/apps/launcher.cc b/apps/launcher.cc index 6b077dd..4f79973 100644 --- a/apps/launcher.cc +++ b/apps/launcher.cc @@ -380,9 +380,12 @@ void RestartPlatformApp(Profile* profile, const Extension* extension) { #endif extensions::EventRouter* event_router = ExtensionSystem::Get(profile)->event_router(); - bool listening_to_restart = event_router-> - ExtensionHasEventListener(extension->id(), - app_runtime::OnRestarted::kEventName); + // We check for registered events, rather than listeners, because listeners + // may not be instantiated for the events yet. + std::set<std::string> events = + event_router->GetRegisteredEvents(extension->id()); + bool listening_to_restart = + events.count(app_runtime::OnRestarted::kEventName) > 0; if (listening_to_restart) { extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); @@ -393,9 +396,8 @@ void RestartPlatformApp(Profile* profile, const Extension* extension) { extension_service()->extension_prefs(); bool had_windows = extension_prefs->IsActive(extension->id()); extension_prefs->SetIsActive(extension->id(), false); - bool listening_to_launch = event_router-> - ExtensionHasEventListener(extension->id(), - app_runtime::OnLaunched::kEventName); + bool listening_to_launch = + events.count(app_runtime::OnLaunched::kEventName) > 0; if (listening_to_launch && had_windows) LaunchPlatformAppWithNoData(profile, extension); |