OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" | 5 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/file_system_provider/service.h" | 7 #include "chrome/browser/chromeos/file_system_provider/service.h" |
8 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
9 #include "extensions/browser/extension_registry.h" | 9 #include "extensions/browser/extension_registry.h" |
10 #include "extensions/browser/extension_registry_factory.h" | 10 #include "extensions/browser/extension_registry_factory.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 namespace file_system_provider { | 13 namespace file_system_provider { |
14 | 14 |
15 // static | 15 // static |
16 Service* ServiceFactory::Get(content::BrowserContext* context) { | 16 Service* ServiceFactory::Get(content::BrowserContext* context) { |
17 return static_cast<Service*>( | 17 return static_cast<Service*>( |
18 GetInstance()->GetServiceForBrowserContext(context, true)); | 18 GetInstance()->GetServiceForBrowserContext(context, true)); |
19 } | 19 } |
20 | 20 |
| 21 // static |
| 22 Service* ServiceFactory::FindExisting(content::BrowserContext* context) { |
| 23 return static_cast<Service*>( |
| 24 GetInstance()->GetServiceForBrowserContext(context, false)); |
| 25 } |
| 26 |
21 ServiceFactory* ServiceFactory::GetInstance() { | 27 ServiceFactory* ServiceFactory::GetInstance() { |
22 return Singleton<ServiceFactory>::get(); | 28 return Singleton<ServiceFactory>::get(); |
23 } | 29 } |
24 | 30 |
25 ServiceFactory::ServiceFactory() | 31 ServiceFactory::ServiceFactory() |
26 : BrowserContextKeyedServiceFactory( | 32 : BrowserContextKeyedServiceFactory( |
27 "Service", | 33 "Service", |
28 BrowserContextDependencyManager::GetInstance()) { | 34 BrowserContextDependencyManager::GetInstance()) { |
29 DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); | 35 DependsOn(extensions::ExtensionRegistryFactory::GetInstance()); |
30 } | 36 } |
31 | 37 |
32 ServiceFactory::~ServiceFactory() {} | 38 ServiceFactory::~ServiceFactory() {} |
33 | 39 |
34 KeyedService* ServiceFactory::BuildServiceInstanceFor( | 40 KeyedService* ServiceFactory::BuildServiceInstanceFor( |
35 content::BrowserContext* profile) const { | 41 content::BrowserContext* profile) const { |
36 return new Service( | 42 return new Service( |
37 Profile::FromBrowserContext(profile), | 43 Profile::FromBrowserContext(profile), |
38 extensions::ExtensionRegistry::Get(Profile::FromBrowserContext(profile))); | 44 extensions::ExtensionRegistry::Get(Profile::FromBrowserContext(profile))); |
39 } | 45 } |
40 | 46 |
41 bool ServiceFactory::ServiceIsCreatedWithBrowserContext() const { return true; } | 47 bool ServiceFactory::ServiceIsCreatedWithBrowserContext() const { return true; } |
42 | 48 |
43 } // namespace file_system_provider | 49 } // namespace file_system_provider |
44 } // namespace chromeos | 50 } // namespace chromeos |
OLD | NEW |