From f5863da15d5c40c66873d36fd403ac96b8172828 Mon Sep 17 00:00:00 2001 From: "rdevlin.cronin" Date: Thu, 10 Sep 2015 12:21:45 -0700 Subject: Don't Allow Service Workers for Unloaded Extensions Extensions are interesting, in that they can be unloaded and reloaded, and their state should be the same after this (especially since it can happen on every browser start/stop). Any service workers that an extension has should not be running during the time that the extension is not loaded, but on reload, these workers should be put in place again, and should maintain their cache. For this, check if the extension is loaded in AllowServiceWorkers(), and stop any running service workers when the extension is unloaded. BUG=519326 TBR=kinuko@chromium.org (small changes to misc content/ files) Review URL: https://codereview.chromium.org/1313213002 Cr-Commit-Position: refs/heads/master@{#348208} --- extensions/shell/browser/shell_extension_system.cc | 6 ++++++ extensions/shell/browser/shell_extension_system.h | 2 ++ 2 files changed, 8 insertions(+) (limited to 'extensions/shell/browser') diff --git a/extensions/shell/browser/shell_extension_system.cc b/extensions/shell/browser/shell_extension_system.cc index 7031452..0457491 100644 --- a/extensions/shell/browser/shell_extension_system.cc +++ b/extensions/shell/browser/shell_extension_system.cc @@ -21,6 +21,7 @@ #include "extensions/browser/null_app_sorting.h" #include "extensions/browser/quota_service.h" #include "extensions/browser/runtime_data.h" +#include "extensions/browser/service_worker_manager.h" #include "extensions/common/constants.h" #include "extensions/common/file_util.h" @@ -98,6 +99,7 @@ void ShellExtensionSystem::Shutdown() { } void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { + service_worker_manager_.reset(new ServiceWorkerManager(browser_context_)); runtime_data_.reset( new RuntimeData(ExtensionRegistry::Get(browser_context_))); quota_service_.reset(new QuotaService); @@ -116,6 +118,10 @@ ManagementPolicy* ShellExtensionSystem::management_policy() { return nullptr; } +ServiceWorkerManager* ShellExtensionSystem::service_worker_manager() { + return service_worker_manager_.get(); +} + SharedUserScriptMaster* ShellExtensionSystem::shared_user_script_master() { return nullptr; } diff --git a/extensions/shell/browser/shell_extension_system.h b/extensions/shell/browser/shell_extension_system.h index 29d2982..f042f2d 100644 --- a/extensions/shell/browser/shell_extension_system.h +++ b/extensions/shell/browser/shell_extension_system.h @@ -47,6 +47,7 @@ class ShellExtensionSystem : public ExtensionSystem { ExtensionService* extension_service() override; RuntimeData* runtime_data() override; ManagementPolicy* management_policy() override; + ServiceWorkerManager* service_worker_manager() override; SharedUserScriptMaster* shared_user_script_master() override; StateStore* state_store() override; StateStore* rules_store() override; @@ -72,6 +73,7 @@ class ShellExtensionSystem : public ExtensionSystem { // Data to be accessed on the IO thread. Must outlive process_manager_. scoped_refptr info_map_; + scoped_ptr service_worker_manager_; scoped_ptr runtime_data_; scoped_ptr quota_service_; scoped_ptr app_sorting_; -- cgit v1.1