| 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 "extensions/browser/extension_registry_factory.h" | 5 #include "extensions/browser/extension_registry_factory.h" |
| 6 | 6 |
| 7 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 7 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 8 #include "extensions/browser/extension_registry.h" | 8 #include "extensions/browser/extension_registry.h" |
| 9 #include "extensions/browser/extensions_browser_client.h" | 9 #include "extensions/browser/extensions_browser_client.h" |
| 10 | 10 |
| 11 using content::BrowserContext; | 11 using content::BrowserContext; |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 // static | 15 // static |
| 16 ExtensionRegistry* ExtensionRegistryFactory::GetForBrowserContext( | 16 ExtensionRegistry* ExtensionRegistryFactory::GetForBrowserContext( |
| 17 BrowserContext* context) { | 17 BrowserContext* context) { |
| 18 return static_cast<ExtensionRegistry*>( | 18 return static_cast<ExtensionRegistry*>( |
| 19 GetInstance()->GetServiceForBrowserContext(context, true)); | 19 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 ExtensionRegistryFactory* ExtensionRegistryFactory::GetInstance() { | 23 ExtensionRegistryFactory* ExtensionRegistryFactory::GetInstance() { |
| 24 return Singleton<ExtensionRegistryFactory>::get(); | 24 return base::Singleton<ExtensionRegistryFactory>::get(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 ExtensionRegistryFactory::ExtensionRegistryFactory() | 27 ExtensionRegistryFactory::ExtensionRegistryFactory() |
| 28 : BrowserContextKeyedServiceFactory( | 28 : BrowserContextKeyedServiceFactory( |
| 29 "ExtensionRegistry", | 29 "ExtensionRegistry", |
| 30 BrowserContextDependencyManager::GetInstance()) { | 30 BrowserContextDependencyManager::GetInstance()) { |
| 31 // No dependencies on other services. | 31 // No dependencies on other services. |
| 32 } | 32 } |
| 33 | 33 |
| 34 ExtensionRegistryFactory::~ExtensionRegistryFactory() {} | 34 ExtensionRegistryFactory::~ExtensionRegistryFactory() {} |
| 35 | 35 |
| 36 KeyedService* ExtensionRegistryFactory::BuildServiceInstanceFor( | 36 KeyedService* ExtensionRegistryFactory::BuildServiceInstanceFor( |
| 37 content::BrowserContext* context) const { | 37 content::BrowserContext* context) const { |
| 38 return new ExtensionRegistry(context); | 38 return new ExtensionRegistry(context); |
| 39 } | 39 } |
| 40 | 40 |
| 41 BrowserContext* ExtensionRegistryFactory::GetBrowserContextToUse( | 41 BrowserContext* ExtensionRegistryFactory::GetBrowserContextToUse( |
| 42 BrowserContext* context) const { | 42 BrowserContext* context) const { |
| 43 // Redirected in incognito. | 43 // Redirected in incognito. |
| 44 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | 44 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace extensions | 47 } // namespace extensions |
| OLD | NEW |