| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/extensions/api/runtime/runtime_api_factory.h" | 5 #include "chrome/browser/extensions/api/runtime/runtime_api_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 7 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 8 #include "chrome/browser/extensions/extension_system_factory.h" | |
| 9 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 8 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 9 #include "extensions/browser/extension_system_provider.h" |
| 10 #include "extensions/browser/extensions_browser_client.h" | 10 #include "extensions/browser/extensions_browser_client.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 RuntimeAPI* RuntimeAPIFactory::GetForBrowserContext( | 15 RuntimeAPI* RuntimeAPIFactory::GetForBrowserContext( |
| 16 content::BrowserContext* context) { | 16 content::BrowserContext* context) { |
| 17 return static_cast<RuntimeAPI*>( | 17 return static_cast<RuntimeAPI*>( |
| 18 GetInstance()->GetServiceForBrowserContext(context, true)); | 18 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 RuntimeAPIFactory* RuntimeAPIFactory::GetInstance() { | 22 RuntimeAPIFactory* RuntimeAPIFactory::GetInstance() { |
| 23 return Singleton<RuntimeAPIFactory>::get(); | 23 return Singleton<RuntimeAPIFactory>::get(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 RuntimeAPIFactory::RuntimeAPIFactory() | 26 RuntimeAPIFactory::RuntimeAPIFactory() |
| 27 : BrowserContextKeyedServiceFactory( | 27 : BrowserContextKeyedServiceFactory( |
| 28 "RuntimeAPI", | 28 "RuntimeAPI", |
| 29 BrowserContextDependencyManager::GetInstance()) { | 29 BrowserContextDependencyManager::GetInstance()) { |
| 30 DependsOn(ExtensionSystemFactory::GetInstance()); | 30 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 RuntimeAPIFactory::~RuntimeAPIFactory() { | 33 RuntimeAPIFactory::~RuntimeAPIFactory() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 BrowserContextKeyedService* RuntimeAPIFactory::BuildServiceInstanceFor( | 36 BrowserContextKeyedService* RuntimeAPIFactory::BuildServiceInstanceFor( |
| 37 content::BrowserContext* context) const { | 37 content::BrowserContext* context) const { |
| 38 return new RuntimeAPI(context); | 38 return new RuntimeAPI(context); |
| 39 } | 39 } |
| 40 | 40 |
| 41 content::BrowserContext* RuntimeAPIFactory::GetBrowserContextToUse( | 41 content::BrowserContext* RuntimeAPIFactory::GetBrowserContextToUse( |
| 42 content::BrowserContext* context) const { | 42 content::BrowserContext* context) const { |
| 43 // Instance is shared between incognito and regular profiles. | 43 // Instance is shared between incognito and regular profiles. |
| 44 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | 44 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool RuntimeAPIFactory::ServiceIsCreatedWithBrowserContext() const { | 47 bool RuntimeAPIFactory::ServiceIsCreatedWithBrowserContext() const { |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool RuntimeAPIFactory::ServiceIsNULLWhileTesting() const { | 51 bool RuntimeAPIFactory::ServiceIsNULLWhileTesting() const { |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace extensions | 55 } // namespace extensions |
| OLD | NEW |