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 = |