[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 1 | // Copyright 2013 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 "apps/app_load_service_factory.h" |
| 6 | |
| 7 | #include "apps/app_load_service.h" |
[email protected] | f6d9b28 | 2013-08-09 11:03:20 | [diff] [blame] | 8 | #include "apps/shell_window_registry.h" |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 9 | #include "chrome/browser/extensions/extension_system_factory.h" |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 10 | #include "chrome/browser/profiles/profile.h" |
| 11 | #include "components/browser_context_keyed_service/browser_context_dependency_manager.h" |
[email protected] | 489db084 | 2014-01-22 18:20:03 | [diff] [blame^] | 12 | #include "extensions/browser/extension_prefs_factory.h" |
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 13 | #include "extensions/browser/extensions_browser_client.h" |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 14 | |
| 15 | namespace apps { |
| 16 | |
| 17 | // static |
| 18 | AppLoadService* AppLoadServiceFactory::GetForProfile(Profile* profile) { |
| 19 | return static_cast<AppLoadService*>( |
| 20 | GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 21 | } |
| 22 | |
| 23 | AppLoadServiceFactory* AppLoadServiceFactory::GetInstance() { |
| 24 | return Singleton<AppLoadServiceFactory>::get(); |
| 25 | } |
| 26 | |
| 27 | AppLoadServiceFactory::AppLoadServiceFactory() |
| 28 | : BrowserContextKeyedServiceFactory( |
| 29 | "AppLoadService", |
| 30 | BrowserContextDependencyManager::GetInstance()) { |
| 31 | DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); |
| 32 | DependsOn(extensions::ExtensionSystemFactory::GetInstance()); |
[email protected] | f6d9b28 | 2013-08-09 11:03:20 | [diff] [blame] | 33 | DependsOn(ShellWindowRegistry::Factory::GetInstance()); |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | AppLoadServiceFactory::~AppLoadServiceFactory() { |
| 37 | } |
| 38 | |
| 39 | BrowserContextKeyedService* AppLoadServiceFactory::BuildServiceInstanceFor( |
| 40 | content::BrowserContext* profile) const { |
| 41 | return new AppLoadService(static_cast<Profile*>(profile)); |
| 42 | } |
| 43 | |
| 44 | bool AppLoadServiceFactory::ServiceIsNULLWhileTesting() const { |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | bool AppLoadServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | content::BrowserContext* AppLoadServiceFactory::GetBrowserContextToUse( |
| 53 | content::BrowserContext* context) const { |
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 54 | // Redirected in incognito. |
| 55 | return extensions::ExtensionsBrowserClient::Get()-> |
| 56 | GetOriginalContext(context); |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } // namespace apps |