Index: chrome/browser/extensions/api/app_runtime/app_runtime_api.cc |
diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc |
index c52920ac8fd8c60a8f985a7ffbd57b508789b0df..1bbc3afafeb63f9ab2ff5fa6aff8f87c0cd9cf07 100644 |
--- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc |
+++ b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc |
@@ -30,6 +30,18 @@ const char kOnRestartedEvent[] = "app.runtime.onRestarted"; |
const char kCallbackNotFoundError[] = |
"WebIntent callback not found; perhaps already responded to"; |
+void DispatchOnLaunchedEventImpl(const std::string& extension_id, |
+ scoped_ptr<base::ListValue> args, |
+ Profile* profile) { |
+ extensions::ExtensionSystem* system = |
+ extensions::ExtensionSystem::Get(profile); |
+ system->event_router()->AddLazyEventListener(kOnLaunchedEvent, extension_id); |
Matt Perry
2012/11/29 22:03:21
add a comment explaining why this is necessary
Marijn Kruisselbrink
2012/11/30 00:51:20
Done.
|
+ system->event_router()->DispatchEventToExtension( |
+ extension_id, kOnLaunchedEvent, args.Pass(), profile, GURL()); |
+ system->event_router()->RemoveLazyEventListener(kOnLaunchedEvent, |
+ extension_id); |
+} |
+ |
} // anonymous namespace |
namespace extensions { |
@@ -38,9 +50,7 @@ namespace extensions { |
void AppEventRouter::DispatchOnLaunchedEvent( |
Profile* profile, const Extension* extension) { |
scoped_ptr<ListValue> arguments(new ListValue()); |
- extensions::ExtensionSystem::Get(profile)->event_router()-> |
- DispatchEventToExtension(extension->id(), kOnLaunchedEvent, |
- arguments.Pass(), profile, GURL()); |
+ DispatchOnLaunchedEventImpl(extension->id(), arguments.Pass(), profile); |
} |
// static. |
@@ -68,9 +78,7 @@ void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( |
items->Append(launch_item); |
launch_data->Set("items", items); |
args->Append(launch_data); |
- extensions::ExtensionSystem::Get(profile)->event_router()-> |
- DispatchEventToExtension(extension->id(), kOnLaunchedEvent, args.Pass(), |
- profile, GURL()); |
+ DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); |
} |
// static. |
@@ -126,9 +134,7 @@ void AppEventRouter::DispatchOnLaunchedEventWithWebIntent( |
int intent_id = |
callbacks->RegisterCallback(extension, intents_dispatcher, source); |
args->Append(base::Value::CreateIntegerValue(intent_id)); |
- extensions::ExtensionSystem::Get(profile)->event_router()-> |
- DispatchEventToExtension(extension->id(), kOnLaunchedEvent, args.Pass(), |
- profile, GURL()); |
+ DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); |
} |
bool AppRuntimePostIntentResponseFunction::RunImpl() { |