Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / extension_system_factory.cc
blobbea8cfbdb06b1e92323cec78f262e5e5633a42ac
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/extensions/install_verifier_factory.h"
10 #include "chrome/browser/policy/profile_policy_connector_factory.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/signin/signin_manager_factory.h"
13 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "extensions/browser/declarative_user_script_manager_factory.h"
16 #include "extensions/browser/event_router_factory.h"
17 #include "extensions/browser/extension_prefs_factory.h"
18 #include "extensions/browser/extension_registry_factory.h"
19 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/extensions_browser_client.h"
21 #include "extensions/browser/process_manager_factory.h"
22 #include "extensions/browser/renderer_startup_helper.h"
24 namespace extensions {
26 // ExtensionSystemSharedFactory
28 // static
29 ExtensionSystemImpl::Shared*
30 ExtensionSystemSharedFactory::GetForBrowserContext(
31 content::BrowserContext* context) {
32 return static_cast<ExtensionSystemImpl::Shared*>(
33 GetInstance()->GetServiceForBrowserContext(context, true));
36 // static
37 ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() {
38 return Singleton<ExtensionSystemSharedFactory>::get();
41 ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
42 : BrowserContextKeyedServiceFactory(
43 "ExtensionSystemShared",
44 BrowserContextDependencyManager::GetInstance()) {
45 DependsOn(ExtensionPrefsFactory::GetInstance());
46 DependsOn(ExtensionManagementFactory::GetInstance());
47 // This depends on ExtensionService which depends on ExtensionRegistry.
48 DependsOn(ExtensionRegistryFactory::GetInstance());
49 DependsOn(GlobalErrorServiceFactory::GetInstance());
50 DependsOn(InstallVerifierFactory::GetInstance());
51 DependsOn(policy::ProfilePolicyConnectorFactory::GetInstance());
52 DependsOn(ProcessManagerFactory::GetInstance());
53 DependsOn(RendererStartupHelperFactory::GetInstance());
54 DependsOn(BlacklistFactory::GetInstance());
55 DependsOn(DeclarativeUserScriptManagerFactory::GetInstance());
56 DependsOn(EventRouterFactory::GetInstance());
57 // This depends on ExtensionDownloader which depends on
58 // ProfileIdentityProvider which depends on SigninManager.
59 DependsOn(SigninManagerFactory::GetInstance());
62 ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
65 KeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
66 content::BrowserContext* context) const {
67 return new ExtensionSystemImpl::Shared(static_cast<Profile*>(context));
70 content::BrowserContext* ExtensionSystemSharedFactory::GetBrowserContextToUse(
71 content::BrowserContext* context) const {
72 // Redirected in incognito.
73 return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
76 // ExtensionSystemFactory
78 // static
79 ExtensionSystem* ExtensionSystemFactory::GetForBrowserContext(
80 content::BrowserContext* context) {
81 return static_cast<ExtensionSystem*>(
82 GetInstance()->GetServiceForBrowserContext(context, true));
85 // static
86 ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() {
87 return Singleton<ExtensionSystemFactory>::get();
90 ExtensionSystemFactory::ExtensionSystemFactory()
91 : ExtensionSystemProvider("ExtensionSystem",
92 BrowserContextDependencyManager::GetInstance()) {
93 DCHECK(ExtensionsBrowserClient::Get())
94 << "ExtensionSystemFactory must be initialized after BrowserProcess";
95 DependsOn(ExtensionSystemSharedFactory::GetInstance());
98 ExtensionSystemFactory::~ExtensionSystemFactory() {
101 KeyedService* ExtensionSystemFactory::BuildServiceInstanceFor(
102 content::BrowserContext* context) const {
103 return new ExtensionSystemImpl(static_cast<Profile*>(context));
106 content::BrowserContext* ExtensionSystemFactory::GetBrowserContextToUse(
107 content::BrowserContext* context) const {
108 // Separate instance in incognito.
109 return context;
112 bool ExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
113 return true;
116 } // namespace extensions