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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 2893693002: Remove NOTIFICATION_EXTENSION_ENABLED. (Closed)
Patch Set: address comments Created 3 years, 6 months 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/extension_service.h ('k') | chrome/browser/themes/theme_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+ // 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));
+}
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/themes/theme_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698