summaryrefslogtreecommitdiffstats
path: root/apps/launcher.cc
diff options
context:
space:
mode:
authorkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 06:48:15 +0000
committerkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 06:48:15 +0000
commitd2489c7461bbefb75ce1c0f09b73f2240944567e (patch)
tree63939e126584edeede494d5f223f8e5815a32bad /apps/launcher.cc
parent7bea768a7d17c399e0949c63dfc3d835d7c2a617 (diff)
downloadchromium_src-d2489c7461bbefb75ce1c0f09b73f2240944567e.zip
chromium_src-d2489c7461bbefb75ce1c0f09b73f2240944567e.tar.gz
chromium_src-d2489c7461bbefb75ce1c0f09b73f2240944567e.tar.bz2
Make clicking the restart bubble for crashed apps work.
Previously AppLoadService listened for NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING before dispatching the onRestarted() event after a reload, but in the case of packaged apps, which use non-persistent background pages, that notification will never get fired. This is because reloading an app doesn't cause its background page to get loaded - only a relevant event causes the page to be woken up. This patch fixes the issue by listening for NOTIFICATION_EXTENSION_LOADED instead, which is always fired after a reload. It also determines whether an extension is listening to an event by checking which events it has registered for, not which ones it currently has a listener for, NOTIFICATION_EXTENSION_LOADED is the notification that listeners get created on, and so to avoid raciness we check registered events (ie: the persisted list of events that an extension is interested in). BUG=327964 Review URL: https://codereview.chromium.org/93593003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/launcher.cc')
-rw-r--r--apps/launcher.cc14
1 files changed, 8 insertions, 6 deletions
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);