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