Chromium Code Reviews| 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..69be1f9c11fcb926ec66f77dab0883c790197fb9 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); |
| } |
| +static 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)); |
|
Matt Perry
2012/11/29 22:03:21
Do you actually need to have an empty function? Wh
Marijn Kruisselbrink
2012/11/30 00:51:20
base::Callback() is "null", which means that unles
|
| + } |
| + } |
| case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| // Add all registered lazy listeners to our cache. |
| const Extension* extension = |