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/keyed_service/content/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* GetForProfile(Profile * profile)17EphemeralAppServiceFactory::GetForProfile(Profile* profile) { 18 return static_cast<EphemeralAppService*>( 19 GetInstance()->GetServiceForBrowserContext(profile, true)); 20 } 21 22 // static GetInstance()23EphemeralAppServiceFactory* EphemeralAppServiceFactory::GetInstance() { 24 return Singleton<EphemeralAppServiceFactory>::get(); 25 } 26 EphemeralAppServiceFactory()27EphemeralAppServiceFactory::EphemeralAppServiceFactory() 28 : BrowserContextKeyedServiceFactory( 29 "EphemeralAppService", 30 BrowserContextDependencyManager::GetInstance()) { 31 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 32 } 33 ~EphemeralAppServiceFactory()34EphemeralAppServiceFactory::~EphemeralAppServiceFactory() { 35 } 36 BuildServiceInstanceFor(content::BrowserContext * context) const37KeyedService* EphemeralAppServiceFactory::BuildServiceInstanceFor( 38 content::BrowserContext* context) const { 39 return new EphemeralAppService(Profile::FromBrowserContext(context)); 40 } 41 GetBrowserContextToUse(content::BrowserContext * context) const42content::BrowserContext* EphemeralAppServiceFactory::GetBrowserContextToUse( 43 content::BrowserContext* context) const { 44 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); 45 } 46 ServiceIsCreatedWithBrowserContext() const47bool EphemeralAppServiceFactory::ServiceIsCreatedWithBrowserContext() const { 48 return true; 49 } 50 ServiceIsNULLWhileTesting() const51bool EphemeralAppServiceFactory::ServiceIsNULLWhileTesting() const { 52 return true; 53 } 54