[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 | |
| 7 | #include "chrome/browser/extensions/extension_message_service.h" |
| 8 | #include "chrome/browser/extensions/extension_prefs.h" |
| 9 | #include "chrome/browser/extensions/extension_service.h" |
| 10 | #include "chrome/browser/extensions/extension_system.h" |
| 11 | #include "chrome/browser/profiles/profile.h" |
| 12 | #include "chrome/browser/profiles/profile_dependency_manager.h" |
[email protected] | 89a773b | 2012-06-11 20:24:30 | [diff] [blame] | 13 | #include "chrome/browser/protector/protector_service_factory.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 14 | #include "chrome/browser/themes/theme_service_factory.h" |
[email protected] | 1ba55cf | 2012-06-29 19:11:39 | [diff] [blame^] | 15 | #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 16 | |
| 17 | // ExtensionSystemSharedFactory |
| 18 | |
| 19 | // static |
| 20 | ExtensionSystemImpl::Shared* ExtensionSystemSharedFactory::GetForProfile( |
| 21 | Profile* profile) { |
| 22 | return static_cast<ExtensionSystemImpl::Shared*>( |
| 23 | GetInstance()->GetServiceForProfile(profile, true)); |
| 24 | } |
| 25 | |
| 26 | // static |
| 27 | ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() { |
| 28 | return Singleton<ExtensionSystemSharedFactory>::get(); |
| 29 | } |
| 30 | |
| 31 | ExtensionSystemSharedFactory::ExtensionSystemSharedFactory() |
| 32 | : ProfileKeyedServiceFactory( |
| 33 | "ExtensionSystemShared", |
| 34 | ProfileDependencyManager::GetInstance()) { |
| 35 | DependsOn(GlobalErrorServiceFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 36 | DependsOn(ThemeServiceFactory::GetInstance()); |
[email protected] | 89a773b | 2012-06-11 20:24:30 | [diff] [blame] | 37 | // ProtectorService should be destroyed after us. |
| 38 | DependsOn(protector::ProtectorServiceFactory::GetInstance()); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() { |
| 42 | } |
| 43 | |
| 44 | ProfileKeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor( |
| 45 | Profile* profile) const { |
| 46 | return new ExtensionSystemImpl::Shared(profile); |
| 47 | } |
| 48 | |
| 49 | bool ExtensionSystemSharedFactory::ServiceRedirectedInIncognito() { |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | // ExtensionSystemFactory |
| 54 | |
| 55 | // static |
[email protected] | 749d59a | 2012-04-05 00:23:24 | [diff] [blame] | 56 | ExtensionSystem* ExtensionSystemFactory::GetForProfile(Profile* profile) { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 57 | return static_cast<ExtensionSystem*>( |
| 58 | GetInstance()->GetServiceForProfile(profile, true)); |
| 59 | } |
| 60 | |
| 61 | // static |
| 62 | ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() { |
| 63 | return Singleton<ExtensionSystemFactory>::get(); |
| 64 | } |
| 65 | |
| 66 | ExtensionSystemFactory::ExtensionSystemFactory() |
| 67 | : ProfileKeyedServiceFactory( |
| 68 | "ExtensionSystem", |
| 69 | ProfileDependencyManager::GetInstance()) { |
| 70 | DependsOn(ExtensionSystemSharedFactory::GetInstance()); |
| 71 | } |
| 72 | |
| 73 | ExtensionSystemFactory::~ExtensionSystemFactory() { |
| 74 | } |
| 75 | |
| 76 | ProfileKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor( |
| 77 | Profile* profile) const { |
| 78 | return new ExtensionSystemImpl(profile); |
| 79 | } |
| 80 | |
| 81 | bool ExtensionSystemFactory::ServiceHasOwnInstanceInIncognito() { |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | bool ExtensionSystemFactory::ServiceIsCreatedWithProfile() { |
| 86 | return true; |
| 87 | } |