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

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: Roughly wire things up and add a test 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 412787979dfcaaafdde066e447b0be43c581d696..a7618c1389889e751437facc4de375ae77488303 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -84,6 +84,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"
@@ -113,6 +114,7 @@
using content::BrowserContext;
using content::BrowserThread;
using content::DevToolsAgentHost;
+using extensions::BackgroundInfo;
using extensions::CrxInstaller;
using extensions::Extension;
using extensions::ExtensionIdSet;
@@ -126,6 +128,7 @@ using extensions::Manifest;
using extensions::PermissionMessage;
using extensions::PermissionMessages;
using extensions::PermissionSet;
+using extensions::ServiceWorkerManager;
using extensions::SharedModuleInfo;
using extensions::UnloadedExtensionInfo;
@@ -1049,6 +1052,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);
@@ -1157,6 +1164,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.
//
@@ -1654,6 +1664,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