1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_system_factory.h"
7 #include "chrome/browser/extensions/blacklist_factory.h"
8 #include "chrome/browser/extensions/extension_management.h"
9 #include "chrome/browser/policy/profile_policy_connector_factory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/signin/signin_manager_factory.h"
12 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "extensions/browser/extension_prefs_factory.h"
15 #include "extensions/browser/extension_registry_factory.h"
16 #include "extensions/browser/extension_system.h"
17 #include "extensions/browser/extensions_browser_client.h"
18 #include "extensions/browser/process_manager_factory.h"
19 #include "extensions/browser/renderer_startup_helper.h"
21 namespace extensions
{
23 // ExtensionSystemSharedFactory
26 ExtensionSystemImpl::Shared
*
27 ExtensionSystemSharedFactory::GetForBrowserContext(
28 content::BrowserContext
* context
) {
29 return static_cast<ExtensionSystemImpl::Shared
*>(
30 GetInstance()->GetServiceForBrowserContext(context
, true));
34 ExtensionSystemSharedFactory
* ExtensionSystemSharedFactory::GetInstance() {
35 return Singleton
<ExtensionSystemSharedFactory
>::get();
38 ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
39 : BrowserContextKeyedServiceFactory(
40 "ExtensionSystemShared",
41 BrowserContextDependencyManager::GetInstance()) {
42 DependsOn(ExtensionPrefsFactory::GetInstance());
43 DependsOn(ExtensionManagementFactory::GetInstance());
44 // This depends on ExtensionService which depends on ExtensionRegistry.
45 DependsOn(ExtensionRegistryFactory::GetInstance());
46 DependsOn(GlobalErrorServiceFactory::GetInstance());
47 DependsOn(policy::ProfilePolicyConnectorFactory::GetInstance());
48 DependsOn(ProcessManagerFactory::GetInstance());
49 DependsOn(RendererStartupHelperFactory::GetInstance());
50 DependsOn(BlacklistFactory::GetInstance());
51 // This depends on ExtensionDownloader which depends on
52 // ProfileIdentityProvider which depends on SigninManager.
53 DependsOn(SigninManagerFactory::GetInstance());
56 ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
59 KeyedService
* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
60 content::BrowserContext
* context
) const {
61 return new ExtensionSystemImpl::Shared(static_cast<Profile
*>(context
));
64 content::BrowserContext
* ExtensionSystemSharedFactory::GetBrowserContextToUse(
65 content::BrowserContext
* context
) const {
66 // Redirected in incognito.
67 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
70 // ExtensionSystemFactory
73 ExtensionSystem
* ExtensionSystemFactory::GetForBrowserContext(
74 content::BrowserContext
* context
) {
75 return static_cast<ExtensionSystem
*>(
76 GetInstance()->GetServiceForBrowserContext(context
, true));
80 ExtensionSystemFactory
* ExtensionSystemFactory::GetInstance() {
81 return Singleton
<ExtensionSystemFactory
>::get();
84 ExtensionSystemFactory::ExtensionSystemFactory()
85 : ExtensionSystemProvider("ExtensionSystem",
86 BrowserContextDependencyManager::GetInstance()) {
87 DCHECK(ExtensionsBrowserClient::Get())
88 << "ExtensionSystemFactory must be initialized after BrowserProcess";
89 DependsOn(ExtensionSystemSharedFactory::GetInstance());
92 ExtensionSystemFactory::~ExtensionSystemFactory() {
95 KeyedService
* ExtensionSystemFactory::BuildServiceInstanceFor(
96 content::BrowserContext
* context
) const {
97 return new ExtensionSystemImpl(static_cast<Profile
*>(context
));
100 content::BrowserContext
* ExtensionSystemFactory::GetBrowserContextToUse(
101 content::BrowserContext
* context
) const {
102 // Separate instance in incognito.
106 bool ExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
110 } // namespace extensions