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.
5 #include "apps/app_load_service_factory.h"
7 #include "apps/app_load_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "extensions/browser/app_window/app_window_registry.h"
11 #include "extensions/browser/extension_prefs_factory.h"
12 #include "extensions/browser/extension_registry_factory.h"
13 #include "extensions/browser/extension_system_provider.h"
14 #include "extensions/browser/extensions_browser_client.h"
19 AppLoadService
* AppLoadServiceFactory::GetForProfile(Profile
* profile
) {
20 return static_cast<AppLoadService
*>(
21 GetInstance()->GetServiceForBrowserContext(profile
, true));
24 AppLoadServiceFactory
* AppLoadServiceFactory::GetInstance() {
25 return Singleton
<AppLoadServiceFactory
>::get();
28 AppLoadServiceFactory::AppLoadServiceFactory()
29 : BrowserContextKeyedServiceFactory(
31 BrowserContextDependencyManager::GetInstance()) {
32 DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
33 DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
34 DependsOn(extensions::ExtensionRegistryFactory::GetInstance());
36 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
39 AppLoadServiceFactory::~AppLoadServiceFactory() {
42 KeyedService
* AppLoadServiceFactory::BuildServiceInstanceFor(
43 content::BrowserContext
* profile
) const {
44 return new AppLoadService(static_cast<Profile
*>(profile
));
47 bool AppLoadServiceFactory::ServiceIsNULLWhileTesting() const {
51 bool AppLoadServiceFactory::ServiceIsCreatedWithBrowserContext() const {
55 content::BrowserContext
* AppLoadServiceFactory::GetBrowserContextToUse(
56 content::BrowserContext
* context
) const {
57 // Redirected in incognito.
58 return extensions::ExtensionsBrowserClient::Get()->
59 GetOriginalContext(context
);