summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-02 15:22:08 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-02 15:22:08 +0000
commit31d8f5f265d7e715f1555c42c10e6741976b1065 (patch)
tree52197c501ce7fd1e6804e1f11a33a948fcbf2dc0
parent765216340f6eb85c9872399a4d7056ace9927abd (diff)
downloadchromium_src-31d8f5f265d7e715f1555c42c10e6741976b1065.zip
chromium_src-31d8f5f265d7e715f1555c42c10e6741976b1065.tar.gz
chromium_src-31d8f5f265d7e715f1555c42c10e6741976b1065.tar.bz2
Reland 125805 - Reland 124817 - A profile-keyed service for Extensions, ExtensionSystem.
Move InitExtensions into ExtensionSystem. Remove a few accessors (ExtensionDevToolsManager, ExtensionMessageService). The others have too many callers to fix in one go. New since last time: Moved LazyBackgroundTaskQueue into ExtensionSystem. BUG=104095 TEST=Open and close an incognito window; should not crash. TBR=aa@chromium.org,akalin@chromium.org Review URL: https://chromiumcodereview.appspot.com/9959040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130128 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc4
-rw-r--r--chrome/browser/chrome_content_browser_client.cc6
-rw-r--r--chrome/browser/extensions/extension_devtools_bridge.cc5
-rw-r--r--chrome/browser/extensions/extension_event_router.cc8
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.h1
-rw-r--r--chrome/browser/extensions/extension_message_handler.cc9
-rw-r--r--chrome/browser/extensions/extension_service.cc16
-rw-r--r--chrome/browser/extensions/extension_service.h6
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc78
-rw-r--r--chrome/browser/extensions/extension_service_unittest.h2
-rw-r--r--chrome/browser/extensions/extension_system.cc291
-rw-r--r--chrome/browser/extensions/extension_system.h174
-rw-r--r--chrome/browser/extensions/extension_system_factory.cc87
-rw-r--r--chrome/browser/extensions/extension_system_factory.h56
-rw-r--r--chrome/browser/extensions/test_extension_system.cc103
-rw-r--r--chrome/browser/extensions/test_extension_system.h58
-rw-r--r--chrome/browser/extensions/updater/extension_updater_unittest.cc23
-rw-r--r--chrome/browser/intents/web_intents_registry_factory.cc3
-rw-r--r--chrome/browser/prerender/prerender_manager_factory.cc2
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc55
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h12
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl_unittest.cc8
-rw-r--r--chrome/browser/profiles/profile.h53
-rw-r--r--chrome/browser/profiles/profile_impl.cc178
-rw-r--r--chrome/browser/profiles/profile_impl.h36
-rw-r--r--chrome/browser/profiles/profile_io_data.cc5
-rw-r--r--chrome/browser/profiles/profile_manager.cc6
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.cc25
-rw-r--r--chrome/browser/sync/glue/extension_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/extension_setting_data_type_controller.cc5
-rw-r--r--chrome/browser/sync/glue/theme_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/profile_sync_service_factory.cc3
-rw-r--r--chrome/browser/sync/test/integration/sync_app_helper.cc6
-rw-r--r--chrome/browser/sync/test/integration/sync_extension_helper.cc4
-rw-r--r--chrome/browser/translate/translate_manager_browsertest.cc6
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm9
-rw-r--r--chrome/chrome_browser_extensions.gypi4
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/test/base/testing_profile.cc73
-rw-r--r--chrome/test/base/testing_profile.h28
40 files changed, 1000 insertions, 458 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index e55cc0c..3dabdfd 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -46,6 +46,8 @@
#include "chrome/browser/extensions/extension_install_ui.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/extensions/unpacked_installer.h"
@@ -927,7 +929,7 @@ void AutomationProvider::ExecuteExtensionActionInActiveTabAsync(
const Extension* extension = GetEnabledExtension(extension_handle);
ExtensionService* service = profile_->GetExtensionService();
ExtensionMessageService* message_service =
- profile_->GetExtensionMessageService();
+ ExtensionSystemFactory::GetForProfile(profile_)->message_service();
Browser* browser = browser_tracker_->GetResource(browser_handle);
if (extension && service && message_service && browser) {
int tab_id = ExtensionTabUtil::GetTabId(browser->GetSelectedWebContents());
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 40df6d2..578f549 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -31,6 +31,8 @@
#include "chrome/browser/extensions/extension_message_handler.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/extensions/extension_webkit_preferences.h"
#include "chrome/browser/geolocation/chrome_access_token_store.h"
@@ -621,7 +623,7 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
- profile->GetExtensionInfoMap(),
+ ExtensionSystemFactory::GetForProfile(profile)->info_map(),
extension->id(),
site_instance->GetProcess()->GetID(),
site_instance->GetId()));
@@ -650,7 +652,7 @@ void ChromeContentBrowserClient::SiteInstanceDeleting(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
- profile->GetExtensionInfoMap(),
+ ExtensionSystemFactory::GetForProfile(profile)->info_map(),
extension->id(),
site_instance->GetProcess()->GetID(),
site_instance->GetId()));
diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc
index b960117..2abf5bd 100644
--- a/chrome/browser/extensions/extension_devtools_bridge.cc
+++ b/chrome/browser/extensions/extension_devtools_bridge.cc
@@ -12,6 +12,8 @@
#include "chrome/browser/extensions/extension_devtools_events.h"
#include "chrome/browser/extensions/extension_devtools_manager.h"
#include "chrome/browser/extensions/extension_event_router.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -32,7 +34,8 @@ ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id,
ExtensionDevToolsEvents::OnPageEventNameForTab(tab_id)),
on_tab_close_event_name_(
ExtensionDevToolsEvents::OnTabCloseEventNameForTab(tab_id)) {
- extension_devtools_manager_ = profile_->GetExtensionDevToolsManager();
+ extension_devtools_manager_ =
+ ExtensionSystemFactory::GetForProfile(profile)->devtools_manager();
DCHECK(extension_devtools_manager_.get());
}
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc
index c2662b0..58902c1 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -15,6 +15,8 @@
#include "chrome/browser/extensions/extension_processes_api.h"
#include "chrome/browser/extensions/extension_processes_api_constants.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/lazy_background_task_queue.h"
#include "chrome/browser/extensions/process_map.h"
@@ -101,7 +103,8 @@ void ExtensionEventRouter::DispatchEvent(IPC::Message::Sender* ipc_sender,
ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
: profile_(profile),
- extension_devtools_manager_(profile->GetExtensionDevToolsManager()) {
+ extension_devtools_manager_(
+ ExtensionSystemFactory::GetForProfile(profile)->devtools_manager()) {
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
@@ -393,7 +396,8 @@ void ExtensionEventRouter::MaybeLoadLazyBackgroundPage(
return;
if (!CanDispatchEventNow(profile, extension)) {
- profile->GetLazyBackgroundTaskQueue()->AddPendingTask(
+ ExtensionSystemFactory::GetForProfile(profile)->
+ lazy_background_task_queue()->AddPendingTask(
profile, extension->id(),
base::Bind(&ExtensionEventRouter::DispatchPendingEvent,
base::Unretained(this), event));
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index 1fca5ad..13611ff 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -18,6 +18,7 @@ class Browser;
class ChromeRenderMessageFilter;
class Extension;
class ExtensionFunction;
+class ExtensionInfoMap;
class Profile;
struct ExtensionHostMsg_Request_Params;
diff --git a/chrome/browser/extensions/extension_message_handler.cc b/chrome/browser/extensions/extension_message_handler.cc
index 1317549..d55538e 100644
--- a/chrome/browser/extensions/extension_message_handler.cc
+++ b/chrome/browser/extensions/extension_message_handler.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/extensions/extension_message_handler.h"
#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/render_process_host.h"
@@ -38,8 +40,9 @@ void ExtensionMessageHandler::OnPostMessage(int port_id,
const std::string& message) {
Profile* profile = Profile::FromBrowserContext(
render_view_host()->GetProcess()->GetBrowserContext());
- if (profile->GetExtensionMessageService()) {
- profile->GetExtensionMessageService()->PostMessageFromRenderer(
- port_id, message);
+ ExtensionMessageService* message_service =
+ ExtensionSystemFactory::GetForProfile(profile)->message_service();
+ if (message_service) {
+ message_service->PostMessageFromRenderer(port_id, message);
}
}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 6923e15..1af45fd 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -53,6 +53,8 @@
#include "chrome/browser/extensions/extension_sorting.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/extensions/extension_sync_data.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/extensions/extension_webnavigation_api.h"
#include "chrome/browser/extensions/external_extension_provider_impl.h"
@@ -377,6 +379,7 @@ ExtensionService::ExtensionService(Profile* profile,
bool autoupdate_enabled,
bool extensions_enabled)
: profile_(profile),
+ system_(ExtensionSystemFactory::GetForProfile(profile)),
extension_prefs_(extension_prefs),
settings_frontend_(extensions::SettingsFrontend::Create(profile)),
pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)),
@@ -700,7 +703,8 @@ void ExtensionService::ReloadExtension(const std::string& extension_id) {
// If the extension has an inspector open for its background page, detach
// the inspector and hang onto a cookie for it, so that we can reattach
// later.
- ExtensionProcessManager* manager = profile_->GetExtensionProcessManager();
+ // TODO(yoz): this is not incognito-safe!
+ ExtensionProcessManager* manager = system_->process_manager();
ExtensionHost* host = manager->GetBackgroundHostForExtension(extension_id);
if (host && DevToolsAgentHostRegistry::HasDevToolsAgentHost(
host->render_view_host())) {
@@ -990,7 +994,7 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) {
// that the request context doesn't yet know about. The profile is responsible
// for ensuring its URLRequestContexts appropriately discover the loaded
// extension.
- profile_->RegisterExtensionWithRequestContexts(extension);
+ system_->RegisterExtensionWithRequestContexts(extension);
// Tell renderers about the new extension, unless it's a theme (renderers
// don't need to know about themes).
@@ -1137,7 +1141,7 @@ void ExtensionService::NotifyExtensionUnloaded(
host->Send(new ExtensionMsg_Unloaded(extension->id()));
}
- profile_->UnregisterExtensionWithRequestContexts(extension->id(), reason);
+ system_->UnregisterExtensionWithRequestContexts(extension->id(), reason);
profile_->GetExtensionSpecialStoragePolicy()->
RevokeRightsForExtension(extension);
@@ -1880,7 +1884,7 @@ void ExtensionService::UnloadExtension(
if (!extension) {
// In case the extension may have crashed/uninstalled. Allow the profile to
// clean up its RequestContexts.
- profile_->UnregisterExtensionWithRequestContexts(extension_id, reason);
+ system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
return;
}
@@ -1905,7 +1909,7 @@ if (disabled_extensions_.Contains(extension->id())) {
// Make sure the profile cleans up its RequestContexts when an already
// disabled extension is unloaded (since they are also tracking the disabled
// extensions).
- profile_->UnregisterExtensionWithRequestContexts(extension_id, reason);
+ system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
return;
}
@@ -2476,7 +2480,7 @@ void ExtensionService::Observe(int type,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess,
- profile_->GetExtensionInfoMap(),
+ system_->info_map(),
process->GetID()));
break;
}
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 15eef4ef..fb87340 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -57,6 +57,7 @@ class ExtensionGlobalError;
class ExtensionManagementEventRouter;
class ExtensionPreferenceEventRouter;
class ExtensionSyncData;
+class ExtensionSystem;
class ExtensionToolbarModel;
class ExtensionWebNavigationEventRouter;
class HistoryExtensionEventRouter;
@@ -701,9 +702,12 @@ class ExtensionService
NaClModuleInfoList::iterator FindNaClModule(const GURL& url);
- // The profile this ExtensionService is part of.
+ // The normal profile associated with this ExtensionService.
Profile* profile_;
+ // The ExtensionSystem for the profile above.
+ ExtensionSystem* system_;
+
// Preferences for the owning profile (weak reference).
ExtensionPrefs* extension_prefs_;
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index ee19e7f..2ed4b66 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -36,6 +36,8 @@
#include "chrome/browser/extensions/extension_sorting.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/extensions/extension_sync_data.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/external_extension_provider_impl.h"
#include "chrome/browser/extensions/external_extension_provider_interface.h"
#include "chrome/browser/extensions/external_pref_extension_loader.h"
@@ -43,6 +45,7 @@
#include "chrome/browser/extensions/pack_extension_job.cc"
#include "chrome/browser/extensions/pending_extension_info.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
+#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/plugin_prefs_factory.h"
@@ -50,6 +53,7 @@
#include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -372,20 +376,6 @@ class MockProviderVisitor
DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor);
};
-class ExtensionTestingProfile : public TestingProfile {
- public:
- ExtensionTestingProfile() : service_(NULL) {
- }
-
- void set_extensions_service(ExtensionService* service) {
- service_ = service;
- }
- virtual ExtensionService* GetExtensionService() { return service_; }
-
- private:
- ExtensionService* service_;
-};
-
// Our message loop may be used in tests which require it to be an IO loop.
ExtensionServiceTestBase::ExtensionServiceTestBase()
: loop_(MessageLoop::TYPE_IO),
@@ -418,7 +408,7 @@ ExtensionServiceTestBase::~ExtensionServiceTestBase() {
void ExtensionServiceTestBase::InitializeExtensionService(
const FilePath& pref_file, const FilePath& extensions_install_dir,
bool autoupdate_enabled) {
- ExtensionTestingProfile* profile = new ExtensionTestingProfile();
+ TestingProfile* profile = new TestingProfile();
// Create a PrefService that only contains user defined preference values.
PrefService* prefs =
PrefServiceMockBuilder().WithUserFilePrefs(pref_file).Create();
@@ -431,13 +421,13 @@ void ExtensionServiceTestBase::InitializeExtensionService(
profile_.reset(profile);
- service_ = profile->CreateExtensionService(
- CommandLine::ForCurrentProcess(),
- extensions_install_dir,
- autoupdate_enabled);
+ service_ = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile))->CreateExtensionService(
+ CommandLine::ForCurrentProcess(),
+ extensions_install_dir,
+ autoupdate_enabled);
service_->set_extensions_enabled(true);
service_->set_show_extensions_prompts(false);
- profile->set_extensions_service(service_);
// When we start up, we want to make sure there is no external provider,
// since the ExtensionService on Windows will use the Registry as a default
@@ -471,7 +461,9 @@ void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
}
void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
- profile_->CreateExtensionProcessManager();
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile_.get()))->
+ CreateExtensionProcessManager();
}
void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
@@ -498,8 +490,8 @@ void ExtensionServiceTestBase::InitializeExtensionServiceHelper(
void ExtensionServiceTestBase::InitializeRequestContext() {
ASSERT_TRUE(profile_.get());
- ExtensionTestingProfile* profile =
- static_cast<ExtensionTestingProfile*>(profile_.get());
+ TestingProfile* profile =
+ static_cast<TestingProfile*>(profile_.get());
profile->CreateRequestContext();
}
@@ -746,7 +738,7 @@ class ExtensionServiceTest
enabled_extension_count);
}
- // Update() should delete the temporary input file.
+ // Update() should the temporary input file.
EXPECT_FALSE(file_util::PathExists(path));
}
@@ -3862,11 +3854,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
// By default, we are enabled.
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- // Owned by |profile|.
- ExtensionService* service =
- profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ ExtensionService* service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_TRUE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3876,9 +3869,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
recorder.set_ready(false);
profile.reset(new TestingProfile());
command_line->AppendSwitch(switches::kDisableExtensions);
- service = profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3887,9 +3883,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
recorder.set_ready(false);
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
- service = profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3899,9 +3898,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- service = profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
diff --git a/chrome/browser/extensions/extension_service_unittest.h b/chrome/browser/extensions/extension_service_unittest.h
index 613761b..f4267d0 100644
--- a/chrome/browser/extensions/extension_service_unittest.h
+++ b/chrome/browser/extensions/extension_service_unittest.h
@@ -55,7 +55,7 @@ class ExtensionServiceTestBase : public testing::Test {
scoped_ptr<TestingProfile> profile_;
FilePath extensions_install_dir_;
FilePath data_dir_;
- // Owned by |profile_|.
+ // Managed by ExtensionSystemFactory.
ExtensionService* service_;
size_t expected_extensions_count_;
content::TestBrowserThread ui_thread_;
diff --git a/chrome/browser/extensions/extension_system.cc b/chrome/browser/extensions/extension_system.cc
new file mode 100644
index 0000000..6e4da65
--- /dev/null
+++ b/chrome/browser/extensions/extension_system.cc
@@ -0,0 +1,291 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_system.h"
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/string_tokenizer.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/component_loader.h"
+#include "chrome/browser/content_settings/cookie_settings.h"
+#include "chrome/browser/extensions/extension_devtools_manager.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
+#include "chrome/browser/extensions/extension_event_router.h"
+#include "chrome/browser/extensions/extension_info_map.h"
+#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_navigation_observer.h"
+#include "chrome/browser/extensions/extension_pref_store.h"
+#include "chrome/browser/extensions/extension_pref_value_map.h"
+#include "chrome/browser/extensions/extension_process_manager.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
+#include "chrome/browser/extensions/lazy_background_task_queue.h"
+#include "chrome/browser/extensions/unpacked_installer.h"
+#include "chrome/browser/extensions/user_script_master.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/pref_names.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+//
+// ExtensionSystem
+//
+
+ExtensionSystem::ExtensionSystem() {
+}
+
+ExtensionSystem::~ExtensionSystem() {
+}
+
+//
+// ExtensionSystemImpl::Shared
+//
+
+ExtensionSystemImpl::Shared::Shared(Profile* profile)
+ : profile_(profile) {
+}
+
+ExtensionSystemImpl::Shared::~Shared() {
+}
+
+void ExtensionSystemImpl::Shared::InitPrefs() {
+ bool extensions_disabled =
+ profile_->GetPrefs()->GetBoolean(prefs::kDisableExtensions) ||
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions);
+ extension_prefs_.reset(new ExtensionPrefs(
+ profile_->GetPrefs(),
+ profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
+ profile_->GetExtensionPrefValueMap()));
+ extension_prefs_->Init(extensions_disabled);
+}
+
+void ExtensionSystemImpl::Shared::InitInfoMap() {
+ // The ExtensionInfoMap needs to be created before the
+ // ExtensionProcessManager.
+ extension_info_map_ = new ExtensionInfoMap();
+}
+
+void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+
+ lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_));
+ extension_event_router_.reset(new ExtensionEventRouter(profile_));
+ extension_message_service_.reset(new ExtensionMessageService(
+ lazy_background_task_queue_.get()));
+ extension_navigation_observer_.reset(
+ new ExtensionNavigationObserver(profile_));
+
+ ExtensionErrorReporter::Init(true); // allow noisy errors.
+
+ user_script_master_ = new UserScriptMaster(profile_);
+
+ bool autoupdate_enabled = true;
+#if defined(OS_CHROMEOS)
+ if (!extensions_enabled)
+ autoupdate_enabled = false;
+ else
+ autoupdate_enabled = !command_line->HasSwitch(switches::kGuestSession);
+#endif
+ extension_service_.reset(new ExtensionService(
+ profile_,
+ CommandLine::ForCurrentProcess(),
+ profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
+ extension_prefs_.get(),
+ autoupdate_enabled,
+ extensions_enabled));
+
+ extension_service_->component_loader()->AddDefaultComponentExtensions();
+ if (command_line->HasSwitch(switches::kLoadComponentExtension)) {
+ CommandLine::StringType path_list = command_line->GetSwitchValueNative(
+ switches::kLoadComponentExtension);
+ StringTokenizerT<CommandLine::StringType,
+ CommandLine::StringType::const_iterator> t(path_list,
+ FILE_PATH_LITERAL(","));
+ while (t.GetNext()) {
+ // Load the component extension manifest synchronously.
+ // Blocking the UI thread is acceptable here since
+ // this flag designated for developers.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ extension_service_->component_loader()->AddOrReplace(
+ FilePath(t.token()));
+ }
+ }
+ extension_service_->Init();
+
+ if (extensions_enabled) {
+ // Load any extensions specified with --load-extension.
+ // TODO(yoz): Seems like this should move into ExtensionService::Init.
+ // But maybe it's no longer important.
+ if (command_line->HasSwitch(switches::kLoadExtension)) {
+ CommandLine::StringType path_list = command_line->GetSwitchValueNative(
+ switches::kLoadExtension);
+ StringTokenizerT<CommandLine::StringType,
+ CommandLine::StringType::const_iterator> t(path_list,
+ FILE_PATH_LITERAL(","));
+ scoped_refptr<extensions::UnpackedInstaller> installer =
+ extensions::UnpackedInstaller::Create(extension_service_.get());
+ while (t.GetNext()) {
+ installer->LoadFromCommandLine(FilePath(t.token()));
+ }
+ }
+ }
+
+ // Make the chrome://extension-icon/ resource available.
+ profile_->GetChromeURLDataManager()->AddDataSource(
+ new ExtensionIconSource(profile_));
+
+ // Initialize extension event routers. Note that on Chrome OS, this will
+ // not succeed if the user has not logged in yet, in which case the
+ // event routers are initialized in LoginUtilsImpl::CompleteLogin instead.
+ // The InitEventRouters call used to be in BrowserMain, because when bookmark
+ // import happened on first run, the bookmark bar was not being correctly
+ // initialized (see issue 40144). Now that bookmarks aren't imported and
+ // the event routers need to be initialized for every profile individually,
+ // initialize them with the extension service.
+ // If this profile is being created as part of the import process, never
+ // initialize the event routers. If import is going to run in a separate
+ // process (the profile itself is on the main process), wait for import to
+ // finish before initializing the routers.
+ if (!command_line->HasSwitch(switches::kImport) &&
+ !command_line->HasSwitch(switches::kImportFromFile)) {
+ if (g_browser_process->profile_manager()->will_import()) {
+ extension_service_->InitEventRoutersAfterImport();
+ } else {
+ extension_service_->InitEventRouters();
+ }
+ }
+}
+
+ExtensionService* ExtensionSystemImpl::Shared::extension_service() {
+ return extension_service_.get();
+}
+
+UserScriptMaster* ExtensionSystemImpl::Shared::user_script_master() {
+ return user_script_master_.get();
+}
+
+ExtensionInfoMap* ExtensionSystemImpl::Shared::info_map() {
+ return extension_info_map_.get();
+}
+
+LazyBackgroundTaskQueue*
+ExtensionSystemImpl::Shared::lazy_background_task_queue() {
+ return lazy_background_task_queue_.get();
+}
+
+ExtensionMessageService* ExtensionSystemImpl::Shared::message_service() {
+ return extension_message_service_.get();
+}
+
+ExtensionEventRouter* ExtensionSystemImpl::Shared::event_router() {
+ return extension_event_router_.get();
+}
+
+//
+// ExtensionSystemImpl
+//
+
+ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile)
+ : profile_(profile),
+ extension_devtools_manager_(NULL) {
+ shared_ = ExtensionSystemSharedFactory::GetForProfile(profile);
+
+ if (profile->IsOffTheRecord()) {
+ extension_process_manager_.reset(ExtensionProcessManager::Create(profile));
+ } else {
+ shared_->InitPrefs();
+ }
+}
+
+ExtensionSystemImpl::~ExtensionSystemImpl() {
+}
+
+void ExtensionSystemImpl::Shutdown() {
+ extension_process_manager_.reset();
+}
+
+void ExtensionSystemImpl::Init(bool extensions_enabled) {
+ DCHECK(!profile_->IsOffTheRecord());
+ if (user_script_master() || extension_service())
+ return; // Already initialized.
+
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(
+ switches::kEnableExtensionTimelineApi)) {
+ extension_devtools_manager_ = new ExtensionDevToolsManager(profile_);
+ }
+
+ shared_->InitInfoMap();
+
+ extension_process_manager_.reset(ExtensionProcessManager::Create(profile_));
+
+ shared_->Init(extensions_enabled);
+}
+
+ExtensionService* ExtensionSystemImpl::extension_service() {
+ return shared_->extension_service();
+}
+
+UserScriptMaster* ExtensionSystemImpl::user_script_master() {
+ return shared_->user_script_master();
+}
+
+ExtensionDevToolsManager* ExtensionSystemImpl::devtools_manager() {
+ // TODO(mpcomplete): in incognito, figure out whether we should
+ // return the original profile's version.
+ return extension_devtools_manager_.get();
+}
+
+ExtensionProcessManager* ExtensionSystemImpl::process_manager() {
+ return extension_process_manager_.get();
+}
+
+ExtensionInfoMap* ExtensionSystemImpl::info_map() {
+ return shared_->info_map();
+}
+
+LazyBackgroundTaskQueue* ExtensionSystemImpl::lazy_background_task_queue() {
+ return shared_->lazy_background_task_queue();
+}
+
+ExtensionMessageService* ExtensionSystemImpl::message_service() {
+ return shared_->message_service();
+}
+
+ExtensionEventRouter* ExtensionSystemImpl::event_router() {
+ return shared_->event_router();
+}
+
+void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
+ const Extension* extension) {
+ base::Time install_time;
+ if (extension->location() != Extension::COMPONENT) {
+ install_time = extension_service()->extension_prefs()->
+ GetInstallTime(extension->id());
+ }
+ bool incognito_enabled =
+ extension_service()->IsIncognitoEnabled(extension->id());
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ExtensionInfoMap::AddExtension, info_map(),
+ make_scoped_refptr(extension), install_time,
+ incognito_enabled));
+}
+
+void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
+ const std::string& extension_id,
+ const extension_misc::UnloadedExtensionReason reason) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ExtensionInfoMap::RemoveExtension, info_map(),
+ extension_id, reason));
+}
diff --git a/chrome/browser/extensions/extension_system.h b/chrome/browser/extensions/extension_system.h
new file mode 100644
index 0000000..3ed5002
--- /dev/null
+++ b/chrome/browser/extensions/extension_system.h
@@ -0,0 +1,174 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
+#pragma once
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "chrome/common/extensions/extension_constants.h"
+
+class Extension;
+class ExtensionDevToolsManager;
+class ExtensionEventRouter;
+class ExtensionInfoMap;
+class ExtensionMessageService;
+class ExtensionNavigationObserver;
+class ExtensionPrefs;
+class ExtensionPrefValueMap;
+class ExtensionProcessManager;
+class ExtensionService;
+class LazyBackgroundTaskQueue;
+class Profile;
+class UserScriptMaster;
+
+// The ExtensionSystem manages the creation and destruction of services
+// related to extensions. Most objects are shared between normal
+// and incognito Profiles, except as called out in comments.
+// This interface supports using TestExtensionSystem for TestingProfiles
+// that don't want all of the extensions baggage in their tests.
+class ExtensionSystem : public ProfileKeyedService {
+ public:
+ ExtensionSystem();
+ virtual ~ExtensionSystem();
+
+ // ProfileKeyedService implementation.
+ virtual void Shutdown() OVERRIDE {}
+
+ // Initializes extensions machinery.
+ // Component extensions are always enabled, external and user extensions
+ // are controlled by |extensions_enabled|.
+ virtual void Init(bool extensions_enabled) = 0;
+
+ // The ExtensionService is created at startup.
+ virtual ExtensionService* extension_service() = 0;
+
+ // The ExtensionDevToolsManager is created at startup.
+ virtual ExtensionDevToolsManager* devtools_manager() = 0;
+
+ // The UserScriptMaster is created at startup.
+ virtual UserScriptMaster* user_script_master() = 0;
+
+ // The ExtensionProcessManager is created at startup.
+ virtual ExtensionProcessManager* process_manager() = 0;
+
+ // Returns the IO-thread-accessible extension data.
+ virtual ExtensionInfoMap* info_map() = 0;
+
+ // The LazyBackgroundTaskQueue is created at startup.
+ virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0;
+
+ // The ExtensionMessageService is created at startup.
+ virtual ExtensionMessageService* message_service() = 0;
+
+ // The ExtensionEventRouter is created at startup.
+ virtual ExtensionEventRouter* event_router() = 0;
+
+ // Called by the ExtensionService that lives in this system. Gives the
+ // info map a chance to react to the load event before the EXTENSION_LOADED
+ // notification has fired. The purpose for handling this event first is to
+ // avoid race conditions by making sure URLRequestContexts learn about new
+ // extensions before anything else needs them to know.
+ virtual void RegisterExtensionWithRequestContexts(
+ const Extension* extension) {}
+
+ // Called by the ExtensionService that lives in this system. Lets the
+ // info map clean up its RequestContexts once all the listeners to the
+ // EXTENSION_UNLOADED notification have finished running.
+ virtual void UnregisterExtensionWithRequestContexts(
+ const std::string& extension_id,
+ const extension_misc::UnloadedExtensionReason reason) {}
+};
+
+// The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
+// Implementation details: non-shared services are owned by
+// ExtensionSystemImpl, a ProfileKeyedService with separate incognito
+// instances. A private Shared class (also a ProfileKeyedService,
+// but with a shared instance for incognito) keeps the common services.
+class ExtensionSystemImpl : public ExtensionSystem {
+ public:
+ explicit ExtensionSystemImpl(Profile* profile);
+ virtual ~ExtensionSystemImpl();
+
+ // ProfileKeyedService implementation.
+ virtual void Shutdown() OVERRIDE;
+
+ virtual void Init(bool extensions_enabled) OVERRIDE;
+
+ virtual ExtensionService* extension_service() OVERRIDE; // shared
+ virtual UserScriptMaster* user_script_master() OVERRIDE; // shared
+ virtual ExtensionDevToolsManager* devtools_manager() OVERRIDE;
+ virtual ExtensionProcessManager* process_manager() OVERRIDE;
+ virtual LazyBackgroundTaskQueue* lazy_background_task_queue()
+ OVERRIDE; // shared
+ virtual ExtensionInfoMap* info_map() OVERRIDE; // shared
+ virtual ExtensionMessageService* message_service() OVERRIDE; // shared
+ virtual ExtensionEventRouter* event_router() OVERRIDE; // shared
+
+ virtual void RegisterExtensionWithRequestContexts(
+ const Extension* extension) OVERRIDE;
+
+ virtual void UnregisterExtensionWithRequestContexts(
+ const std::string& extension_id,
+ const extension_misc::UnloadedExtensionReason reason) OVERRIDE;
+
+ private:
+ friend class ExtensionSystemSharedFactory;
+
+ // Owns the Extension-related systems that have a single instance
+ // shared between normal and incognito profiles.
+ class Shared : public ProfileKeyedService {
+ public:
+ explicit Shared(Profile* profile);
+ virtual ~Shared();
+
+ // Initialization takes place in phases.
+ virtual void InitPrefs();
+ void InitInfoMap();
+ void Init(bool extensions_enabled);
+
+ ExtensionService* extension_service();
+ UserScriptMaster* user_script_master();
+ ExtensionInfoMap* info_map();
+ LazyBackgroundTaskQueue* lazy_background_task_queue();
+ ExtensionMessageService* message_service();
+ ExtensionEventRouter* event_router();
+
+ private:
+ Profile* profile_;
+
+ // The services that are shared between normal and incognito profiles.
+
+ // Keep extension_prefs_ on top of extension_service_ because the latter
+ // maintains a pointer to the first and shall be destructed first.
+ scoped_ptr<ExtensionPrefs> extension_prefs_;
+ scoped_ptr<ExtensionService> extension_service_;
+ scoped_refptr<UserScriptMaster> user_script_master_;
+ // extension_info_map_ needs to outlive extension_process_manager_.
+ scoped_refptr<ExtensionInfoMap> extension_info_map_;
+ // This is a dependency of ExtensionMessageService and ExtensionEventRouter.
+ scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_;
+ scoped_ptr<ExtensionMessageService> extension_message_service_;
+ scoped_ptr<ExtensionEventRouter> extension_event_router_;
+ scoped_ptr<ExtensionNavigationObserver> extension_navigation_observer_;
+ };
+
+ Profile* profile_;
+
+ Shared* shared_;
+
+ // The services that have their own instances in incognito.
+ scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
+ // |extension_process_manager_| must be destroyed before the Profile's
+ // |io_data_|. While |extension_process_manager_| still lives, we handle
+ // incoming resource requests from extension processes and those require
+ // access to the ResourceContext owned by |io_data_|.
+ scoped_ptr<ExtensionProcessManager> extension_process_manager_;
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
diff --git a/chrome/browser/extensions/extension_system_factory.cc b/chrome/browser/extensions/extension_system_factory.cc
new file mode 100644
index 0000000..956e735
--- /dev/null
+++ b/chrome/browser/extensions/extension_system_factory.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_system_factory.h"
+
+#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/browser/ui/global_error_service_factory.h"
+
+// ExtensionSystemSharedFactory
+
+// static
+ExtensionSystemImpl::Shared* ExtensionSystemSharedFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<ExtensionSystemImpl::Shared*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() {
+ return Singleton<ExtensionSystemSharedFactory>::get();
+}
+
+ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
+ : ProfileKeyedServiceFactory(
+ "ExtensionSystemShared",
+ ProfileDependencyManager::GetInstance()) {
+ DependsOn(GlobalErrorServiceFactory::GetInstance());
+ DependsOn(TemplateURLServiceFactory::GetInstance());
+ DependsOn(ThemeServiceFactory::GetInstance());
+}
+
+ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
+}
+
+ProfileKeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new ExtensionSystemImpl::Shared(profile);
+}
+
+bool ExtensionSystemSharedFactory::ServiceRedirectedInIncognito() {
+ return true;
+}
+
+// ExtensionSystemFactory
+
+// static
+ExtensionSystem* ExtensionSystemFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<ExtensionSystem*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() {
+ return Singleton<ExtensionSystemFactory>::get();
+}
+
+ExtensionSystemFactory::ExtensionSystemFactory()
+ : ProfileKeyedServiceFactory(
+ "ExtensionSystem",
+ ProfileDependencyManager::GetInstance()) {
+ DependsOn(ExtensionSystemSharedFactory::GetInstance());
+}
+
+ExtensionSystemFactory::~ExtensionSystemFactory() {
+}
+
+ProfileKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new ExtensionSystemImpl(profile);
+}
+
+bool ExtensionSystemFactory::ServiceHasOwnInstanceInIncognito() {
+ return true;
+}
+
+bool ExtensionSystemFactory::ServiceIsCreatedWithProfile() {
+ return true;
+}
diff --git a/chrome/browser/extensions/extension_system_factory.h b/chrome/browser/extensions/extension_system_factory.h
new file mode 100644
index 0000000..a6c0c9e
--- /dev/null
+++ b/chrome/browser/extensions/extension_system_factory.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_FACTORY_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_FACTORY_H_
+#pragma once
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+
+class ExtensionSystem;
+class Profile;
+class ProfileKeyedService;
+
+// ProfileKeyedServiceFactory for ExtensionSystemImpl::Shared.
+// Should not be used except by ExtensionSystem(Factory).
+class ExtensionSystemSharedFactory : public ProfileKeyedServiceFactory {
+ public:
+ static ExtensionSystemImpl::Shared* GetForProfile(Profile* profile);
+
+ static ExtensionSystemSharedFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<ExtensionSystemSharedFactory>;
+
+ ExtensionSystemSharedFactory();
+ virtual ~ExtensionSystemSharedFactory();
+
+ virtual ProfileKeyedService* BuildServiceInstanceFor(
+ Profile* profile) const OVERRIDE;
+ virtual bool ServiceRedirectedInIncognito() OVERRIDE;
+};
+
+// ProfileKeyedServiceFactory for ExtensionSystem.
+class ExtensionSystemFactory : public ProfileKeyedServiceFactory {
+ public:
+ // ProfileKeyedServiceFactory implementation:
+ static ExtensionSystem* GetForProfile(Profile* profile);
+
+ static ExtensionSystemFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<ExtensionSystemFactory>;
+
+ ExtensionSystemFactory();
+ virtual ~ExtensionSystemFactory();
+
+ virtual ProfileKeyedService* BuildServiceInstanceFor(
+ Profile* profile) const OVERRIDE;
+ virtual bool ServiceHasOwnInstanceInIncognito() OVERRIDE;
+ virtual bool ServiceIsCreatedWithProfile() OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_FACTORY_H_
diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc
new file mode 100644
index 0000000..07e7522
--- /dev/null
+++ b/chrome/browser/extensions/test_extension_system.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/test_extension_system.h"
+
+#include "chrome/browser/extensions/extension_devtools_manager.h"
+#include "chrome/browser/extensions/extension_event_router.h"
+#include "chrome/browser/extensions/extension_info_map.h"
+#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_pref_value_map.h"
+#include "chrome/browser/extensions/extension_process_manager.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/user_script_master.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_switches.h"
+
+
+TestExtensionSystem::TestExtensionSystem(Profile* profile)
+ : profile_(profile) {
+}
+
+TestExtensionSystem::~TestExtensionSystem() {
+}
+
+void TestExtensionSystem::Shutdown() {
+ extension_process_manager_.reset();
+}
+
+void TestExtensionSystem::CreateExtensionProcessManager() {
+ extension_process_manager_.reset(ExtensionProcessManager::Create(profile_));
+}
+
+ExtensionService* TestExtensionSystem::CreateExtensionService(
+ const CommandLine* command_line,
+ const FilePath& install_directory,
+ bool autoupdate_enabled) {
+ // Extension pref store, created for use by |extension_prefs_|.
+ extension_pref_value_map_.reset(new ExtensionPrefValueMap);
+
+ bool extensions_disabled =
+ command_line && command_line->HasSwitch(switches::kDisableExtensions);
+
+ // Note that the GetPrefs() creates a TestingPrefService, therefore
+ // the extension controlled pref values set in extension_prefs_
+ // are not reflected in the pref service. One would need to
+ // inject a new ExtensionPrefStore(extension_pref_value_map_.get(), false).
+
+ extension_prefs_.reset(
+ new ExtensionPrefs(profile_->GetPrefs(),
+ install_directory,
+ extension_pref_value_map_.get()));
+ extension_prefs_->Init(extensions_disabled);
+ extension_service_.reset(new ExtensionService(profile_,
+ command_line,
+ install_directory,
+ extension_prefs_.get(),
+ autoupdate_enabled,
+ true));
+ return extension_service_.get();
+}
+
+ExtensionService* TestExtensionSystem::extension_service() {
+ return extension_service_.get();
+}
+
+void TestExtensionSystem::SetExtensionService(ExtensionService* service) {
+ extension_service_.reset(service);
+}
+
+UserScriptMaster* TestExtensionSystem::user_script_master() {
+ return NULL;
+}
+
+ExtensionDevToolsManager* TestExtensionSystem::devtools_manager() {
+ return NULL;
+}
+
+ExtensionProcessManager* TestExtensionSystem::process_manager() {
+ return extension_process_manager_.get();
+}
+
+ExtensionInfoMap* TestExtensionSystem::info_map() {
+ return NULL;
+}
+
+LazyBackgroundTaskQueue* TestExtensionSystem::lazy_background_task_queue() {
+ return NULL;
+}
+
+ExtensionMessageService* TestExtensionSystem::message_service() {
+ return NULL;
+}
+
+ExtensionEventRouter* TestExtensionSystem::event_router() {
+ return NULL;
+}
+
+// static
+ProfileKeyedService* TestExtensionSystem::Build(Profile* profile) {
+ return new TestExtensionSystem(profile);
+}
diff --git a/chrome/browser/extensions/test_extension_system.h b/chrome/browser/extensions/test_extension_system.h
new file mode 100644
index 0000000..c739c69
--- /dev/null
+++ b/chrome/browser/extensions/test_extension_system.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
+#define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
+#pragma once
+
+#include "chrome/browser/extensions/extension_system.h"
+
+class CommandLine;
+class FilePath;
+
+// Test ExtensionSystem, for use with TestingProfile.
+class TestExtensionSystem : public ExtensionSystem {
+ public:
+ explicit TestExtensionSystem(Profile* profile);
+ virtual ~TestExtensionSystem();
+
+ // ProfileKeyedService implementation.
+ virtual void Shutdown() OVERRIDE;
+
+ // Creates an ExtensionService initialized with the testing profile and
+ // returns it.
+ ExtensionService* CreateExtensionService(const CommandLine* command_line,
+ const FilePath& install_directory,
+ bool autoupdate_enabled);
+
+ // Creates an ExtensionProcessManager. If not invoked, the
+ // ExtensionProcessManager is NULL.
+ void CreateExtensionProcessManager();
+
+ virtual void Init(bool extensions_enabled) OVERRIDE {}
+ virtual ExtensionService* extension_service() OVERRIDE;
+ void SetExtensionService(ExtensionService* service);
+ virtual UserScriptMaster* user_script_master() OVERRIDE;
+ virtual ExtensionDevToolsManager* devtools_manager() OVERRIDE;
+ virtual ExtensionProcessManager* process_manager() OVERRIDE;
+ virtual ExtensionInfoMap* info_map() OVERRIDE;
+ virtual LazyBackgroundTaskQueue* lazy_background_task_queue() OVERRIDE;
+ virtual ExtensionMessageService* message_service() OVERRIDE;
+ virtual ExtensionEventRouter* event_router() OVERRIDE;
+
+ // Factory method for tests to use with SetTestingProfile.
+ static ProfileKeyedService* Build(Profile* profile);
+
+ private:
+ Profile* profile_;
+
+ scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
+ // The Extension Preferences. Only created if CreateExtensionService is
+ // invoked.
+ scoped_ptr<ExtensionPrefs> extension_prefs_;
+ scoped_ptr<ExtensionService> extension_service_;
+ scoped_ptr<ExtensionProcessManager> extension_process_manager_;
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc
index 1d7d2c6..d8ee50a 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -20,8 +20,11 @@
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/extension_sync_data.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/test_extension_prefs.h"
#include "chrome/browser/extensions/test_extension_service.h"
+#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/extensions/updater/extension_downloader.h"
#include "chrome/browser/extensions/updater/extension_downloader_delegate.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
@@ -983,17 +986,21 @@ class ExtensionUpdaterTest : public testing::Test {
// service, not on our mock |service|. This allows us to fake
// the CrxInstaller actions we want.
TestingProfile profile;
- profile.CreateExtensionService(
- CommandLine::ForCurrentProcess(),
- FilePath(),
- false);
- profile.GetExtensionService()->set_extensions_enabled(true);
- profile.GetExtensionService()->set_show_extensions_prompts(false);
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(&profile))->
+ CreateExtensionService(
+ CommandLine::ForCurrentProcess(),
+ FilePath(),
+ false);
+ ExtensionService* extension_service =
+ ExtensionSystemFactory::GetForProfile(&profile)->extension_service();
+ extension_service->set_extensions_enabled(true);
+ extension_service->set_show_extensions_prompts(false);
scoped_refptr<CrxInstaller> fake_crx1(
- CrxInstaller::Create(profile.GetExtensionService(), NULL));
+ CrxInstaller::Create(extension_service, NULL));
scoped_refptr<CrxInstaller> fake_crx2(
- CrxInstaller::Create(profile.GetExtensionService(), NULL));
+ CrxInstaller::Create(extension_service, NULL));
if (updates_start_running) {
// Add fake CrxInstaller to be returned by service.UpdateExtension().
diff --git a/chrome/browser/intents/web_intents_registry_factory.cc b/chrome/browser/intents/web_intents_registry_factory.cc
index 2b22286..94d869f 100644
--- a/chrome/browser/intents/web_intents_registry_factory.cc
+++ b/chrome/browser/intents/web_intents_registry_factory.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/intents/web_intents_registry_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -18,7 +19,7 @@ WebIntentsRegistryFactory::WebIntentsRegistryFactory()
ProfileDependencyManager::GetInstance()) {
// TODO(erg): For Shutdown() order, we need to:
// DependsOn(WebDataServiceFactory::GetInstance());
- // DependsOn(ExtensionServiceFactory::GetInstance());
+ DependsOn(ExtensionSystemFactory::GetInstance());
}
WebIntentsRegistryFactory::~WebIntentsRegistryFactory() {
diff --git a/chrome/browser/prerender/prerender_manager_factory.cc b/chrome/browser/prerender/prerender_manager_factory.cc
index 8065d79..543b99e 100644
--- a/chrome/browser/prerender/prerender_manager_factory.cc
+++ b/chrome/browser/prerender/prerender_manager_factory.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
@@ -32,6 +33,7 @@ PrerenderManagerFactory* PrerenderManagerFactory::GetInstance() {
PrerenderManagerFactory::PrerenderManagerFactory()
: ProfileKeyedServiceFactory("PrerenderManager",
ProfileDependencyManager::GetInstance()) {
+ DependsOn(ExtensionSystemFactory::GetInstance());
}
PrerenderManagerFactory::~PrerenderManagerFactory() {
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index ade048d..bcfc9f5 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -21,11 +21,13 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/api/web_request/web_request_api.h"
#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_pref_store.h"
+#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/plugin_prefs.h"
@@ -85,8 +87,6 @@ OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile)
}
void OffTheRecordProfileImpl::Init() {
- extension_process_manager_.reset(ExtensionProcessManager::Create(this));
-
ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false);
DCHECK_NE(IncognitoModePrefs::DISABLED,
@@ -122,6 +122,13 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
io_data_.GetResourceContextNoInit());
+ ExtensionService* extension_service =
+ ExtensionSystemFactory::GetForProfile(this)->extension_service();
+ if (extension_service && extension_service->extensions_enabled()) {
+ extension_service->extension_prefs()->
+ ClearIncognitoSessionOnlyContentSettings();
+ }
+
ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
BrowserThread::PostTask(
@@ -134,12 +141,6 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
if (pref_proxy_config_tracker_.get())
pref_proxy_config_tracker_->DetachFromPrefService();
- ExtensionService* extension_service = GetExtensionService();
- if (extension_service && extension_service->extensions_enabled()) {
- ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
- extension_prefs->ClearIncognitoSessionOnlyContentSettings();
- }
-
// Clears any data the network stack contains that may be related to the
// OTR session.
g_browser_process->io_thread()->ChangedToOnTheRecord();
@@ -192,33 +193,25 @@ VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() {
return NULL;
}
-ExtensionService* OffTheRecordProfileImpl::GetExtensionService() {
- return GetOriginalProfile()->GetExtensionService();
+ExtensionPrefValueMap* OffTheRecordProfileImpl::GetExtensionPrefValueMap() {
+ return NULL;
}
-UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() {
- return GetOriginalProfile()->GetUserScriptMaster();
+ExtensionService* OffTheRecordProfileImpl::GetExtensionService() {
+ return ExtensionSystemFactory::GetForProfile(this)->extension_service();
}
-ExtensionDevToolsManager*
- OffTheRecordProfileImpl::GetExtensionDevToolsManager() {
- // TODO(mpcomplete): figure out whether we should return the original
- // profile's version.
- return NULL;
+UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() {
+ return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
}
ExtensionProcessManager*
OffTheRecordProfileImpl::GetExtensionProcessManager() {
- return extension_process_manager_.get();
-}
-
-ExtensionMessageService*
- OffTheRecordProfileImpl::GetExtensionMessageService() {
- return GetOriginalProfile()->GetExtensionMessageService();
+ return ExtensionSystemFactory::GetForProfile(this)->process_manager();
}
ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() {
- return GetOriginalProfile()->GetExtensionEventRouter();
+ return ExtensionSystemFactory::GetForProfile(this)->event_router();
}
ExtensionSpecialStoragePolicy*
@@ -226,10 +219,6 @@ ExtensionSpecialStoragePolicy*
return GetOriginalProfile()->GetExtensionSpecialStoragePolicy();
}
-LazyBackgroundTaskQueue* OffTheRecordProfileImpl::GetLazyBackgroundTaskQueue() {
- return GetOriginalProfile()->GetLazyBackgroundTaskQueue();
-}
-
GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() {
return NULL;
}
@@ -398,10 +387,6 @@ history::TopSites* OffTheRecordProfileImpl::GetTopSites() {
void OffTheRecordProfileImpl::MarkAsCleanShutdown() {
}
-void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) {
- NOTREACHED();
-}
-
void OffTheRecordProfileImpl::InitPromoResources() {
NOTREACHED();
}
@@ -439,10 +424,6 @@ void OffTheRecordProfileImpl::InitChromeOSPreferences() {
}
#endif // defined(OS_CHROMEOS)
-ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() {
- return profile_->GetExtensionInfoMap();
-}
-
ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() {
if (!chrome_url_data_manager_.get())
chrome_url_data_manager_.reset(new ChromeURLDataManager(
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index 78016dd..d5e6c30 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -40,15 +40,13 @@ class OffTheRecordProfileImpl : public Profile,
virtual bool HasOffTheRecordProfile() OVERRIDE;
virtual Profile* GetOriginalProfile() OVERRIDE;
virtual VisitedLinkMaster* GetVisitedLinkMaster() OVERRIDE;
+ virtual ExtensionPrefValueMap* GetExtensionPrefValueMap() OVERRIDE;
virtual ExtensionService* GetExtensionService() OVERRIDE;
virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE;
- virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() OVERRIDE;
virtual ExtensionProcessManager* GetExtensionProcessManager() OVERRIDE;
- virtual ExtensionMessageService* GetExtensionMessageService() OVERRIDE;
virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE;
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() OVERRIDE;
- virtual LazyBackgroundTaskQueue* GetLazyBackgroundTaskQueue() OVERRIDE;
virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() OVERRIDE;
virtual HistoryService* GetHistoryService(ServiceAccessType sat) OVERRIDE;
virtual HistoryService* GetHistoryServiceWithoutCreating() OVERRIDE;
@@ -74,7 +72,6 @@ class OffTheRecordProfileImpl : public Profile,
virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE;
virtual history::TopSites* GetTopSites() OVERRIDE;
virtual void MarkAsCleanShutdown() OVERRIDE;
- virtual void InitExtensions(bool extensions_enabled) OVERRIDE;
virtual void InitPromoResources() OVERRIDE;
virtual void InitRegisteredProtocolHandlers() OVERRIDE;
virtual FilePath last_selected_directory() OVERRIDE;
@@ -85,8 +82,6 @@ class OffTheRecordProfileImpl : public Profile,
virtual void SetupChromeOSEnterpriseExtensionObserver() OVERRIDE;
virtual void InitChromeOSPreferences() OVERRIDE;
#endif // defined(OS_CHROMEOS)
-
- virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
@@ -137,11 +132,6 @@ class OffTheRecordProfileImpl : public Profile,
OffTheRecordProfileIOData::Handle io_data_;
- // Must be freed before |io_data_|. While |extension_process_manager_| still
- // lives, we handle incoming resource requests from extension processes and
- // those require access to the ResourceContext owned by |io_data_|.
- scoped_ptr<ExtensionProcessManager> extension_process_manager_;
-
// We use a non-persistent content settings map for OTR.
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
diff --git a/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc b/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc
index ebc63cb..4d0f2c0 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/net/ssl_config_service_manager.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -142,6 +143,9 @@ TEST_F(OffTheRecordProfileImplTest, GetHostZoomMap) {
new OffTheRecordProfileImpl(parent_profile.get()));
child_profile->InitHostZoomMap();
+ ProfileDependencyManager::GetInstance()->CreateProfileServices(
+ child_profile.get(), false);
+
// Prepare child host zoom map.
HostZoomMap* child_zoom_map =
HostZoomMap::GetForBrowserContext(child_profile.get());
@@ -159,12 +163,12 @@ TEST_F(OffTheRecordProfileImplTest, GetHostZoomMap) {
EXPECT_NE(parent_zoom_map->GetZoomLevel(host),
child_zoom_map->GetZoomLevel(host)) <<
- "Child change must not propaget to parent.";
+ "Child change must not propagate to parent.";
parent_zoom_map->SetZoomLevel(host, zoom_level_40);
ASSERT_EQ(parent_zoom_map->GetZoomLevel(host), zoom_level_40);
EXPECT_EQ(parent_zoom_map->GetZoomLevel(host),
child_zoom_map->GetZoomLevel(host)) <<
- "Parent change should propaget to child.";
+ "Parent change should propagate to child.";
}
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 49037f2..4003362 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -15,7 +15,6 @@
#include "base/logging.h"
#include "chrome/browser/net/preconnect.h" // TODO: remove this.
#include "chrome/browser/net/pref_proxy_config_tracker.h"
-#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/browser_context.h"
class AutocompleteClassifier;
@@ -23,10 +22,8 @@ class BookmarkModel;
class ChromeAppCacheService;
class ChromeURLDataManager;
class Extension;
-class ExtensionDevToolsManager;
class ExtensionEventRouter;
-class ExtensionInfoMap;
-class ExtensionMessageService;
+class ExtensionPrefValueMap;
class ExtensionProcessManager;
class ExtensionService;
class ExtensionSpecialStoragePolicy;
@@ -34,7 +31,6 @@ class FaviconService;
class GAIAInfoUpdateService;
class HistoryService;
class HostContentSettingsMap;
-class LazyBackgroundTaskQueue;
class PasswordStore;
class PrefService;
class PromoCounter;
@@ -212,38 +208,38 @@ class Profile : public content::BrowserContext {
// that this method is called.
virtual VisitedLinkMaster* GetVisitedLinkMaster() = 0;
+ // Accessor. The instance is created upon first access.
+ // TODO(yoz): make this a ProfileKeyedService.
+ virtual ExtensionPrefValueMap* GetExtensionPrefValueMap() = 0;
+
+ // DEPRECATED. Instead, use ExtensionSystemFactory::extension_service().
// Retrieves a pointer to the ExtensionService associated with this
// profile. The ExtensionService is created at startup.
+ // TODO(yoz): remove this accessor (bug 104095).
virtual ExtensionService* GetExtensionService() = 0;
+ // DEPRECATED. Instead, use ExtensionSystemFactory::user_script_master().
// Retrieves a pointer to the UserScriptMaster associated with this
// profile. The UserScriptMaster is lazily created the first time
// that this method is called.
+ // TODO(yoz): remove this accessor (bug 104095).
virtual UserScriptMaster* GetUserScriptMaster() = 0;
- // Retrieves a pointer to the ExtensionDevToolsManager associated with this
- // profile. The instance is created at startup.
- virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() = 0;
-
+ // DEPRECATED. Instead, use ExtensionSystemFactory::process_manager().
// Retrieves a pointer to the ExtensionProcessManager associated with this
// profile. The instance is created at startup.
+ // TODO(yoz): remove this accessor (bug 104095).
virtual ExtensionProcessManager* GetExtensionProcessManager() = 0;
- // Retrieves a pointer to the ExtensionMessageService associated with this
- // profile. The instance is created at startup.
- virtual ExtensionMessageService* GetExtensionMessageService() = 0;
-
+ // DEPRECATED. Instead, use ExtensionSystemFactory::event_router().
// Accessor. The instance is created at startup.
+ // TODO(yoz): remove this accessor (bug 104095).
virtual ExtensionEventRouter* GetExtensionEventRouter() = 0;
// Accessor. The instance is created upon first access.
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() = 0;
- // Accessor. The instance is created at startup.
- // TODO(yoz): this belongs with the ExtensionSystem.
- virtual LazyBackgroundTaskQueue* GetLazyBackgroundTaskQueue() = 0;
-
// Retrieves a pointer to the FaviconService associated with this
// profile. The FaviconService is lazily created the first time
// that this method is called.
@@ -322,21 +318,6 @@ class Profile : public content::BrowserContext {
virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp(
const std::string& app_id) = 0;
- // Called by the ExtensionService that lives in this profile. Gives the
- // profile a chance to react to the load event before the EXTENSION_LOADED
- // notification has fired. The purpose for handling this event first is to
- // avoid race conditions by making sure URLRequestContexts learn about new
- // extensions before anything else needs them to know.
- virtual void RegisterExtensionWithRequestContexts(
- const Extension* extension) {}
-
- // Called by the ExtensionService that lives in this profile. Lets the
- // profile clean up its RequestContexts once all the listeners to the
- // EXTENSION_UNLOADED notification have finished running.
- virtual void UnregisterExtensionWithRequestContexts(
- const std::string& extension_id,
- const extension_misc::UnloadedExtensionReason) {}
-
// Returns the SSLConfigService for this profile.
virtual net::SSLConfigService* GetSSLConfigService() = 0;
@@ -370,11 +351,6 @@ class Profile : public content::BrowserContext {
// that it can be invoked when the user logs out/powers down (WM_ENDSESSION).
virtual void MarkAsCleanShutdown() = 0;
- // Initializes extensions machinery.
- // Component extensions are always enabled, external and user extensions
- // are controlled by |extensions_enabled|.
- virtual void InitExtensions(bool extensions_enabled) = 0;
-
// Start up service that gathers data from a promo resource feed.
virtual void InitPromoResources() = 0;
@@ -386,9 +362,6 @@ class Profile : public content::BrowserContext {
virtual FilePath last_selected_directory() = 0;
virtual void set_last_selected_directory(const FilePath& path) = 0;
- // Returns the IO-thread-accessible profile data for this profile.
- virtual ExtensionInfoMap* GetExtensionInfoMap() = 0;
-
// Returns the PromoCounter for Instant, or NULL if not applicable.
virtual PromoCounter* GetInstantPromoCounter() = 0;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 772a068..aec59ba 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -28,19 +28,14 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
-#include "chrome/browser/extensions/component_loader.h"
-#include "chrome/browser/extensions/extension_devtools_manager.h"
-#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/extension_event_router.h"
-#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/extensions/extension_message_service.h"
-#include "chrome/browser/extensions/extension_navigation_observer.h"
#include "chrome/browser/extensions/extension_pref_store.h"
+#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
-#include "chrome/browser/extensions/lazy_background_task_queue.h"
-#include "chrome/browser/extensions/unpacked_installer.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
@@ -228,7 +223,6 @@ ProfileImpl::ProfileImpl(const FilePath& path,
ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_(
new VisitedLinkEventListener(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
- extension_devtools_manager_(NULL),
host_content_settings_map_(NULL),
history_service_created_(false),
favicon_service_created_(false),
@@ -432,105 +426,6 @@ void ProfileImpl::InitHostZoomMap() {
content::Source<HostZoomMap>(host_zoom_map));
}
-void ProfileImpl::InitExtensions(bool extensions_enabled) {
- if (user_script_master_ || extension_service_.get())
- return; // Already initialized.
-
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(
- switches::kEnableExtensionTimelineApi)) {
- extension_devtools_manager_ = new ExtensionDevToolsManager(this);
- }
-
- // The ExtensionInfoMap needs to be created before the
- // ExtensionProcessManager.
- extension_info_map_ = new ExtensionInfoMap();
- extension_process_manager_.reset(ExtensionProcessManager::Create(this));
- lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(this));
- extension_event_router_.reset(new ExtensionEventRouter(this));
- extension_message_service_.reset(new ExtensionMessageService(
- lazy_background_task_queue_.get()));
- extension_navigation_observer_.reset(new ExtensionNavigationObserver(this));
-
- ExtensionErrorReporter::Init(true); // allow noisy errors.
-
- user_script_master_ = new UserScriptMaster(this);
-
- bool autoupdate_enabled = true;
-#if defined(OS_CHROMEOS)
- if (!extensions_enabled)
- autoupdate_enabled = false;
- else
- autoupdate_enabled = !command_line->HasSwitch(switches::kGuestSession);
-#endif
- extension_service_.reset(new ExtensionService(
- this,
- CommandLine::ForCurrentProcess(),
- GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
- extension_prefs_.get(),
- autoupdate_enabled,
- extensions_enabled));
-
- extension_service_->component_loader()->AddDefaultComponentExtensions();
- if (command_line->HasSwitch(switches::kLoadComponentExtension)) {
- CommandLine::StringType path_list = command_line->GetSwitchValueNative(
- switches::kLoadComponentExtension);
- StringTokenizerT<CommandLine::StringType,
- CommandLine::StringType::const_iterator> t(path_list,
- FILE_PATH_LITERAL(","));
- while (t.GetNext()) {
- // Load the component extension manifest synchronously.
- // Blocking the UI thread is acceptable here since
- // this flag designated for developers.
- base::ThreadRestrictions::ScopedAllowIO allow_io;
- extension_service_->component_loader()->AddOrReplace(
- FilePath(t.token()));
- }
- }
- extension_service_->Init();
-
- if (extensions_enabled) {
- // Load any extensions specified with --load-extension.
- // TODO(yoz): Seems like this should move into ExtensionService::Init.
- if (command_line->HasSwitch(switches::kLoadExtension)) {
- CommandLine::StringType path_list = command_line->GetSwitchValueNative(
- switches::kLoadExtension);
- StringTokenizerT<CommandLine::StringType,
- CommandLine::StringType::const_iterator> t(path_list,
- FILE_PATH_LITERAL(","));
- scoped_refptr<extensions::UnpackedInstaller> installer =
- extensions::UnpackedInstaller::Create(extension_service_.get());
- while (t.GetNext()) {
- installer->LoadFromCommandLine(FilePath(t.token()));
- }
- }
- }
-
- // Make the chrome://extension-icon/ resource available.
- GetChromeURLDataManager()->AddDataSource(new ExtensionIconSource(this));
-
- // Initialize extension event routers. Note that on Chrome OS, this will
- // not succeed if the user has not logged in yet, in which case the
- // event routers are initialized in LoginUtilsImpl::CompleteLogin instead.
- // The InitEventRouters call used to be in BrowserMain, because when bookmark
- // import happened on first run, the bookmark bar was not being correctly
- // initialized (see issue 40144). Now that bookmarks aren't imported and
- // the event routers need to be initialized for every profile individually,
- // initialize them with the extension service.
- // If this profile is being created as part of the import process, never
- // initialize the event routers. If import is going to run in a separate
- // process (the profile itself is on the main process), wait for import to
- // finish before initializing the routers.
- if (!command_line->HasSwitch(switches::kImport) &&
- !command_line->HasSwitch(switches::kImportFromFile)) {
- if (g_browser_process->profile_manager()->will_import()) {
- extension_service_->InitEventRoutersAfterImport();
- } else {
- extension_service_->InitEventRouters();
- }
- }
-}
-
void ProfileImpl::InitPromoResources() {
if (promo_resource_service_)
return;
@@ -689,27 +584,19 @@ VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() {
}
ExtensionService* ProfileImpl::GetExtensionService() {
- return extension_service_.get();
+ return ExtensionSystemFactory::GetForProfile(this)->extension_service();
}
UserScriptMaster* ProfileImpl::GetUserScriptMaster() {
- return user_script_master_.get();
-}
-
-ExtensionDevToolsManager* ProfileImpl::GetExtensionDevToolsManager() {
- return extension_devtools_manager_.get();
+ return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
}
ExtensionProcessManager* ProfileImpl::GetExtensionProcessManager() {
- return extension_process_manager_.get();
-}
-
-ExtensionMessageService* ProfileImpl::GetExtensionMessageService() {
- return extension_message_service_.get();
+ return ExtensionSystemFactory::GetForProfile(this)->process_manager();
}
ExtensionEventRouter* ProfileImpl::GetExtensionEventRouter() {
- return extension_event_router_.get();
+ return ExtensionSystemFactory::GetForProfile(this)->event_router();
}
ExtensionSpecialStoragePolicy*
@@ -721,10 +608,6 @@ ExtensionSpecialStoragePolicy*
return extension_special_storage_policy_.get();
}
-LazyBackgroundTaskQueue* ProfileImpl::GetLazyBackgroundTaskQueue() {
- return lazy_background_task_queue_.get();
-}
-
void ProfileImpl::OnPrefsLoaded(bool success) {
if (!success) {
if (delegate_)
@@ -749,20 +632,8 @@ void ProfileImpl::OnPrefsLoaded(bool success) {
// Mark the session as open.
prefs_->SetBoolean(prefs::kSessionExitedCleanly, false);
- bool extensions_disabled =
- prefs_->GetBoolean(prefs::kDisableExtensions) ||
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions);
-
ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false);
- // Ensure that preferences set by extensions are restored in the profile
- // as early as possible. The constructor takes care of that.
- extension_prefs_.reset(new ExtensionPrefs(
- prefs_.get(),
- GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
- GetExtensionPrefValueMap()));
- extension_prefs_->Init(extensions_disabled);
-
DCHECK(!net_pref_observer_.get());
net_pref_observer_.reset(new NetPrefObserver(
prefs_.get(),
@@ -816,8 +687,10 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContext() {
net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess(
int renderer_child_id) {
- if (extension_service_.get()) {
- const Extension* installed_app = extension_service_->
+ ExtensionService* extension_service =
+ ExtensionSystemFactory::GetForProfile(this)->extension_service();
+ if (extension_service) {
+ const Extension* installed_app = extension_service->
GetInstalledAppForRenderer(renderer_child_id);
if (installed_app != NULL && installed_app->is_storage_isolated() &&
installed_app->HasAPIPermission(
@@ -853,31 +726,6 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp(
return io_data_.GetIsolatedAppRequestContextGetter(app_id);
}
-void ProfileImpl::RegisterExtensionWithRequestContexts(
- const Extension* extension) {
- base::Time install_time;
- if (extension->location() != Extension::COMPONENT) {
- install_time = GetExtensionService()->extension_prefs()->
- GetInstallTime(extension->id());
- }
- bool incognito_enabled =
- GetExtensionService()->IsIncognitoEnabled(extension->id());
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&ExtensionInfoMap::AddExtension, extension_info_map_.get(),
- make_scoped_refptr(extension), install_time,
- incognito_enabled));
-}
-
-void ProfileImpl::UnregisterExtensionWithRequestContexts(
- const std::string& extension_id,
- const extension_misc::UnloadedExtensionReason reason) {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&ExtensionInfoMap::RemoveExtension, extension_info_map_.get(),
- extension_id, reason));
-}
-
net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
return ssl_config_service_manager_->Get();
}
@@ -1132,10 +980,6 @@ void ProfileImpl::EnsureSessionServiceCreated() {
SessionServiceFactory::GetForProfile(this);
}
-ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() {
- return extension_info_map_.get();
-}
-
ChromeURLDataManager* ProfileImpl::GetChromeURLDataManager() {
if (!chrome_url_data_manager_.get())
chrome_url_data_manager_.reset(new ChromeURLDataManager(
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 83f498b..0c12998 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -22,8 +22,7 @@
#include "content/public/browser/notification_registrar.h"
class ExtensionNavigationObserver;
-class ExtensionPrefs;
-class ExtensionPrefValueMap;
+class ExtensionSystem;
class NetPrefObserver;
class PrefService;
class PromoResourceService;
@@ -75,15 +74,13 @@ class ProfileImpl : public Profile,
virtual history::TopSites* GetTopSites() OVERRIDE;
virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE;
virtual VisitedLinkMaster* GetVisitedLinkMaster() OVERRIDE;
- virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE;
+ virtual ExtensionPrefValueMap* GetExtensionPrefValueMap() OVERRIDE;
virtual ExtensionService* GetExtensionService() OVERRIDE;
- virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() OVERRIDE;
+ virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE;
virtual ExtensionProcessManager* GetExtensionProcessManager() OVERRIDE;
- virtual ExtensionMessageService* GetExtensionMessageService() OVERRIDE;
virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE;
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() OVERRIDE;
- virtual LazyBackgroundTaskQueue* GetLazyBackgroundTaskQueue() OVERRIDE;
virtual FaviconService* GetFaviconService(ServiceAccessType sat) OVERRIDE;
virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() OVERRIDE;
virtual HistoryService* GetHistoryService(ServiceAccessType sat) OVERRIDE;
@@ -99,11 +96,6 @@ class ProfileImpl : public Profile,
GetRequestContextForExtensions() OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp(
const std::string& app_id) OVERRIDE;
- virtual void RegisterExtensionWithRequestContexts(
- const Extension* extension) OVERRIDE;
- virtual void UnregisterExtensionWithRequestContexts(
- const std::string& extension_id,
- const extension_misc::UnloadedExtensionReason reason) OVERRIDE;
virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE;
virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE;
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() OVERRIDE;
@@ -112,12 +104,10 @@ class ProfileImpl : public Profile,
virtual bool IsSameProfile(Profile* profile) OVERRIDE;
virtual base::Time GetStartTime() const OVERRIDE;
virtual void MarkAsCleanShutdown() OVERRIDE;
- virtual void InitExtensions(bool extensions_enabled) OVERRIDE;
virtual void InitPromoResources() OVERRIDE;
virtual void InitRegisteredProtocolHandlers() OVERRIDE;
virtual FilePath last_selected_directory() OVERRIDE;
virtual void set_last_selected_directory(const FilePath& path) OVERRIDE;
- virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE;
@@ -174,8 +164,6 @@ class ProfileImpl : public Profile,
void EnsureSessionServiceCreated();
- ExtensionPrefValueMap* GetExtensionPrefValueMap();
-
void UpdateProfileUserNameCache();
@@ -208,24 +196,6 @@ class ProfileImpl : public Profile,
scoped_ptr<VisitedLinkEventListener> visited_link_event_listener_;
scoped_ptr<VisitedLinkMaster> visited_link_master_;
ProfileImplIOData::Handle io_data_;
- // Keep extension_prefs_ on top of extension_service_ because the latter
- // maintains a pointer to the first and shall be destructed first.
- scoped_ptr<ExtensionPrefs> extension_prefs_;
- scoped_ptr<ExtensionService> extension_service_;
- scoped_refptr<UserScriptMaster> user_script_master_;
- scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
- // extension_info_map_ needs to outlive extension_process_manager_.
- scoped_refptr<ExtensionInfoMap> extension_info_map_;
- // |extension_process_manager_| must be destroyed before |io_data_|.
- // While |extension_process_manager_| still lives, we handle incoming
- // resource requests from extension processes and those require access
- // to the ResourceContext owned by |io_data_|.
- scoped_ptr<ExtensionProcessManager> extension_process_manager_;
- // This is a dependency of ExtensionMessageService and ExtensionEventRouter.
- scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_;
- scoped_ptr<ExtensionMessageService> extension_message_service_;
- scoped_ptr<ExtensionEventRouter> extension_event_router_;
- scoped_ptr<ExtensionNavigationObserver> extension_navigation_observer_;
scoped_refptr<ExtensionSpecialStoragePolicy>
extension_special_storage_policy_;
scoped_ptr<NetPrefObserver> net_pref_observer_;
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 1e33668..1a4c1a7 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -24,6 +24,8 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/extension_protocols.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_cookie_notification_details.h"
#include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
@@ -195,7 +197,8 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
profile);
params->cookie_monster_delegate =
new ChromeCookieMonsterDelegate(profile_getter);
- params->extension_info_map = profile->GetExtensionInfoMap();
+ params->extension_info_map =
+ ExtensionSystemFactory::GetForProfile(profile)->info_map();
#if defined(ENABLE_NOTIFICATIONS)
params->notification_service =
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 1f4f2eb2..84ecbd8 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -18,6 +18,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/default_apps_trial.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/managed_mode.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
@@ -637,9 +639,9 @@ void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
}
void ProfileManager::DoFinalInitForServices(Profile* profile,
- bool go_off_the_record) {
+ bool go_off_the_record) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- profile->InitExtensions(!go_off_the_record);
+ ExtensionSystemFactory::GetForProfile(profile)->Init(!go_off_the_record);
if (!command_line.HasSwitch(switches::kDisableWebResources))
profile->InitPromoResources();
}
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 75d290d..57050b9 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -17,6 +17,8 @@
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_process_manager.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/metrics/histogram_synchronizer.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
#include "chrome/browser/net/chrome_url_request_context.h"
@@ -53,7 +55,8 @@ ChromeRenderMessageFilter::ChromeRenderMessageFilter(
: render_process_id_(render_process_id),
profile_(profile),
request_context_(request_context),
- extension_info_map_(profile->GetExtensionInfoMap()),
+ extension_info_map_(
+ ExtensionSystemFactory::GetForProfile(profile)->info_map()),
cookie_settings_(CookieSettings::Factory::GetForProfile(profile)),
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
@@ -263,9 +266,10 @@ void ChromeRenderMessageFilter::OpenChannelToExtensionOnUIThread(
const std::string& target_extension_id,
const std::string& channel_name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- profile_->GetExtensionMessageService()->OpenChannelToExtension(
- source_process_id, source_routing_id, receiver_port_id,
- source_extension_id, target_extension_id, channel_name);
+ ExtensionSystemFactory::GetForProfile(profile_)->message_service()->
+ OpenChannelToExtension(
+ source_process_id, source_routing_id, receiver_port_id,
+ source_extension_id, target_extension_id, channel_name);
}
void ChromeRenderMessageFilter::OnOpenChannelToTab(
@@ -288,9 +292,10 @@ void ChromeRenderMessageFilter::OpenChannelToTabOnUIThread(
const std::string& extension_id,
const std::string& channel_name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- profile_->GetExtensionMessageService()->OpenChannelToTab(
- source_process_id, source_routing_id, receiver_port_id,
- tab_id, extension_id, channel_name);
+ ExtensionSystemFactory::GetForProfile(profile_)->message_service()->
+ OpenChannelToTab(
+ source_process_id, source_routing_id, receiver_port_id,
+ tab_id, extension_id, channel_name);
}
void ChromeRenderMessageFilter::OnGetExtensionMessageBundle(
@@ -378,8 +383,10 @@ void ChromeRenderMessageFilter::OnExtensionCloseChannel(int port_id) {
if (!content::RenderProcessHost::FromID(render_process_id_))
return; // To guard against crash in browser_tests shutdown.
- if (profile_->GetExtensionMessageService())
- profile_->GetExtensionMessageService()->CloseChannel(port_id);
+ ExtensionMessageService* message_service =
+ ExtensionSystemFactory::GetForProfile(profile_)->message_service();
+ if (message_service)
+ message_service->CloseChannel(port_id);
}
void ChromeRenderMessageFilter::OnExtensionRequestForIOThread(
diff --git a/chrome/browser/sync/glue/extension_data_type_controller.cc b/chrome/browser/sync/glue/extension_data_type_controller.cc
index 6566da3..303546b 100644
--- a/chrome/browser/sync/glue/extension_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_data_type_controller.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/sync/glue/extension_data_type_controller.h"
#include "base/metrics/histogram.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
@@ -27,7 +29,7 @@ ExtensionDataTypeController::~ExtensionDataTypeController() {
}
bool ExtensionDataTypeController::StartModels() {
- profile_->InitExtensions(true);
+ ExtensionSystemFactory::GetForProfile(profile_)->Init(true);
return true;
}
diff --git a/chrome/browser/sync/glue/extension_setting_data_type_controller.cc b/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
index a07aba9..9f60544 100644
--- a/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
@@ -6,6 +6,9 @@
#include "base/bind.h"
#include "base/metrics/histogram.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/api/syncable_service.h"
#include "chrome/browser/sync/glue/generic_change_processor.h"
@@ -52,7 +55,7 @@ bool ExtensionSettingDataTypeController::PostTaskOnBackendThread(
bool ExtensionSettingDataTypeController::StartModels() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- profile_->InitExtensions(true);
+ ExtensionSystemFactory::GetForProfile(profile_)->Init(true);
return true;
}
diff --git a/chrome/browser/sync/glue/theme_data_type_controller.cc b/chrome/browser/sync/glue/theme_data_type_controller.cc
index ead0275..20047ea 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/sync/glue/theme_data_type_controller.h"
#include "base/metrics/histogram.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
@@ -27,7 +29,7 @@ syncable::ModelType ThemeDataTypeController::type() const {
}
bool ThemeDataTypeController::StartModels() {
- profile_->InitExtensions(true);
+ ExtensionSystemFactory::GetForProfile(profile_)->Init(true);
return true;
}
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc
index cbc4e27..ddca10e 100644
--- a/chrome/browser/sync/profile_sync_service_factory.cc
+++ b/chrome/browser/sync/profile_sync_service_factory.cc
@@ -8,6 +8,7 @@
#include "base/memory/singleton.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
@@ -52,6 +53,7 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory()
DependsOn(GlobalErrorServiceFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance());
DependsOn(PasswordStoreFactory::GetInstance());
+ DependsOn(ExtensionSystemFactory::GetInstance());
// The following have not been converted to ProfileKeyedServices yet, and for
// now they are explicitly destroyed after the ProfileDependencyManager is
@@ -62,7 +64,6 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory()
// DependsOn(HistoryServiceFactory::GetInstance());
// DependsOn(BookmarkBarModelFactory::GetInstance());
// DependsOn(FaviconServiceFactory::GetInstance());
- // DependsOn(ExtensionServiceFactory::GetInstance());
}
ProfileSyncServiceFactory::~ProfileSyncServiceFactory() {
diff --git a/chrome/browser/sync/test/integration/sync_app_helper.cc b/chrome/browser/sync/test/integration/sync_app_helper.cc
index bbe2f50..aa63718 100644
--- a/chrome/browser/sync/test/integration/sync_app_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_app_helper.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/sync/test/integration/sync_app_helper.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_sorting.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/extensions_helper.h"
@@ -92,9 +94,9 @@ void SyncAppHelper::SetupIfNecessary(SyncTest* test) {
return;
for (int i = 0; i < test->num_clients(); ++i) {
- test->GetProfile(i)->InitExtensions(true);
+ ExtensionSystemFactory::GetForProfile(test->GetProfile(i))->Init(true);
}
- test->verifier()->InitExtensions(true);
+ ExtensionSystemFactory::GetForProfile(test->verifier())->Init(true);
setup_completed_ = true;
}
diff --git a/chrome/browser/sync/test/integration/sync_extension_helper.cc b/chrome/browser/sync/test/integration/sync_extension_helper.cc
index 95dbe5c..d3e3a3e 100644
--- a/chrome/browser/sync/test/integration/sync_extension_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_extension_helper.cc
@@ -9,6 +9,8 @@
#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/pending_extension_info.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
#include "chrome/browser/profiles/profile.h"
@@ -239,7 +241,7 @@ bool SyncExtensionHelper::ExtensionStatesMatch(
}
void SyncExtensionHelper::SetupProfile(Profile* profile) {
- profile->InitExtensions(true);
+ ExtensionSystemFactory::GetForProfile(profile)->Init(true);
profile_extensions_.insert(make_pair(profile, ExtensionNameMap()));
}
diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc
index 7e78056..7e11c9e 100644
--- a/chrome/browser/translate/translate_manager_browsertest.cc
+++ b/chrome/browser/translate/translate_manager_browsertest.cc
@@ -13,6 +13,8 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
+#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/infobars/infobar.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
@@ -1347,7 +1349,9 @@ TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) {
TranslateInfoBarDelegate* infobar;
TestingProfile* test_profile =
static_cast<TestingProfile*>(contents()->GetBrowserContext());
- test_profile->CreateExtensionProcessManager();
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(test_profile))->
+ CreateExtensionProcessManager();
test_profile->set_incognito(true);
for (int i = 0; i < 8; ++i) {
SCOPED_TRACE(::testing::Message() << "Iteration " << i <<
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
index c794696..23e6ac0f 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
@@ -13,6 +13,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
+#include "chrome/browser/extensions/test_extension_system.h"
#import "chrome/browser/ui/cocoa/animation_utils.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
@@ -272,8 +274,11 @@ class BookmarkBarControllerTestBase : public CocoaProfileTest {
ASSERT_TRUE(profile());
FilePath extension_dir;
- profile()->CreateExtensionService(CommandLine::ForCurrentProcess(),
- extension_dir, false);
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile()))->
+ CreateExtensionService(
+ CommandLine::ForCurrentProcess(),
+ extension_dir, false);
resizeDelegate_.reset([[ViewResizerPong alloc] init]);
NSRect parent_frame = NSMakeRect(0, 0, 800, 50);
parent_view_.reset([[NSView alloc] initWithFrame:parent_frame]);
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 13488d0..e87d6b1 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -328,6 +328,10 @@
'browser/extensions/extension_sorting.h',
'browser/extensions/extension_special_storage_policy.cc',
'browser/extensions/extension_special_storage_policy.h',
+ 'browser/extensions/extension_system.cc',
+ 'browser/extensions/extension_system.h',
+ 'browser/extensions/extension_system_factory.cc',
+ 'browser/extensions/extension_system_factory.h',
'browser/extensions/extension_sync_data.cc',
'browser/extensions/extension_sync_data.h',
'browser/extensions/extension_tab_helper.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d418fb0..f68157d 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -147,6 +147,8 @@
'browser/extensions/test_extension_prefs.h',
'browser/extensions/test_extension_service.cc',
'browser/extensions/test_extension_service.h',
+ 'browser/extensions/test_extension_system.cc',
+ 'browser/extensions/test_extension_system.h',
'browser/mock_browsing_data_appcache_helper.cc',
'browser/mock_browsing_data_appcache_helper.h',
'browser/mock_browsing_data_cookie_helper.cc',
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 962e3ab..67f4a9e 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -20,6 +20,9 @@
#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
+#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
#include "chrome/browser/history/history.h"
@@ -195,6 +198,9 @@ TestingProfile::TestingProfile(const FilePath& path,
}
void TestingProfile::Init() {
+ ExtensionSystemFactory::GetInstance()->SetTestingFactory(
+ this, TestExtensionSystem::Build);
+
profile_dependency_manager_->CreateProfileServices(this, true);
#if defined(ENABLE_NOTIFICATIONS)
@@ -386,39 +392,6 @@ void TestingProfile::BlockUntilTemplateURLServiceLoaded() {
turl_service_load_observer.Wait();
}
-void TestingProfile::CreateExtensionProcessManager() {
- extension_process_manager_.reset(ExtensionProcessManager::Create(this));
-}
-
-ExtensionService* TestingProfile::CreateExtensionService(
- const CommandLine* command_line,
- const FilePath& install_directory,
- bool autoupdate_enabled) {
- // Extension pref store, created for use by |extension_prefs_|.
-
- extension_pref_value_map_.reset(new ExtensionPrefValueMap);
-
- bool extensions_disabled =
- command_line && command_line->HasSwitch(switches::kDisableExtensions);
-
- // Note that the GetPrefs() creates a TestingPrefService, therefore
- // the extension controlled pref values set in extension_prefs_
- // are not reflected in the pref service. One would need to
- // inject a new ExtensionPrefStore(extension_pref_value_map_.get(), false).
- extension_prefs_.reset(
- new ExtensionPrefs(GetPrefs(),
- install_directory,
- extension_pref_value_map_.get()));
- extension_prefs_->Init(extensions_disabled);
- extension_service_.reset(new ExtensionService(this,
- command_line,
- install_directory,
- extension_prefs_.get(),
- autoupdate_enabled,
- true));
- return extension_service_.get();
-}
-
FilePath TestingProfile::GetPath() {
return profile_path_;
}
@@ -466,28 +439,24 @@ VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() {
return NULL;
}
-ExtensionService* TestingProfile::GetExtensionService() {
- return extension_service_.get();
-}
-
-UserScriptMaster* TestingProfile::GetUserScriptMaster() {
+ExtensionPrefValueMap* TestingProfile::GetExtensionPrefValueMap() {
return NULL;
}
-ExtensionDevToolsManager* TestingProfile::GetExtensionDevToolsManager() {
- return NULL;
+ExtensionService* TestingProfile::GetExtensionService() {
+ return ExtensionSystemFactory::GetForProfile(this)->extension_service();
}
-ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() {
- return extension_process_manager_.get();
+UserScriptMaster* TestingProfile::GetUserScriptMaster() {
+ return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
}
-ExtensionMessageService* TestingProfile::GetExtensionMessageService() {
- return NULL;
+ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() {
+ return ExtensionSystemFactory::GetForProfile(this)->process_manager();
}
ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() {
- return NULL;
+ return ExtensionSystemFactory::GetForProfile(this)->event_router();
}
void TestingProfile::SetExtensionSpecialStoragePolicy(
@@ -502,10 +471,6 @@ TestingProfile::GetExtensionSpecialStoragePolicy() {
return extension_special_storage_policy_.get();
}
-LazyBackgroundTaskQueue* TestingProfile::GetLazyBackgroundTaskQueue() {
- return NULL;
-}
-
FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) {
return favicon_service_.get();
}
@@ -590,8 +555,10 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
int renderer_child_id) {
- if (extension_service_.get()) {
- const Extension* installed_app = extension_service_->
+ ExtensionService* extension_service =
+ ExtensionSystemFactory::GetForProfile(this)->extension_service();
+ if (extension_service) {
+ const Extension* installed_app = extension_service->
GetInstalledAppForRenderer(renderer_child_id);
if (installed_app != NULL && installed_app->is_storage_isolated())
return GetRequestContextForIsolatedApp(installed_app->id());
@@ -732,10 +699,6 @@ void TestingProfile::BlockUntilHistoryProcessesPendingRequests() {
MessageLoop::current()->Run();
}
-ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() {
- return NULL;
-}
-
PromoCounter* TestingProfile::GetInstantPromoCounter() {
return NULL;
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index cc31f9c..9d4d875 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -132,18 +132,6 @@ class TestingProfile : public Profile {
// Blocks until TempalteURLService finishes loading.
void BlockUntilTemplateURLServiceLoaded();
- // Creates an ExtensionProcessManager. If not invoked, the
- // ExtensionProcessManager is NULL.
- void CreateExtensionProcessManager();
-
- // Creates an ExtensionService initialized with the testing profile and
- // returns it. The profile keeps its own copy of a scoped_refptr to the
- // ExtensionService to make sure that is still alive to be notified when the
- // profile is destroyed.
- ExtensionService* CreateExtensionService(const CommandLine* command_line,
- const FilePath& install_directory,
- bool autoupdate_enabled);
-
TestingPrefService* GetTestingPrefService();
// content::BrowserContext
@@ -180,17 +168,15 @@ class TestingProfile : public Profile {
virtual bool HasOffTheRecordProfile() OVERRIDE;
virtual Profile* GetOriginalProfile() OVERRIDE;
virtual VisitedLinkMaster* GetVisitedLinkMaster() OVERRIDE;
+ virtual ExtensionPrefValueMap* GetExtensionPrefValueMap() OVERRIDE;
virtual ExtensionService* GetExtensionService() OVERRIDE;
virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE;
- virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() OVERRIDE;
virtual ExtensionProcessManager* GetExtensionProcessManager() OVERRIDE;
- virtual ExtensionMessageService* GetExtensionMessageService() OVERRIDE;
virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE;
void SetExtensionSpecialStoragePolicy(
ExtensionSpecialStoragePolicy* extension_special_storage_policy);
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() OVERRIDE;
- virtual LazyBackgroundTaskQueue* GetLazyBackgroundTaskQueue() OVERRIDE;
virtual FaviconService* GetFaviconService(ServiceAccessType access) OVERRIDE;
virtual HistoryService* GetHistoryService(ServiceAccessType access) OVERRIDE;
virtual HistoryService* GetHistoryServiceWithoutCreating() OVERRIDE;
@@ -241,7 +227,6 @@ class TestingProfile : public Profile {
virtual base::Time GetStartTime() const OVERRIDE;
virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE;
virtual void MarkAsCleanShutdown() OVERRIDE {}
- virtual void InitExtensions(bool extensions_enabled) OVERRIDE {}
virtual void InitPromoResources() OVERRIDE {}
virtual void InitRegisteredProtocolHandlers() OVERRIDE {}
@@ -267,7 +252,6 @@ class TestingProfile : public Profile {
// history service processes all pending requests.
void BlockUntilHistoryProcessesPendingRequests();
- virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE;
@@ -349,16 +333,6 @@ class TestingProfile : public Profile {
FilePath last_selected_directory_;
scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails.
- // The Extension Preferences. Only created if CreateExtensionService is
- // invoked.
- scoped_ptr<ExtensionPrefs> extension_prefs_;
-
- scoped_ptr<ExtensionService> extension_service_;
-
- scoped_ptr<ExtensionProcessManager> extension_process_manager_;
-
- scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
-
scoped_refptr<ExtensionSpecialStoragePolicy>
extension_special_storage_policy_;