Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: chrome/browser/extensions/api/app_runtime/app_runtime_api.cc

Issue 11348301: Force-load a lazy background page whenever an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/event_router.cc » ('j') | chrome/browser/extensions/event_router.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | chrome/browser/extensions/event_router.cc » ('j') | chrome/browser/extensions/event_router.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698