blob: fbfe42d3b3511429d37eeac2e116b755c5f34bcc [file] [log] [blame]
[email protected]31d8f5f22012-04-02 15:22:081// 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
reillyg121e8892014-11-03 22:12:597#include "chrome/browser/extensions/blacklist_factory.h"
binjin1569c9b2014-09-05 13:33:188#include "chrome/browser/extensions/extension_management.h"
juncai33e462102015-05-18 20:48:449#include "chrome/browser/extensions/install_verifier_factory.h"
[email protected]d81bb3e2013-05-02 18:17:0310#include "chrome/browser/policy/profile_policy_connector_factory.h"
[email protected]31d8f5f22012-04-02 15:22:0811#include "chrome/browser/profiles/profile.h"
Colin Blundell0610146f2018-05-23 10:23:2312#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
mlerman41e7bbe2014-11-27 20:10:1513#include "chrome/browser/signin/signin_manager_factory.h"
[email protected]1ba55cf2012-06-29 19:11:3914#include "chrome/browser/ui/global_error/global_error_service_factory.h"
[email protected]b33f0b112014-03-13 17:05:3015#include "components/keyed_service/content/browser_context_dependency_manager.h"
juncai6b9c265c2015-05-18 21:00:1216#include "extensions/browser/declarative_user_script_manager_factory.h"
juncaicf523332015-06-04 00:14:0417#include "extensions/browser/event_router_factory.h"
[email protected]489db0842014-01-22 18:20:0318#include "extensions/browser/extension_prefs_factory.h"
[email protected]5fdfa562013-12-27 17:43:5919#include "extensions/browser/extension_registry_factory.h"
[email protected]59b0e602014-01-30 00:41:2420#include "extensions/browser/extension_system.h"
[email protected]da762a82013-12-07 03:45:5821#include "extensions/browser/extensions_browser_client.h"
reillyg0ea3fa902014-10-28 15:30:2322#include "extensions/browser/process_manager_factory.h"
[email protected]44366da12014-01-28 01:38:4123#include "extensions/browser/renderer_startup_helper.h"
[email protected]31d8f5f22012-04-02 15:22:0824
[email protected]bd306722012-07-11 20:43:5925namespace extensions {
26
[email protected]31d8f5f22012-04-02 15:22:0827// ExtensionSystemSharedFactory
28
29// static
[email protected]bd306722012-07-11 20:43:5930ExtensionSystemImpl::Shared*
[email protected]59b0e602014-01-30 00:41:2431ExtensionSystemSharedFactory::GetForBrowserContext(
32 content::BrowserContext* context) {
[email protected]31d8f5f22012-04-02 15:22:0833 return static_cast<ExtensionSystemImpl::Shared*>(
[email protected]59b0e602014-01-30 00:41:2434 GetInstance()->GetServiceForBrowserContext(context, true));
[email protected]31d8f5f22012-04-02 15:22:0835}
36
37// static
38ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2239 return base::Singleton<ExtensionSystemSharedFactory>::get();
[email protected]31d8f5f22012-04-02 15:22:0840}
41
42ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
[email protected]f1484c52013-05-22 23:25:4443 : BrowserContextKeyedServiceFactory(
[email protected]31d8f5f22012-04-02 15:22:0844 "ExtensionSystemShared",
[email protected]f1484c52013-05-22 23:25:4445 BrowserContextDependencyManager::GetInstance()) {
[email protected]836e2982013-05-16 08:07:4246 DependsOn(ExtensionPrefsFactory::GetInstance());
binjin1569c9b2014-09-05 13:33:1847 DependsOn(ExtensionManagementFactory::GetInstance());
Colin Blundell0610146f2018-05-23 10:23:2348 // This depends on ExtensionService, which depends on ExtensionRegistry.
[email protected]5fdfa562013-12-27 17:43:5949 DependsOn(ExtensionRegistryFactory::GetInstance());
[email protected]31d8f5f22012-04-02 15:22:0850 DependsOn(GlobalErrorServiceFactory::GetInstance());
juncai33e462102015-05-18 20:48:4451 DependsOn(InstallVerifierFactory::GetInstance());
[email protected]d81bb3e2013-05-02 18:17:0352 DependsOn(policy::ProfilePolicyConnectorFactory::GetInstance());
reillyg0ea3fa902014-10-28 15:30:2353 DependsOn(ProcessManagerFactory::GetInstance());
[email protected]44366da12014-01-28 01:38:4154 DependsOn(RendererStartupHelperFactory::GetInstance());
reillyg121e8892014-11-03 22:12:5955 DependsOn(BlacklistFactory::GetInstance());
juncai6b9c265c2015-05-18 21:00:1256 DependsOn(DeclarativeUserScriptManagerFactory::GetInstance());
juncaicf523332015-06-04 00:14:0457 DependsOn(EventRouterFactory::GetInstance());
Colin Blundell0610146f2018-05-23 10:23:2358 // This depends on ExtensionDownloader, which depends on
59 // ProfileOAuth2TokenService and SigninManager for webstore authentication.
60 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
mlerman41e7bbe2014-11-27 20:10:1561 DependsOn(SigninManagerFactory::GetInstance());
[email protected]31d8f5f22012-04-02 15:22:0862}
63
64ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
65}
66
[email protected]b33f0b112014-03-13 17:05:3067KeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
[email protected]59b0e602014-01-30 00:41:2468 content::BrowserContext* context) const {
69 return new ExtensionSystemImpl::Shared(static_cast<Profile*>(context));
[email protected]31d8f5f22012-04-02 15:22:0870}
71
[email protected]018bf652013-05-03 23:18:3472content::BrowserContext* ExtensionSystemSharedFactory::GetBrowserContextToUse(
73 content::BrowserContext* context) const {
[email protected]da762a82013-12-07 03:45:5874 // Redirected in incognito.
[email protected]8172a9d2014-01-09 23:18:3075 return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
[email protected]31d8f5f22012-04-02 15:22:0876}
77
78// ExtensionSystemFactory
79
80// static
[email protected]59b0e602014-01-30 00:41:2481ExtensionSystem* ExtensionSystemFactory::GetForBrowserContext(
82 content::BrowserContext* context) {
[email protected]31d8f5f22012-04-02 15:22:0883 return static_cast<ExtensionSystem*>(
[email protected]59b0e602014-01-30 00:41:2484 GetInstance()->GetServiceForBrowserContext(context, true));
[email protected]31d8f5f22012-04-02 15:22:0885}
86
87// static
88ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2289 return base::Singleton<ExtensionSystemFactory>::get();
[email protected]31d8f5f22012-04-02 15:22:0890}
91
92ExtensionSystemFactory::ExtensionSystemFactory()
[email protected]70489302014-02-13 15:15:4893 : ExtensionSystemProvider("ExtensionSystem",
94 BrowserContextDependencyManager::GetInstance()) {
[email protected]8172a9d2014-01-09 23:18:3095 DCHECK(ExtensionsBrowserClient::Get())
96 << "ExtensionSystemFactory must be initialized after BrowserProcess";
[email protected]70489302014-02-13 15:15:4897 DependsOn(ExtensionSystemSharedFactory::GetInstance());
[email protected]31d8f5f22012-04-02 15:22:0898}
99
100ExtensionSystemFactory::~ExtensionSystemFactory() {
101}
102
[email protected]b33f0b112014-03-13 17:05:30103KeyedService* ExtensionSystemFactory::BuildServiceInstanceFor(
[email protected]8172a9d2014-01-09 23:18:30104 content::BrowserContext* context) const {
[email protected]70489302014-02-13 15:15:48105 return new ExtensionSystemImpl(static_cast<Profile*>(context));
[email protected]31d8f5f22012-04-02 15:22:08106}
107
[email protected]018bf652013-05-03 23:18:34108content::BrowserContext* ExtensionSystemFactory::GetBrowserContextToUse(
109 content::BrowserContext* context) const {
[email protected]da762a82013-12-07 03:45:58110 // Separate instance in incognito.
111 return context;
[email protected]31d8f5f22012-04-02 15:22:08112}
113
[email protected]f1484c52013-05-22 23:25:44114bool ExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
[email protected]31d8f5f22012-04-02 15:22:08115 return true;
116}
[email protected]bd306722012-07-11 20:43:59117
118} // namespace extensions