Chromium Code Reviews| Index: apps/launcher.cc |
| diff --git a/apps/launcher.cc b/apps/launcher.cc |
| index f8f00517d708dd41cc48835893e8e7bbce676ea0..ec9ea188a7d71ac6566ec0e188970afbb78d8dd4 100644 |
| --- a/apps/launcher.cc |
| +++ b/apps/launcher.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/files/file_path.h" |
| #include "base/logging.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/stl_util.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
| @@ -377,9 +378,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 = |
| + ContainsKey(events, std::string(app_runtime::OnRestarted::kEventName)); |
|
tapted
2013/12/16 03:23:17
what's wrong with .count()? you should get an impl
koz (OOO until 15th September)
2013/12/16 03:52:35
Oh, but I'm old-school, too! Sort of. Java is olds
|
| if (listening_to_restart) { |
| extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); |
| @@ -390,9 +394,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 = |
| + ContainsKey(events, std::string(app_runtime::OnLaunched::kEventName)); |
| if (listening_to_launch && had_windows) |
| LaunchPlatformAppWithNoData(profile, extension); |