[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #include "chrome/browser/extensions/extension_system_factory.h" | ||||
6 | |||||
reillyg | 121e889 | 2014-11-03 22:12:59 | [diff] [blame] | 7 | #include "chrome/browser/extensions/blacklist_factory.h" |
binjin | 1569c9b | 2014-09-05 13:33:18 | [diff] [blame] | 8 | #include "chrome/browser/extensions/extension_management.h" |
juncai | 33e46210 | 2015-05-18 20:48:44 | [diff] [blame] | 9 | #include "chrome/browser/extensions/install_verifier_factory.h" |
[email protected] | d81bb3e | 2013-05-02 18:17:03 | [diff] [blame] | 10 | #include "chrome/browser/policy/profile_policy_connector_factory.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 11 | #include "chrome/browser/profiles/profile.h" |
Colin Blundell | 0610146f | 2018-05-23 10:23:23 | [diff] [blame] | 12 | #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
mlerman | 41e7bbe | 2014-11-27 20:10:15 | [diff] [blame] | 13 | #include "chrome/browser/signin/signin_manager_factory.h" |
[email protected] | 1ba55cf | 2012-06-29 19:11:39 | [diff] [blame] | 14 | #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
[email protected] | b33f0b11 | 2014-03-13 17:05:30 | [diff] [blame] | 15 | #include "components/keyed_service/content/browser_context_dependency_manager.h" |
juncai | 6b9c265c | 2015-05-18 21:00:12 | [diff] [blame] | 16 | #include "extensions/browser/declarative_user_script_manager_factory.h" |
juncai | cf52333 | 2015-06-04 00:14:04 | [diff] [blame] | 17 | #include "extensions/browser/event_router_factory.h" |
[email protected] | 489db084 | 2014-01-22 18:20:03 | [diff] [blame] | 18 | #include "extensions/browser/extension_prefs_factory.h" |
[email protected] | 5fdfa56 | 2013-12-27 17:43:59 | [diff] [blame] | 19 | #include "extensions/browser/extension_registry_factory.h" |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 20 | #include "extensions/browser/extension_system.h" |
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 21 | #include "extensions/browser/extensions_browser_client.h" |
reillyg | 0ea3fa90 | 2014-10-28 15:30:23 | [diff] [blame] | 22 | #include "extensions/browser/process_manager_factory.h" |
[email protected] | 44366da1 | 2014-01-28 01:38:41 | [diff] [blame] | 23 | #include "extensions/browser/renderer_startup_helper.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 24 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 25 | namespace extensions { |
26 | |||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 27 | // ExtensionSystemSharedFactory |
28 | |||||
29 | // static | ||||
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 30 | ExtensionSystemImpl::Shared* |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 31 | ExtensionSystemSharedFactory::GetForBrowserContext( |
32 | content::BrowserContext* context) { | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 33 | return static_cast<ExtensionSystemImpl::Shared*>( |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 34 | GetInstance()->GetServiceForBrowserContext(context, true)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 35 | } |
36 | |||||
37 | // static | ||||
38 | ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() { | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 39 | return base::Singleton<ExtensionSystemSharedFactory>::get(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 40 | } |
41 | |||||
42 | ExtensionSystemSharedFactory::ExtensionSystemSharedFactory() | ||||
[email protected] | f1484c5 | 2013-05-22 23:25:44 | [diff] [blame] | 43 | : BrowserContextKeyedServiceFactory( |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 44 | "ExtensionSystemShared", |
[email protected] | f1484c5 | 2013-05-22 23:25:44 | [diff] [blame] | 45 | BrowserContextDependencyManager::GetInstance()) { |
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame] | 46 | DependsOn(ExtensionPrefsFactory::GetInstance()); |
binjin | 1569c9b | 2014-09-05 13:33:18 | [diff] [blame] | 47 | DependsOn(ExtensionManagementFactory::GetInstance()); |
Colin Blundell | 0610146f | 2018-05-23 10:23:23 | [diff] [blame] | 48 | // This depends on ExtensionService, which depends on ExtensionRegistry. |
[email protected] | 5fdfa56 | 2013-12-27 17:43:59 | [diff] [blame] | 49 | DependsOn(ExtensionRegistryFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 50 | DependsOn(GlobalErrorServiceFactory::GetInstance()); |
juncai | 33e46210 | 2015-05-18 20:48:44 | [diff] [blame] | 51 | DependsOn(InstallVerifierFactory::GetInstance()); |
[email protected] | d81bb3e | 2013-05-02 18:17:03 | [diff] [blame] | 52 | DependsOn(policy::ProfilePolicyConnectorFactory::GetInstance()); |
reillyg | 0ea3fa90 | 2014-10-28 15:30:23 | [diff] [blame] | 53 | DependsOn(ProcessManagerFactory::GetInstance()); |
[email protected] | 44366da1 | 2014-01-28 01:38:41 | [diff] [blame] | 54 | DependsOn(RendererStartupHelperFactory::GetInstance()); |
reillyg | 121e889 | 2014-11-03 22:12:59 | [diff] [blame] | 55 | DependsOn(BlacklistFactory::GetInstance()); |
juncai | 6b9c265c | 2015-05-18 21:00:12 | [diff] [blame] | 56 | DependsOn(DeclarativeUserScriptManagerFactory::GetInstance()); |
juncai | cf52333 | 2015-06-04 00:14:04 | [diff] [blame] | 57 | DependsOn(EventRouterFactory::GetInstance()); |
Colin Blundell | 0610146f | 2018-05-23 10:23:23 | [diff] [blame] | 58 | // This depends on ExtensionDownloader, which depends on |
59 | // ProfileOAuth2TokenService and SigninManager for webstore authentication. | ||||
60 | DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | ||||
mlerman | 41e7bbe | 2014-11-27 20:10:15 | [diff] [blame] | 61 | DependsOn(SigninManagerFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 62 | } |
63 | |||||
64 | ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() { | ||||
65 | } | ||||
66 | |||||
[email protected] | b33f0b11 | 2014-03-13 17:05:30 | [diff] [blame] | 67 | KeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor( |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 68 | content::BrowserContext* context) const { |
69 | return new ExtensionSystemImpl::Shared(static_cast<Profile*>(context)); | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 70 | } |
71 | |||||
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame] | 72 | content::BrowserContext* ExtensionSystemSharedFactory::GetBrowserContextToUse( |
73 | content::BrowserContext* context) const { | ||||
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 74 | // Redirected in incognito. |
[email protected] | 8172a9d | 2014-01-09 23:18:30 | [diff] [blame] | 75 | return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 76 | } |
77 | |||||
78 | // ExtensionSystemFactory | ||||
79 | |||||
80 | // static | ||||
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 81 | ExtensionSystem* ExtensionSystemFactory::GetForBrowserContext( |
82 | content::BrowserContext* context) { | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 83 | return static_cast<ExtensionSystem*>( |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 84 | GetInstance()->GetServiceForBrowserContext(context, true)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 85 | } |
86 | |||||
87 | // static | ||||
88 | ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() { | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 89 | return base::Singleton<ExtensionSystemFactory>::get(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 90 | } |
91 | |||||
92 | ExtensionSystemFactory::ExtensionSystemFactory() | ||||
[email protected] | 7048930 | 2014-02-13 15:15:48 | [diff] [blame] | 93 | : ExtensionSystemProvider("ExtensionSystem", |
94 | BrowserContextDependencyManager::GetInstance()) { | ||||
[email protected] | 8172a9d | 2014-01-09 23:18:30 | [diff] [blame] | 95 | DCHECK(ExtensionsBrowserClient::Get()) |
96 | << "ExtensionSystemFactory must be initialized after BrowserProcess"; | ||||
[email protected] | 7048930 | 2014-02-13 15:15:48 | [diff] [blame] | 97 | DependsOn(ExtensionSystemSharedFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 98 | } |
99 | |||||
100 | ExtensionSystemFactory::~ExtensionSystemFactory() { | ||||
101 | } | ||||
102 | |||||
[email protected] | b33f0b11 | 2014-03-13 17:05:30 | [diff] [blame] | 103 | KeyedService* ExtensionSystemFactory::BuildServiceInstanceFor( |
[email protected] | 8172a9d | 2014-01-09 23:18:30 | [diff] [blame] | 104 | content::BrowserContext* context) const { |
[email protected] | 7048930 | 2014-02-13 15:15:48 | [diff] [blame] | 105 | return new ExtensionSystemImpl(static_cast<Profile*>(context)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 106 | } |
107 | |||||
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame] | 108 | content::BrowserContext* ExtensionSystemFactory::GetBrowserContextToUse( |
109 | content::BrowserContext* context) const { | ||||
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 110 | // Separate instance in incognito. |
111 | return context; | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 112 | } |
113 | |||||
[email protected] | f1484c5 | 2013-05-22 23:25:44 | [diff] [blame] | 114 | bool ExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 115 | return true; |
116 | } | ||||
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 117 | |
118 | } // namespace extensions |