1 // Copyright 2014 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/chromeos/platform_keys/platform_keys_service_factory.h" 6 7 #include "base/logging.h" 8 #include "base/memory/singleton.h" 9 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" 10 #include "chrome/browser/extensions/extension_system_factory.h" 11 #include "chrome/browser/profiles/incognito_helpers.h" 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" 13 14 namespace chromeos { 15 16 // static GetForBrowserContext(content::BrowserContext * context)17PlatformKeysService* PlatformKeysServiceFactory::GetForBrowserContext( 18 content::BrowserContext* context) { 19 return static_cast<PlatformKeysService*>( 20 GetInstance()->GetServiceForBrowserContext(context, true)); 21 } 22 23 // static GetInstance()24PlatformKeysServiceFactory* PlatformKeysServiceFactory::GetInstance() { 25 return Singleton<PlatformKeysServiceFactory>::get(); 26 } 27 PlatformKeysServiceFactory()28PlatformKeysServiceFactory::PlatformKeysServiceFactory() 29 : BrowserContextKeyedServiceFactory( 30 "PlatformKeysService", 31 BrowserContextDependencyManager::GetInstance()) { 32 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); 33 } 34 ~PlatformKeysServiceFactory()35PlatformKeysServiceFactory::~PlatformKeysServiceFactory() { 36 } 37 GetBrowserContextToUse(content::BrowserContext * context) const38content::BrowserContext* PlatformKeysServiceFactory::GetBrowserContextToUse( 39 content::BrowserContext* context) const { 40 return chrome::GetBrowserContextRedirectedInIncognito(context); 41 } 42 BuildServiceInstanceFor(content::BrowserContext * context) const43KeyedService* PlatformKeysServiceFactory::BuildServiceInstanceFor( 44 content::BrowserContext* context) const { 45 extensions::StateStore* store = 46 extensions::ExtensionSystem::Get(context)->state_store(); 47 DCHECK(store); 48 return new PlatformKeysService(context, store); 49 } 50 51 } // namespace chromeos 52