[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 | |||||
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame^] | 7 | #include "chrome/browser/extensions/extension_prefs_factory.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 8 | #include "chrome/browser/extensions/extension_system.h" |
[email protected] | d81bb3e | 2013-05-02 18:17:03 | [diff] [blame] | 9 | #include "chrome/browser/policy/profile_policy_connector_factory.h" |
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame] | 10 | #include "chrome/browser/profiles/incognito_helpers.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 11 | #include "chrome/browser/profiles/profile.h" |
12 | #include "chrome/browser/profiles/profile_dependency_manager.h" | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 13 | #include "chrome/browser/themes/theme_service_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] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 15 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 16 | namespace extensions { |
17 | |||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 18 | // ExtensionSystemSharedFactory |
19 | |||||
20 | // static | ||||
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 21 | ExtensionSystemImpl::Shared* |
22 | ExtensionSystemSharedFactory::GetForProfile(Profile* profile) { | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 23 | return static_cast<ExtensionSystemImpl::Shared*>( |
24 | GetInstance()->GetServiceForProfile(profile, true)); | ||||
25 | } | ||||
26 | |||||
27 | // static | ||||
28 | ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() { | ||||
29 | return Singleton<ExtensionSystemSharedFactory>::get(); | ||||
30 | } | ||||
31 | |||||
32 | ExtensionSystemSharedFactory::ExtensionSystemSharedFactory() | ||||
33 | : ProfileKeyedServiceFactory( | ||||
34 | "ExtensionSystemShared", | ||||
35 | ProfileDependencyManager::GetInstance()) { | ||||
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame^] | 36 | DependsOn(ExtensionPrefsFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 37 | DependsOn(GlobalErrorServiceFactory::GetInstance()); |
[email protected] | f766a9d | 2012-07-11 01:57:44 | [diff] [blame] | 38 | #if defined(ENABLE_THEMES) |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 39 | DependsOn(ThemeServiceFactory::GetInstance()); |
[email protected] | f766a9d | 2012-07-11 01:57:44 | [diff] [blame] | 40 | #endif |
[email protected] | d81bb3e | 2013-05-02 18:17:03 | [diff] [blame] | 41 | DependsOn(policy::ProfilePolicyConnectorFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 42 | } |
43 | |||||
44 | ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() { | ||||
45 | } | ||||
46 | |||||
47 | ProfileKeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor( | ||||
[email protected] | c7fa436 | 2013-04-26 18:09:02 | [diff] [blame] | 48 | content::BrowserContext* profile) const { |
49 | return new ExtensionSystemImpl::Shared(static_cast<Profile*>(profile)); | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 50 | } |
51 | |||||
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame] | 52 | content::BrowserContext* ExtensionSystemSharedFactory::GetBrowserContextToUse( |
53 | content::BrowserContext* context) const { | ||||
54 | return chrome::GetBrowserContextRedirectedInIncognito(context); | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 55 | } |
56 | |||||
57 | // ExtensionSystemFactory | ||||
58 | |||||
59 | // static | ||||
[email protected] | 749d59a | 2012-04-05 00:23:24 | [diff] [blame] | 60 | ExtensionSystem* ExtensionSystemFactory::GetForProfile(Profile* profile) { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 61 | return static_cast<ExtensionSystem*>( |
62 | GetInstance()->GetServiceForProfile(profile, true)); | ||||
63 | } | ||||
64 | |||||
65 | // static | ||||
66 | ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() { | ||||
67 | return Singleton<ExtensionSystemFactory>::get(); | ||||
68 | } | ||||
69 | |||||
70 | ExtensionSystemFactory::ExtensionSystemFactory() | ||||
71 | : ProfileKeyedServiceFactory( | ||||
72 | "ExtensionSystem", | ||||
73 | ProfileDependencyManager::GetInstance()) { | ||||
74 | DependsOn(ExtensionSystemSharedFactory::GetInstance()); | ||||
75 | } | ||||
76 | |||||
77 | ExtensionSystemFactory::~ExtensionSystemFactory() { | ||||
78 | } | ||||
79 | |||||
80 | ProfileKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor( | ||||
[email protected] | c7fa436 | 2013-04-26 18:09:02 | [diff] [blame] | 81 | content::BrowserContext* profile) const { |
82 | return new ExtensionSystemImpl(static_cast<Profile*>(profile)); | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 83 | } |
84 | |||||
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame] | 85 | content::BrowserContext* ExtensionSystemFactory::GetBrowserContextToUse( |
86 | content::BrowserContext* context) const { | ||||
87 | return chrome::GetBrowserContextOwnInstanceInIncognito(context); | ||||
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 88 | } |
89 | |||||
[email protected] | bb05cae1 | 2012-09-06 00:37:52 | [diff] [blame] | 90 | bool ExtensionSystemFactory::ServiceIsCreatedWithProfile() const { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 91 | return true; |
92 | } | ||||
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 93 | |
94 | } // namespace extensions |