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/file_system_provider/service_factory.h" 6 7 #include "chrome/browser/chromeos/file_system_provider/service.h" 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" 9 #include "extensions/browser/extension_registry.h" 10 #include "extensions/browser/extension_registry_factory.h" 11 12 namespace chromeos { 13 namespace file_system_provider { 14 15 // static 16 Service* ServiceFactory::Get(content::BrowserContext* context) { 17 return static_cast<Service*>( 18 GetInstance()->GetServiceForBrowserContext(context, true)); 19 } 20 21 // static 22 Service* ServiceFactory::FindExisting(content::BrowserContext* context) { 23 return static_cast<Service*>( 24 GetInstance()->GetServiceForBrowserContext(context, false)); 25 } 26 27 ServiceFactory* ServiceFactory::GetInstance() { 28 return Singleton<ServiceFactory>::get(); 29 } 30 31 ServiceFactory::ServiceFactory() 32 : BrowserContextKeyedServiceFactory( 33 "Service", 34 BrowserContextDependencyManager::GetInstance()) { 35 DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); 36 } 37 38 ServiceFactory::~ServiceFactory() {} 39 40 KeyedService* ServiceFactory::BuildServiceInstanceFor( 41 content::BrowserContext* profile) const { 42 return new Service( 43 Profile::FromBrowserContext(profile), 44 extensions::ExtensionRegistry::Get(Profile::FromBrowserContext(profile))); 45 } 46 47 bool ServiceFactory::ServiceIsCreatedWithBrowserContext() const { return true; } 48 49 } // namespace file_system_provider 50 } // namespace chromeos 51