blob: 94eac78b68ede3ab86c6faac506e1017bf670ea5 [file] [log] [blame]
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01001// 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)868fa2f2013-06-11 10:57:03 +01008#include "chrome/browser/profiles/profile.h"
Torne (Richard Coles)a1401312014-03-18 10:20:56 +00009#include "components/keyed_service/content/browser_context_dependency_manager.h"
Primiano Tucci1320f922014-09-30 14:45:55 +010010#include "extensions/browser/app_window/app_window_registry.h"
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000011#include "extensions/browser/extension_prefs_factory.h"
Primiano Tucci1320f922014-09-30 14:45:55 +010012#include "extensions/browser/extension_registry_factory.h"
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000013#include "extensions/browser/extension_system_provider.h"
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +000014#include "extensions/browser/extensions_browser_client.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010015
16namespace apps {
17
18// static
19AppLoadService* AppLoadServiceFactory::GetForProfile(Profile* profile) {
20 return static_cast<AppLoadService*>(
21 GetInstance()->GetServiceForBrowserContext(profile, true));
22}
23
24AppLoadServiceFactory* AppLoadServiceFactory::GetInstance() {
25 return Singleton<AppLoadServiceFactory>::get();
26}
27
28AppLoadServiceFactory::AppLoadServiceFactory()
29 : BrowserContextKeyedServiceFactory(
30 "AppLoadService",
31 BrowserContextDependencyManager::GetInstance()) {
Primiano Tucci1320f922014-09-30 14:45:55 +010032 DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
33 DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
34 DependsOn(extensions::ExtensionRegistryFactory::GetInstance());
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000035 DependsOn(
36 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010037}
38
39AppLoadServiceFactory::~AppLoadServiceFactory() {
40}
41
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000042KeyedService* AppLoadServiceFactory::BuildServiceInstanceFor(
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010043 content::BrowserContext* profile) const {
44 return new AppLoadService(static_cast<Profile*>(profile));
45}
46
47bool AppLoadServiceFactory::ServiceIsNULLWhileTesting() const {
48 return false;
49}
50
51bool AppLoadServiceFactory::ServiceIsCreatedWithBrowserContext() const {
52 return true;
53}
54
55content::BrowserContext* AppLoadServiceFactory::GetBrowserContextToUse(
56 content::BrowserContext* context) const {
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +000057 // Redirected in incognito.
58 return extensions::ExtensionsBrowserClient::Get()->
59 GetOriginalContext(context);
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010060}
61
62} // namespace apps