[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] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 8 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 9 | #include "components/keyed_service/content/browser_context_dependency_manager.h" |
hashimoto | ad3c687 | 2014-08-29 09:46:57 | [diff] [blame] | 10 | #include "extensions/browser/app_window/app_window_registry.h" |
[email protected] | 489db084 | 2014-01-22 18:20:03 | [diff] [blame] | 11 | #include "extensions/browser/extension_prefs_factory.h" |
limasdf | d3791758 | 2014-09-17 00:21:43 | [diff] [blame] | 12 | #include "extensions/browser/extension_registry_factory.h" |
[email protected] | 7048930 | 2014-02-13 15:15:48 | [diff] [blame] | 13 | #include "extensions/browser/extension_system_provider.h" |
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 14 | #include "extensions/browser/extensions_browser_client.h" |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [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() { | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 25 | return base::Singleton<AppLoadServiceFactory>::get(); |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 26 | } |
27 | |||||
28 | AppLoadServiceFactory::AppLoadServiceFactory() | ||||
29 | : BrowserContextKeyedServiceFactory( | ||||
30 | "AppLoadService", | ||||
31 | BrowserContextDependencyManager::GetInstance()) { | ||||
limasdf | d3791758 | 2014-09-17 00:21:43 | [diff] [blame] | 32 | DependsOn(extensions::AppWindowRegistry::Factory::GetInstance()); |
33 | DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); | ||||
34 | DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); | ||||
[email protected] | 7048930 | 2014-02-13 15:15:48 | [diff] [blame] | 35 | DependsOn( |
36 | extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | ||||
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 37 | } |
38 | |||||
39 | AppLoadServiceFactory::~AppLoadServiceFactory() { | ||||
40 | } | ||||
41 | |||||
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 42 | KeyedService* AppLoadServiceFactory::BuildServiceInstanceFor( |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [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 { | ||||
[email protected] | da762a8 | 2013-12-07 03:45:58 | [diff] [blame] | 57 | // Redirected in incognito. |
58 | return extensions::ExtensionsBrowserClient::Get()-> | ||||
59 | GetOriginalContext(context); | ||||
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 60 | } |
61 | |||||
62 | } // namespace apps |