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

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

Issue 182253010: Register a Service Worker when an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to r261176 Created 6 years, 9 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
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index adae9a5934173fc5ed0d161bfea4b150c597e616..b5643ed68435c448cade3b1da485933c867f8287 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -81,6 +81,7 @@
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/runtime_data.h"
+#include "extensions/browser/service_worker_manager.h"
#include "extensions/browser/update_observer.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
@@ -111,6 +112,7 @@
using content::BrowserContext;
using content::BrowserThread;
using content::DevToolsAgentHost;
+using extensions::BackgroundInfo;
using extensions::CrxInstaller;
using extensions::Extension;
using extensions::ExtensionIdSet;
@@ -124,6 +126,7 @@ using extensions::Manifest;
using extensions::PermissionMessage;
using extensions::PermissionMessages;
using extensions::PermissionSet;
+using extensions::ServiceWorkerManager;
using extensions::SharedModuleInfo;
using extensions::UnloadedExtensionInfo;
@@ -912,6 +915,10 @@ void ExtensionService::DisableExtension(
// Move it over to the disabled list. Don't send a second unload notification
// for terminated extensions being disabled.
registry_->AddDisabled(make_scoped_refptr(extension));
+
+ if (BackgroundInfo::HasServiceWorker(extension))
+ ServiceWorkerManager::Get(profile_)->UnregisterExtension(extension);
+
if (registry_->enabled_extensions().Contains(extension->id())) {
registry_->RemoveEnabled(extension->id());
NotifyExtensionUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE);
@@ -1023,6 +1030,9 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) {
}
}
+ if (BackgroundInfo::HasServiceWorker(extension))
+ ServiceWorkerManager::Get(profile_)->RegisterExtension(extension);
+
// Tell subsystems that use the EXTENSION_LOADED notification about the new
// extension.
//
@@ -1511,6 +1521,19 @@ void ExtensionService::UnloadExtension(
} else {
// Remove the extension from the enabled list.
registry_->RemoveEnabled(extension->id());
+
+ if (BackgroundInfo::HasServiceWorker(extension)) {
+ switch (reason) {
+ case UnloadedExtensionInfo::REASON_DISABLE:
+ case UnloadedExtensionInfo::REASON_UNINSTALL:
+ case UnloadedExtensionInfo::REASON_BLACKLIST:
+ ServiceWorkerManager::Get(profile_)->UnregisterExtension(extension);
+ break;
+ case UnloadedExtensionInfo::REASON_UPDATE:
+ case UnloadedExtensionInfo::REASON_TERMINATE:
+ break;
+ }
+ }
NotifyExtensionUnloaded(extension.get(), reason);
}

Powered by Google App Engine
This is Rietveld 408576698