Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [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" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 8 | #include "chrome/browser/profiles/profile.h" |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 9 | #include "components/keyed_service/content/browser_context_dependency_manager.h" |
Primiano Tucci | 1320f92 | 2014-09-30 14:45:55 +0100 | [diff] [blame] | 10 | #include "extensions/browser/app_window/app_window_registry.h" |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 11 | #include "extensions/browser/extension_prefs_factory.h" |
Primiano Tucci | 1320f92 | 2014-09-30 14:45:55 +0100 | [diff] [blame] | 12 | #include "extensions/browser/extension_registry_factory.h" |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 13 | #include "extensions/browser/extension_system_provider.h" |
Torne (Richard Coles) | a3f6a49 | 2013-12-18 16:25:09 +0000 | [diff] [blame] | 14 | #include "extensions/browser/extensions_browser_client.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 15 | |
| 16 | namespace apps { |
| 17 | |
| 18 | // static |
| 19 | AppLoadService* AppLoadServiceFactory::GetForProfile(Profile* profile) { |
| 20 | return static_cast<AppLoadService*>( |
| 21 | GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 22 | } |
| 23 | |
| 24 | AppLoadServiceFactory* AppLoadServiceFactory::GetInstance() { |
| 25 | return Singleton<AppLoadServiceFactory>::get(); |
| 26 | } |
| 27 | |
| 28 | AppLoadServiceFactory::AppLoadServiceFactory() |
| 29 | : BrowserContextKeyedServiceFactory( |
| 30 | "AppLoadService", |
| 31 | BrowserContextDependencyManager::GetInstance()) { |
Primiano Tucci | 1320f92 | 2014-09-30 14:45:55 +0100 | [diff] [blame] | 32 | DependsOn(extensions::AppWindowRegistry::Factory::GetInstance()); |
| 33 | DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); |
| 34 | DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 35 | DependsOn( |
| 36 | extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | AppLoadServiceFactory::~AppLoadServiceFactory() { |
| 40 | } |
| 41 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 42 | KeyedService* AppLoadServiceFactory::BuildServiceInstanceFor( |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 43 | content::BrowserContext* profile) const { |
| 44 | return new AppLoadService(static_cast<Profile*>(profile)); |
| 45 | } |
| 46 | |
| 47 | bool AppLoadServiceFactory::ServiceIsNULLWhileTesting() const { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | bool AppLoadServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | content::BrowserContext* AppLoadServiceFactory::GetBrowserContextToUse( |
| 56 | content::BrowserContext* context) const { |
Torne (Richard Coles) | a3f6a49 | 2013-12-18 16:25:09 +0000 | [diff] [blame] | 57 | // Redirected in incognito. |
| 58 | return extensions::ExtensionsBrowserClient::Get()-> |
| 59 | GetOriginalContext(context); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | } // namespace apps |