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

Unified Diff: chrome/browser/extensions/event_router.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: comment 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 | « chrome/browser/extensions/api/app_runtime/app_runtime_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/event_router.cc
diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc
index 213299b2f6c879663028f330231dd5427f0243b5..3fe9f1622a16e76c62c8d9335795ef4f45a590d4 100644
--- a/chrome/browser/extensions/event_router.cc
+++ b/chrome/browser/extensions/event_router.cc
@@ -65,6 +65,8 @@ void DispatchOnInstalledEvent(
old_version, chrome_updated);
}
+void DoNothing(extensions::ExtensionHost* host) {}
+
} // namespace
struct EventRouter::ListenerProcess {
@@ -128,6 +130,8 @@ EventRouter::EventRouter(Profile* profile, ExtensionPrefs* extension_prefs)
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
content::Source<Profile>(profile_));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_ENABLED,
+ content::Source<Profile>(profile_));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile_));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -606,6 +610,18 @@ void EventRouter::Observe(int type,
dispatch_chrome_updated_event_ = false;
break;
}
+ case chrome::NOTIFICATION_EXTENSION_ENABLED: {
+ // If the extension has a lazy background page, make sure it gets loaded
+ // to register the events the extension is interested in.
+ const Extension* extension =
+ content::Details<const Extension>(details).ptr();
+ if (extension->has_lazy_background_page()) {
+ LazyBackgroundTaskQueue* queue =
+ ExtensionSystem::Get(profile_)->lazy_background_task_queue();
+ queue->AddPendingTask(profile_, extension->id(),
+ base::Bind(&DoNothing));
+ }
+ }
case chrome::NOTIFICATION_EXTENSION_LOADED: {
// Add all registered lazy listeners to our cache.
const Extension* extension =
« no previous file with comments | « chrome/browser/extensions/api/app_runtime/app_runtime_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698