summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.cc7
-rw-r--r--chrome/browser/extensions/extension_event_router.cc5
-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.h4
-rw-r--r--chrome/browser/extensions/extension_system.cc284
-rw-r--r--chrome/browser/extensions/extension_system.h168
-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/extension_updater_unittest.cc23
-rw-r--r--chrome/browser/extensions/test_extension_system.cc99
-rw-r--r--chrome/browser/extensions/test_extension_system.h57
-rw-r--r--chrome/browser/intents/web_intents_registry_factory.cc3
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc51
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h10
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl_unittest.cc10
-rw-r--r--chrome/browser/profiles/profile.h48
-rw-r--r--chrome/browser/profiles/profile_impl.cc174
-rw-r--r--chrome/browser/profiles/profile_impl.h33
-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.cc21
-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.cc8
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm9
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/test/base/testing_profile.cc69
-rw-r--r--chrome/test/base/testing_profile.h27
39 files changed, 436 insertions, 980 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 2ff12e3..9f7256a 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -47,8 +47,6 @@
#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 +925,7 @@ void AutomationProvider::ExecuteExtensionActionInActiveTabAsync(
const Extension* extension = GetEnabledExtension(extension_handle);
ExtensionService* service = profile_->GetExtensionService();
ExtensionMessageService* message_service =
- ExtensionSystemFactory::GetForProfile(profile_)->message_service();
+ profile_->GetExtensionMessageService();
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 a30e603..ed827c5 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -31,8 +31,6 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_message_handler.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"
@@ -597,7 +595,7 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
- ExtensionSystemFactory::GetForProfile(profile)->info_map(),
+ profile->GetExtensionInfoMap(),
extension->id(),
site_instance->GetProcess()->GetID(),
site_instance->GetId()));
@@ -626,7 +624,7 @@ void ChromeContentBrowserClient::SiteInstanceDeleting(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
- ExtensionSystemFactory::GetForProfile(profile)->info_map(),
+ profile->GetExtensionInfoMap(),
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 d272389..e31767f 100644
--- a/chrome/browser/extensions/extension_devtools_bridge.cc
+++ b/chrome/browser/extensions/extension_devtools_bridge.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -12,8 +12,6 @@
#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"
@@ -34,8 +32,7 @@ ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id,
ExtensionDevToolsEvents::OnPageEventNameForTab(tab_id)),
on_tab_close_event_name_(
ExtensionDevToolsEvents::OnTabCloseEventNameForTab(tab_id)) {
- extension_devtools_manager_ =
- ExtensionSystemFactory::GetForProfile(profile)->devtools_manager();
+ extension_devtools_manager_ = profile_->GetExtensionDevToolsManager();
DCHECK(extension_devtools_manager_.get());
}
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc
index 201e1db..29d94af 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -13,8 +13,6 @@
#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/api/webrequest/webrequest_api.h"
#include "chrome/browser/extensions/process_map.h"
@@ -102,8 +100,7 @@ void ExtensionEventRouter::DispatchEvent(IPC::Message::Sender* ipc_sender,
ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
: profile_(profile),
- extension_devtools_manager_(
- ExtensionSystemFactory::GetForProfile(profile)->devtools_manager()) {
+ extension_devtools_manager_(profile->GetExtensionDevToolsManager()) {
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index 151787f..cb429e0 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -18,7 +18,6 @@ class Browser;
class ChromeRenderMessageFilter;
class Extension;
class ExtensionFunction;
-class ExtensionInfoMap;
class Profile;
class RenderViewHost;
struct ExtensionHostMsg_Request_Params;
diff --git a/chrome/browser/extensions/extension_message_handler.cc b/chrome/browser/extensions/extension_message_handler.cc
index 9e2e838..0ad4005 100644
--- a/chrome/browser/extensions/extension_message_handler.cc
+++ b/chrome/browser/extensions/extension_message_handler.cc
@@ -5,8 +5,6 @@
#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/browser/renderer_host/render_view_host.h"
@@ -40,9 +38,8 @@ void ExtensionMessageHandler::OnPostMessage(int port_id,
const std::string& message) {
Profile* profile = Profile::FromBrowserContext(
render_view_host()->process()->GetBrowserContext());
- ExtensionMessageService* message_service =
- ExtensionSystemFactory::GetForProfile(profile)->message_service();
- if (message_service) {
- message_service->PostMessageFromRenderer(port_id, message);
+ if (profile->GetExtensionMessageService()) {
+ profile->GetExtensionMessageService()->PostMessageFromRenderer(
+ port_id, message);
}
}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index b2d7eec..3c0eb11 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -52,8 +52,6 @@
#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_updater.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/extensions/extension_webnavigation_api.h"
@@ -377,7 +375,6 @@ 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)),
@@ -695,8 +692,7 @@ 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.
- // TODO(yoz): this is not incognito-safe!
- ExtensionProcessManager* manager = system_->process_manager();
+ ExtensionProcessManager* manager = profile_->GetExtensionProcessManager();
ExtensionHost* host = manager->GetBackgroundHostForExtension(extension_id);
if (host && DevToolsAgentHostRegistry::HasDevToolsAgentHost(
host->render_view_host())) {
@@ -985,7 +981,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.
- system_->RegisterExtensionWithRequestContexts(extension);
+ profile_->RegisterExtensionWithRequestContexts(extension);
// Tell renderers about the new extension, unless it's a theme (renderers
// don't need to know about themes).
@@ -1132,7 +1128,7 @@ void ExtensionService::NotifyExtensionUnloaded(
host->Send(new ExtensionMsg_Unloaded(extension->id()));
}
- system_->UnregisterExtensionWithRequestContexts(extension->id(), reason);
+ profile_->UnregisterExtensionWithRequestContexts(extension->id(), reason);
profile_->GetExtensionSpecialStoragePolicy()->
RevokeRightsForExtension(extension);
@@ -1933,7 +1929,7 @@ void ExtensionService::UnloadExtension(
if (!extension) {
// In case the extension may have crashed/uninstalled. Allow the profile to
// clean up its RequestContexts.
- system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
+ profile_->UnregisterExtensionWithRequestContexts(extension_id, reason);
return;
}
@@ -1958,7 +1954,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).
- system_->UnregisterExtensionWithRequestContexts(extension_id, reason);
+ profile_->UnregisterExtensionWithRequestContexts(extension_id, reason);
return;
}
@@ -2505,7 +2501,7 @@ void ExtensionService::Observe(int type,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess,
- system_->info_map(),
+ profile_->GetExtensionInfoMap(),
process->GetID()));
break;
}
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index f7e02be..c090504 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -58,7 +58,6 @@ class ExtensionGlobalError;
class ExtensionManagementEventRouter;
class ExtensionPreferenceEventRouter;
class ExtensionSyncData;
-class ExtensionSystem;
class ExtensionToolbarModel;
class ExtensionUpdater;
class ExtensionWebNavigationEventRouter;
@@ -707,12 +706,9 @@ class ExtensionService
NaClModuleInfoList::iterator FindNaClModule(const GURL& url);
- // The normal profile associated with this ExtensionService.
+ // The profile this ExtensionService is part of.
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 e10c89c..0880121 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -35,8 +35,6 @@
#include "chrome/browser/extensions/extension_service.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_updater.h"
#include "chrome/browser/extensions/external_extension_provider_impl.h"
#include "chrome/browser/extensions/external_extension_provider_interface.h"
@@ -46,7 +44,6 @@
#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/plugin_prefs_factory.h"
#include "chrome/browser/prefs/browser_prefs.h"
@@ -54,7 +51,6 @@
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.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"
@@ -374,6 +370,20 @@ 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),
@@ -406,7 +416,7 @@ ExtensionServiceTestBase::~ExtensionServiceTestBase() {
void ExtensionServiceTestBase::InitializeExtensionService(
const FilePath& pref_file, const FilePath& extensions_install_dir,
bool autoupdate_enabled) {
- TestingProfile* profile = new TestingProfile();
+ ExtensionTestingProfile* profile = new ExtensionTestingProfile();
// Create a PrefService that only contains user defined preference values.
PrefService* prefs =
PrefServiceMockBuilder().WithUserFilePrefs(pref_file).Create();
@@ -418,13 +428,13 @@ void ExtensionServiceTestBase::InitializeExtensionService(
profile_.reset(profile);
- service_ = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile))->CreateExtensionService(
- CommandLine::ForCurrentProcess(),
- extensions_install_dir,
- autoupdate_enabled);
+ service_ = 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
@@ -458,9 +468,7 @@ void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
}
void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
- static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile_.get()))->
- CreateExtensionProcessManager();
+ profile_->CreateExtensionProcessManager();
}
void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
@@ -487,8 +495,8 @@ void ExtensionServiceTestBase::InitializeExtensionServiceHelper(
void ExtensionServiceTestBase::InitializeRequestContext() {
ASSERT_TRUE(profile_.get());
- TestingProfile* profile =
- static_cast<TestingProfile*>(profile_.get());
+ ExtensionTestingProfile* profile =
+ static_cast<ExtensionTestingProfile*>(profile_.get());
profile->CreateRequestContext();
}
@@ -735,7 +743,7 @@ class ExtensionServiceTest
enabled_extension_count);
}
- // Update() should the temporary input file.
+ // Update() should delete the temporary input file.
EXPECT_FALSE(file_util::PathExists(path));
}
@@ -3849,12 +3857,11 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
// By default, we are enabled.
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- ExtensionService* service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ // Owned by |profile|.
+ ExtensionService* service =
+ profile->CreateExtensionService(command_line.get(),
+ install_dir,
+ false);
EXPECT_TRUE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3864,12 +3871,9 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
recorder.set_ready(false);
profile.reset(new TestingProfile());
command_line->AppendSwitch(switches::kDisableExtensions);
- service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ service = profile->CreateExtensionService(command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3878,12 +3882,9 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
recorder.set_ready(false);
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
- service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ service = profile->CreateExtensionService(command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3893,12 +3894,9 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ service = profile->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 4f45c67..613761b 100644
--- a/chrome/browser/extensions/extension_service_unittest.h
+++ b/chrome/browser/extensions/extension_service_unittest.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -55,7 +55,7 @@ class ExtensionServiceTestBase : public testing::Test {
scoped_ptr<TestingProfile> profile_;
FilePath extensions_install_dir_;
FilePath data_dir_;
- // Managed by ExtensionSystemFactory.
+ // Owned by |profile_|.
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
deleted file mode 100644
index 982c441..0000000
--- a/chrome/browser/extensions/extension_system.cc
+++ /dev/null
@@ -1,284 +0,0 @@
-// 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/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::Shutdown() {
- if (message_service())
- message_service()->DestroyingProfile();
-}
-
-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();
-
- extension_event_router_.reset(new ExtensionEventRouter(profile_));
- extension_message_service_ = new ExtensionMessageService(profile_);
- 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();
-}
-
-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();
-}
-
-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
deleted file mode 100644
index ce3c62a..0000000
--- a/chrome/browser/extensions/extension_system.h
+++ /dev/null
@@ -1,168 +0,0 @@
-// 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 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 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; // delegated
- virtual UserScriptMaster* user_script_master() OVERRIDE; // delegated
- virtual ExtensionDevToolsManager* devtools_manager() OVERRIDE;
- virtual ExtensionProcessManager* process_manager() OVERRIDE;
- virtual ExtensionInfoMap* info_map() OVERRIDE; // delegated
- virtual ExtensionMessageService* message_service() OVERRIDE; // delegated
- virtual ExtensionEventRouter* event_router() OVERRIDE; // delegated
-
- 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();
-
- // ProfileKeyedService implementation.
- virtual void Shutdown() OVERRIDE;
-
- // 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();
- 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_;
- scoped_refptr<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
deleted file mode 100644
index 956e735..0000000
--- a/chrome/browser/extensions/extension_system_factory.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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
deleted file mode 100644
index a6c0c9e..0000000
--- a/chrome/browser/extensions/extension_system_factory.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// 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/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc
index d94e409..72eabc4 100644
--- a/chrome/browser/extensions/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/extension_updater_unittest.cc
@@ -18,12 +18,9 @@
#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/extension_updater.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/google/google_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/extensions/extension.h"
@@ -815,21 +812,17 @@ class ExtensionUpdaterTest : public testing::Test {
// service, not on our mock |service|. This allows us to fake
// the CrxInstaller actions we want.
TestingProfile profile;
- 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);
+ profile.CreateExtensionService(
+ CommandLine::ForCurrentProcess(),
+ FilePath(),
+ false);
+ profile.GetExtensionService()->set_extensions_enabled(true);
+ profile.GetExtensionService()->set_show_extensions_prompts(false);
scoped_refptr<CrxInstaller> fake_crx1(
- CrxInstaller::Create(extension_service, NULL));
+ CrxInstaller::Create(profile.GetExtensionService(), NULL));
scoped_refptr<CrxInstaller> fake_crx2(
- CrxInstaller::Create(extension_service, NULL));
+ CrxInstaller::Create(profile.GetExtensionService(), NULL));
if (updates_start_running) {
// Add fake CrxInstaller to be returned by service.UpdateExtension().
diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc
deleted file mode 100644
index 5f271bf..0000000
--- a/chrome/browser/extensions/test_extension_system.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// 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;
-}
-
-ExtensionMessageService* TestExtensionSystem::message_service() {
- return NULL;
-}
-
-ExtensionEventRouter* TestExtensionSystem::event_router() {
- return NULL;
-}
-
-// static
-ProfileKeyedBase* 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
deleted file mode 100644
index 6c3d7ce..0000000
--- a/chrome/browser/extensions/test_extension_system.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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 ExtensionMessageService* message_service() OVERRIDE;
- virtual ExtensionEventRouter* event_router() OVERRIDE;
-
- // Factory method for tests to use with SetTestingProfile.
- static ProfileKeyedBase* 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/intents/web_intents_registry_factory.cc b/chrome/browser/intents/web_intents_registry_factory.cc
index 94d869f..2b22286 100644
--- a/chrome/browser/intents/web_intents_registry_factory.cc
+++ b/chrome/browser/intents/web_intents_registry_factory.cc
@@ -2,7 +2,6 @@
// 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"
@@ -19,7 +18,7 @@ WebIntentsRegistryFactory::WebIntentsRegistryFactory()
ProfileDependencyManager::GetInstance()) {
// TODO(erg): For Shutdown() order, we need to:
// DependsOn(WebDataServiceFactory::GetInstance());
- DependsOn(ExtensionSystemFactory::GetInstance());
+ // DependsOn(ExtensionServiceFactory::GetInstance());
}
WebIntentsRegistryFactory::~WebIntentsRegistryFactory() {
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 8b0a8e7..480eb1b 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -21,13 +21,11 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/api/webrequest/webrequest_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"
@@ -87,6 +85,8 @@ OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile)
}
void OffTheRecordProfileImpl::Init() {
+ extension_process_manager_.reset(ExtensionProcessManager::Create(this));
+
BrowserList::AddObserver(this);
ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false);
@@ -124,13 +124,6 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
io_data_.GetResourceContextNoInit());
- ExtensionService* extension_service =
- ExtensionSystemFactory::GetForProfile(this)->extension_service();
- if (extension_service) {
- extension_service->extension_prefs()->
- ClearIncognitoSessionOnlyContentSettings();
- }
-
ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
BrowserThread::PostTask(
@@ -145,6 +138,12 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
if (pref_proxy_config_tracker_.get())
pref_proxy_config_tracker_->DetachFromPrefService();
+ ExtensionService* extension_service = GetExtensionService();
+ if (extension_service) {
+ 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();
@@ -197,25 +196,33 @@ VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() {
return NULL;
}
-ExtensionPrefValueMap* OffTheRecordProfileImpl::GetExtensionPrefValueMap() {
- return NULL;
-}
-
ExtensionService* OffTheRecordProfileImpl::GetExtensionService() {
- return ExtensionSystemFactory::GetForProfile(this)->extension_service();
+ return GetOriginalProfile()->GetExtensionService();
}
UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() {
- return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
+ return GetOriginalProfile()->GetUserScriptMaster();
+}
+
+ExtensionDevToolsManager*
+ OffTheRecordProfileImpl::GetExtensionDevToolsManager() {
+ // TODO(mpcomplete): figure out whether we should return the original
+ // profile's version.
+ return NULL;
}
ExtensionProcessManager*
OffTheRecordProfileImpl::GetExtensionProcessManager() {
- return ExtensionSystemFactory::GetForProfile(this)->process_manager();
+ return extension_process_manager_.get();
+}
+
+ExtensionMessageService*
+ OffTheRecordProfileImpl::GetExtensionMessageService() {
+ return GetOriginalProfile()->GetExtensionMessageService();
}
ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() {
- return ExtensionSystemFactory::GetForProfile(this)->event_router();
+ return GetOriginalProfile()->GetExtensionEventRouter();
}
ExtensionSpecialStoragePolicy*
@@ -404,6 +411,10 @@ history::TopSites* OffTheRecordProfileImpl::GetTopSites() {
void OffTheRecordProfileImpl::MarkAsCleanShutdown() {
}
+void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) {
+ NOTREACHED();
+}
+
void OffTheRecordProfileImpl::InitPromoResources() {
NOTREACHED();
}
@@ -442,6 +453,10 @@ void OffTheRecordProfileImpl::OnBrowserAdded(const Browser* browser) {
void OffTheRecordProfileImpl::OnBrowserRemoved(const Browser* browser) {
}
+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 24631af..1a65d56 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -41,10 +41,11 @@ 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;
@@ -75,6 +76,7 @@ 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;
@@ -87,6 +89,7 @@ class OffTheRecordProfileImpl : public Profile,
virtual void OnBrowserAdded(const Browser* browser) OVERRIDE;
virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE;
+ virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
@@ -136,6 +139,11 @@ 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 648d5e2..ebc63cb 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -7,7 +7,6 @@
#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"
@@ -143,9 +142,6 @@ 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());
@@ -163,12 +159,12 @@ TEST_F(OffTheRecordProfileImplTest, GetHostZoomMap) {
EXPECT_NE(parent_zoom_map->GetZoomLevel(host),
child_zoom_map->GetZoomLevel(host)) <<
- "Child change must not propagate to parent.";
+ "Child change must not propaget 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 propagate to child.";
+ "Parent change should propaget to child.";
}
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 2d634eb..7407853 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -15,6 +15,7 @@
#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;
@@ -22,8 +23,10 @@ class BookmarkModel;
class ChromeAppCacheService;
class ChromeURLDataManager;
class Extension;
+class ExtensionDevToolsManager;
class ExtensionEventRouter;
-class ExtensionPrefValueMap;
+class ExtensionInfoMap;
+class ExtensionMessageService;
class ExtensionProcessManager;
class ExtensionService;
class ExtensionSpecialStoragePolicy;
@@ -216,32 +219,28 @@ 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;
- // DEPRECATED. Instead, use ExtensionSystemFactory::process_manager().
+ // Retrieves a pointer to the ExtensionDevToolsManager associated with this
+ // profile. The instance is created at startup.
+ virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() = 0;
+
// 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;
- // DEPRECATED. Instead, use ExtensionSystemFactory::event_router().
+ // Retrieves a pointer to the ExtensionMessageService associated with this
+ // profile. The instance is created at startup.
+ virtual ExtensionMessageService* GetExtensionMessageService() = 0;
+
// 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.
@@ -331,6 +330,21 @@ 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;
@@ -367,6 +381,11 @@ 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;
@@ -378,6 +397,9 @@ 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 4fd2b4f..8408b74 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -30,14 +30,18 @@
#include "chrome/browser/defaults.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/extension_system.h"
-#include "chrome/browser/extensions/extension_system_factory.h"
+#include "chrome/browser/extensions/unpacked_installer.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,6 +232,7 @@ 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),
@@ -425,6 +430,103 @@ 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));
+ extension_event_router_.reset(new ExtensionEventRouter(this));
+ extension_message_service_ = new ExtensionMessageService(this);
+ 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;
@@ -525,6 +627,9 @@ ProfileImpl::~ProfileImpl() {
// HistoryService first.
favicon_service_.reset();
+ if (extension_message_service_)
+ extension_message_service_->DestroyingProfile();
+
if (pref_proxy_config_tracker_.get())
pref_proxy_config_tracker_->DetachFromPrefService();
@@ -589,19 +694,27 @@ VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() {
}
ExtensionService* ProfileImpl::GetExtensionService() {
- return ExtensionSystemFactory::GetForProfile(this)->extension_service();
+ return extension_service_.get();
}
UserScriptMaster* ProfileImpl::GetUserScriptMaster() {
- return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
+ return user_script_master_.get();
+}
+
+ExtensionDevToolsManager* ProfileImpl::GetExtensionDevToolsManager() {
+ return extension_devtools_manager_.get();
}
ExtensionProcessManager* ProfileImpl::GetExtensionProcessManager() {
- return ExtensionSystemFactory::GetForProfile(this)->process_manager();
+ return extension_process_manager_.get();
+}
+
+ExtensionMessageService* ProfileImpl::GetExtensionMessageService() {
+ return extension_message_service_.get();
}
ExtensionEventRouter* ProfileImpl::GetExtensionEventRouter() {
- return ExtensionSystemFactory::GetForProfile(this)->event_router();
+ return extension_event_router_.get();
}
ExtensionSpecialStoragePolicy*
@@ -637,8 +750,20 @@ 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(),
@@ -683,10 +808,8 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContext() {
net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess(
int renderer_child_id) {
- ExtensionService* extension_service =
- ExtensionSystemFactory::GetForProfile(this)->extension_service();
- if (extension_service) {
- const Extension* installed_app = extension_service->
+ if (extension_service_.get()) {
+ const Extension* installed_app = extension_service_->
GetInstalledAppForRenderer(renderer_child_id);
if (installed_app != NULL && installed_app->is_storage_isolated() &&
installed_app->HasAPIPermission(
@@ -722,6 +845,31 @@ 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();
}
@@ -1101,6 +1249,10 @@ TokenService* ProfileImpl::GetTokenService() {
return token_service_.get();
}
+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 d96565d..a7b9b6f 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -22,7 +22,8 @@
#include "content/public/browser/notification_registrar.h"
class ExtensionNavigationObserver;
-class ExtensionSystem;
+class ExtensionPrefs;
+class ExtensionPrefValueMap;
class NetPrefObserver;
class PrefService;
class PromoResourceService;
@@ -73,10 +74,11 @@ class ProfileImpl : public Profile,
virtual history::TopSites* GetTopSites() OVERRIDE;
virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE;
virtual VisitedLinkMaster* GetVisitedLinkMaster() OVERRIDE;
- virtual ExtensionPrefValueMap* GetExtensionPrefValueMap() OVERRIDE;
- virtual ExtensionService* GetExtensionService() OVERRIDE;
virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE;
+ virtual ExtensionService* GetExtensionService() OVERRIDE;
+ virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() OVERRIDE;
virtual ExtensionProcessManager* GetExtensionProcessManager() OVERRIDE;
+ virtual ExtensionMessageService* GetExtensionMessageService() OVERRIDE;
virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE;
virtual ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy() OVERRIDE;
@@ -96,6 +98,11 @@ 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;
@@ -104,11 +111,13 @@ 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 TokenService* GetTokenService() OVERRIDE;
+ virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE;
@@ -162,6 +171,8 @@ class ProfileImpl : public Profile,
void EnsureSessionServiceCreated();
+ ExtensionPrefValueMap* GetExtensionPrefValueMap();
+
void UpdateProfileUserNameCache();
@@ -194,6 +205,22 @@ 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_;
+ scoped_refptr<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 ccdd58b..be8ae72 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -23,8 +23,6 @@
#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/media/media_internals.h"
#include "chrome/browser/net/chrome_cookie_notification_details.h"
@@ -224,8 +222,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
profile);
params->cookie_monster_delegate =
new ChromeCookieMonsterDelegate(profile_getter);
- params->extension_info_map =
- ExtensionSystemFactory::GetForProfile(profile)->info_map();
+ params->extension_info_map = profile->GetExtensionInfoMap();
#if defined(ENABLE_NOTIFICATIONS)
params->notification_service =
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 33d18a4..5dd29a2 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -18,8 +18,6 @@
#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/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile_info_cache.h"
@@ -611,9 +609,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();
- ExtensionSystemFactory::GetForProfile(profile)->Init(!go_off_the_record);
+ profile->InitExtensions(!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 00a2a1a..1563b5e 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -17,8 +17,6 @@
#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"
@@ -56,8 +54,7 @@ ChromeRenderMessageFilter::ChromeRenderMessageFilter(
: render_process_id_(render_process_id),
profile_(profile),
request_context_(request_context),
- extension_info_map_(
- ExtensionSystemFactory::GetForProfile(profile)->info_map()),
+ extension_info_map_(profile->GetExtensionInfoMap()),
cookie_settings_(CookieSettings::Factory::GetForProfile(profile)),
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
@@ -270,10 +267,9 @@ void ChromeRenderMessageFilter::OpenChannelToExtensionOnUIThread(
const std::string& target_extension_id,
const std::string& channel_name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ExtensionSystemFactory::GetForProfile(profile_)->message_service()->
- OpenChannelToExtension(
- source_process_id, source_routing_id, receiver_port_id,
- source_extension_id, target_extension_id, channel_name);
+ profile_->GetExtensionMessageService()->OpenChannelToExtension(
+ source_process_id, source_routing_id, receiver_port_id,
+ source_extension_id, target_extension_id, channel_name);
}
void ChromeRenderMessageFilter::OnOpenChannelToTab(
@@ -296,8 +292,7 @@ void ChromeRenderMessageFilter::OpenChannelToTabOnUIThread(
const std::string& extension_id,
const std::string& channel_name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ExtensionSystemFactory::GetForProfile(profile_)->message_service()->
- OpenChannelToTab(
+ profile_->GetExtensionMessageService()->OpenChannelToTab(
source_process_id, source_routing_id, receiver_port_id,
tab_id, extension_id, channel_name);
}
@@ -386,10 +381,8 @@ void ChromeRenderMessageFilter::OnExtensionCloseChannel(int port_id) {
if (!content::RenderProcessHost::FromID(render_process_id_))
return; // To guard against crash in browser_tests shutdown.
- ExtensionMessageService* message_service =
- ExtensionSystemFactory::GetForProfile(profile_)->message_service();
- if (message_service)
- message_service->CloseChannel(port_id);
+ if (profile_->GetExtensionMessageService())
+ profile_->GetExtensionMessageService()->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 32f029a..1f97689 100644
--- a/chrome/browser/sync/glue/extension_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_data_type_controller.cc
@@ -5,8 +5,6 @@
#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"
@@ -33,7 +31,7 @@ syncable::ModelType ExtensionDataTypeController::type() const {
}
bool ExtensionDataTypeController::StartModels() {
- ExtensionSystemFactory::GetForProfile(profile_)->Init(true);
+ profile_->InitExtensions(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 d265cd8..06f78fb 100644
--- a/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_setting_data_type_controller.cc
@@ -6,9 +6,6 @@
#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"
@@ -55,7 +52,7 @@ bool ExtensionSettingDataTypeController::PostTaskOnBackendThread(
bool ExtensionSettingDataTypeController::StartModels() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ExtensionSystemFactory::GetForProfile(profile_)->Init(true);
+ profile_->InitExtensions(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 20047ea..ead0275 100644
--- a/chrome/browser/sync/glue/theme_data_type_controller.cc
+++ b/chrome/browser/sync/glue/theme_data_type_controller.cc
@@ -5,8 +5,6 @@
#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"
@@ -29,7 +27,7 @@ syncable::ModelType ThemeDataTypeController::type() const {
}
bool ThemeDataTypeController::StartModels() {
- ExtensionSystemFactory::GetForProfile(profile_)->Init(true);
+ profile_->InitExtensions(true);
return true;
}
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc
index e083318..b0fa361 100644
--- a/chrome/browser/sync/profile_sync_service_factory.cc
+++ b/chrome/browser/sync/profile_sync_service_factory.cc
@@ -8,7 +8,6 @@
#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"
@@ -49,7 +48,6 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory()
DependsOn(ThemeServiceFactory::GetInstance());
DependsOn(GlobalErrorServiceFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance());
- DependsOn(ExtensionSystemFactory::GetInstance());
// The following have not been converted to ProfileKeyedServices yet, and for
// now they are explicitly destroyed after the ProfileDependencyManager is
@@ -61,6 +59,7 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory()
// DependsOn(BookmarkBarModelFactory::GetInstance());
// DependsOn(FaviconServiceFactory::GetInstance());
// DependsOn(PasswordStoreService::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 d784bdf..a2864be 100644
--- a/chrome/browser/sync/test/integration/sync_app_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_app_helper.cc
@@ -5,8 +5,6 @@
#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 +90,9 @@ void SyncAppHelper::SetupIfNecessary(SyncTest* test) {
return;
for (int i = 0; i < test->num_clients(); ++i) {
- ExtensionSystemFactory::GetForProfile(test->GetProfile(i))->Init(true);
+ test->GetProfile(i)->InitExtensions(true);
}
- ExtensionSystemFactory::GetForProfile(test->verifier())->Init(true);
+ test->verifier()->InitExtensions(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 a22b333..39e6298 100644
--- a/chrome/browser/sync/test/integration/sync_extension_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_extension_helper.cc
@@ -9,8 +9,6 @@
#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"
@@ -241,7 +239,7 @@ bool SyncExtensionHelper::ExtensionStatesMatch(
}
void SyncExtensionHelper::SetupProfile(Profile* profile) {
- ExtensionSystemFactory::GetForProfile(profile)->Init(true);
+ profile->InitExtensions(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 e07788a..4ab7a43 100644
--- a/chrome/browser/translate/translate_manager_browsertest.cc
+++ b/chrome/browser/translate/translate_manager_browsertest.cc
@@ -13,8 +13,6 @@
#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"
@@ -1307,7 +1305,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
// translate" infobar when the translation is accepted/declined 3 times,
// only when not in incognito mode.
TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) {
- Profile* profile =
+ Profile* profile =
Profile::FromBrowserContext(contents()->GetBrowserContext());
TranslatePrefs translate_prefs(profile->GetPrefs());
translate_prefs.ResetTranslationAcceptedCount("fr");
@@ -1320,9 +1318,7 @@ TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) {
TranslateInfoBarDelegate* infobar;
TestingProfile* test_profile =
static_cast<TestingProfile*>(contents()->GetBrowserContext());
- static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(test_profile))->
- CreateExtensionProcessManager();
+ 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 23e6ac0f..c794696 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
@@ -13,8 +13,6 @@
#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"
@@ -274,11 +272,8 @@ class BookmarkBarControllerTestBase : public CocoaProfileTest {
ASSERT_TRUE(profile());
FilePath extension_dir;
- static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile()))->
- CreateExtensionService(
- CommandLine::ForCurrentProcess(),
- extension_dir, false);
+ 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.gypi b/chrome/chrome_browser.gypi
index 2403b27..e7ce24b 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1253,10 +1253,6 @@
'browser/extensions/extension_special_storage_policy.h',
'browser/extensions/extension_sync_data.cc',
'browser/extensions/extension_sync_data.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_tab_helper.cc',
'browser/extensions/extension_tab_helper.h',
'browser/extensions/extension_tab_helper_delegate.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 7d5a1ef..78472ee 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -133,8 +133,6 @@
'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 66aea73..5e845fc 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -20,9 +20,6 @@
#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"
@@ -198,9 +195,6 @@ TestingProfile::TestingProfile(const FilePath& path,
}
void TestingProfile::Init() {
- ExtensionSystemFactory::GetInstance()->SetTestingFactory(
- this, TestExtensionSystem::Build);
-
profile_dependency_manager_->CreateProfileServices(this, true);
#if defined(ENABLE_NOTIFICATIONS)
@@ -392,6 +386,39 @@ 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_;
}
@@ -439,24 +466,28 @@ VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() {
return NULL;
}
-ExtensionPrefValueMap* TestingProfile::GetExtensionPrefValueMap() {
- return NULL;
-}
-
ExtensionService* TestingProfile::GetExtensionService() {
- return ExtensionSystemFactory::GetForProfile(this)->extension_service();
+ return extension_service_.get();
}
UserScriptMaster* TestingProfile::GetUserScriptMaster() {
- return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
+ return NULL;
+}
+
+ExtensionDevToolsManager* TestingProfile::GetExtensionDevToolsManager() {
+ return NULL;
}
ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() {
- return ExtensionSystemFactory::GetForProfile(this)->process_manager();
+ return extension_process_manager_.get();
+}
+
+ExtensionMessageService* TestingProfile::GetExtensionMessageService() {
+ return NULL;
}
ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() {
- return ExtensionSystemFactory::GetForProfile(this)->event_router();
+ return NULL;
}
void TestingProfile::SetExtensionSpecialStoragePolicy(
@@ -551,10 +582,8 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
int renderer_child_id) {
- ExtensionService* extension_service =
- ExtensionSystemFactory::GetForProfile(this)->extension_service();
- if (extension_service) {
- const Extension* installed_app = extension_service->
+ if (extension_service_.get()) {
+ const Extension* installed_app = extension_service_->
GetInstalledAppForRenderer(renderer_child_id);
if (installed_app != NULL && installed_app->is_storage_isolated())
return GetRequestContextForIsolatedApp(installed_app->id());
@@ -696,6 +725,10 @@ TokenService* TestingProfile::GetTokenService() {
return token_service_.get();
}
+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 5dca7b2..e499413 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -133,6 +133,18 @@ 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
@@ -168,10 +180,11 @@ 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);
@@ -228,6 +241,7 @@ 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 {}
@@ -253,6 +267,7 @@ class TestingProfile : public Profile {
void BlockUntilHistoryProcessesPendingRequests();
virtual TokenService* GetTokenService() OVERRIDE;
+ virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE;
@@ -336,6 +351,16 @@ 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_;