Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index 865438513dd39f0ea0d461506492a3c0736b8112..a77c73d51519aadb93502e5570341ec2dfc05351 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -79,6 +79,7 @@ |
| #include "extensions/browser/extensions_browser_client.h" |
| #include "extensions/browser/external_install_info.h" |
| #include "extensions/browser/install_flag.h" |
| +#include "extensions/browser/lazy_background_task_queue.h" |
| #include "extensions/browser/renderer_startup_helper.h" |
| #include "extensions/browser/runtime_data.h" |
| #include "extensions/browser/uninstall_reason.h" |
| @@ -144,6 +145,8 @@ const int kUpdateIdleDelay = 5; |
| // TODO(samuong): Remove this in M58 (see comment in ExtensionService::Init). |
| const char kDeprecatedLoadComponentExtension[] = "load-component-extension"; |
| +void DoNothingWithExtensionHost(extensions::ExtensionHost* host) {} |
| + |
| } // namespace |
| // ExtensionService. |
| @@ -924,11 +927,7 @@ void ExtensionService::EnableExtension(const std::string& extension_id) { |
| NotifyExtensionLoaded(extension); |
| - // Notify listeners that the extension was enabled. |
| - content::NotificationService::current()->Notify( |
| - extensions::NOTIFICATION_EXTENSION_ENABLED, |
| - content::Source<Profile>(profile_), |
| - content::Details<const Extension>(extension)); |
| + MaybeSpinUpLazyBackgroundPage(extension); |
| } |
| void ExtensionService::DisableExtension(const std::string& extension_id, |
| @@ -2557,3 +2556,29 @@ void ExtensionService::OnInstalledExtensionsLoaded() { |
| OnBlacklistUpdated(); |
| } |
| + |
| +void ExtensionService::MaybeSpinUpLazyBackgroundPage( |
| + const Extension* extension) { |
| + if (!extensions::BackgroundInfo::HasLazyBackgroundPage(extension)) |
| + return; |
| + |
| + // For orphaned devtools, we will reconnect devtools to it later in |
| + // DidCreateRenderViewForBackgroundPage(). |
| + OrphanedDevTools::iterator iter = orphaned_dev_tools_.find(extension->id()); |
| + bool has_orphaned_dev_tools = iter != orphaned_dev_tools_.end(); |
| + |
| + // Reloading component extension does not trigger install, so RuntimeAPI won't |
|
lazyboy
2017/06/01 23:32:54
This turns out to be interesting :)
Reloading comp
Devlin
2017/06/02 01:57:28
Fun! So was this also a bug before?
This makes m
lazyboy
2017/06/02 18:35:37
It wasn't, because we used to call AddPendingTask
Devlin
2017/06/03 02:10:12
Hmm, would we need to call it from here? Couldn't
lazyboy
2017/06/03 02:18:52
OnExtensionLoaded can result from line 1583 as wel
Devlin
2017/06/05 15:38:38
Oh, I see. Drat. This is fine, then.
lazyboy
2017/06/05 21:54:01
Acknowledged.
|
| + // be able to detect its loading. Therefore, we need to spin up its lazy |
| + // background page. |
| + bool is_component_extension = |
| + Manifest::IsComponentLocation(extension->location()); |
| + |
| + if (!has_orphaned_dev_tools && !is_component_extension) |
| + return; |
| + |
| + // Wake up the event page by posting a dummy task. |
| + extensions::LazyBackgroundTaskQueue* queue = |
| + extensions::LazyBackgroundTaskQueue::Get(profile_); |
| + queue->AddPendingTask(profile_, extension->id(), |
| + base::Bind(&DoNothingWithExtensionHost)); |
| +} |