Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / apps / ephemeral_app_service_factory.cc
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 "chrome/browser/apps/ephemeral_app_service_factory.h"
6
7 #include "chrome/browser/apps/ephemeral_app_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
10 #include "extensions/browser/extension_system_provider.h"
11 #include "extensions/browser/extensions_browser_client.h"
12
13 using extensions::ExtensionsBrowserClient;
14
15 // static
16 EphemeralAppService*
17 EphemeralAppServiceFactory::GetForProfile(Profile* profile) {
18   return static_cast<EphemeralAppService*>(
19       GetInstance()->GetServiceForBrowserContext(profile, true));
20 }
21
22 // static
23 EphemeralAppServiceFactory* EphemeralAppServiceFactory::GetInstance() {
24   return Singleton<EphemeralAppServiceFactory>::get();
25 }
26
27 EphemeralAppServiceFactory::EphemeralAppServiceFactory()
28     : BrowserContextKeyedServiceFactory(
29           "EphemeralAppService",
30           BrowserContextDependencyManager::GetInstance()) {
31   DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
32 }
33
34 EphemeralAppServiceFactory::~EphemeralAppServiceFactory() {
35 }
36
37 BrowserContextKeyedService* EphemeralAppServiceFactory::BuildServiceInstanceFor(
38     content::BrowserContext* context) const {
39   return new EphemeralAppService(Profile::FromBrowserContext(context));
40 }
41
42 content::BrowserContext* EphemeralAppServiceFactory::GetBrowserContextToUse(
43     content::BrowserContext* context) const {
44   return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
45 }
46
47 bool EphemeralAppServiceFactory::ServiceIsCreatedWithBrowserContext() const {
48   return true;
49 }
50
51 bool EphemeralAppServiceFactory::ServiceIsNULLWhileTesting() const {
52   return true;
53 }