reillyg | 22114a38 | 2014-11-03 16:47:57 | [diff] [blame] | 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 "extensions/browser/warning_service_factory.h" |
| 6 | |
| 7 | #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 8 | #include "extensions/browser/extension_registry_factory.h" |
| 9 | #include "extensions/browser/extensions_browser_client.h" |
| 10 | #include "extensions/browser/warning_service.h" |
| 11 | |
| 12 | using content::BrowserContext; |
| 13 | |
| 14 | namespace extensions { |
| 15 | |
| 16 | // static |
| 17 | WarningService* WarningServiceFactory::GetForBrowserContext( |
| 18 | BrowserContext* context) { |
| 19 | return static_cast<WarningService*>( |
| 20 | GetInstance()->GetServiceForBrowserContext(context, true)); |
| 21 | } |
| 22 | |
| 23 | // static |
| 24 | WarningServiceFactory* WarningServiceFactory::GetInstance() { |
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 25 | return base::Singleton<WarningServiceFactory>::get(); |
reillyg | 22114a38 | 2014-11-03 16:47:57 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | WarningServiceFactory::WarningServiceFactory() |
| 29 | : BrowserContextKeyedServiceFactory( |
| 30 | "WarningService", |
| 31 | BrowserContextDependencyManager::GetInstance()) { |
| 32 | DependsOn(ExtensionRegistryFactory::GetInstance()); |
| 33 | } |
| 34 | |
| 35 | WarningServiceFactory::~WarningServiceFactory() { |
| 36 | } |
| 37 | |
| 38 | KeyedService* WarningServiceFactory::BuildServiceInstanceFor( |
| 39 | BrowserContext* context) const { |
| 40 | return new WarningService(context); |
| 41 | } |
| 42 | |
| 43 | BrowserContext* WarningServiceFactory::GetBrowserContextToUse( |
| 44 | BrowserContext* context) const { |
| 45 | // Redirected in incognito. |
| 46 | return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 47 | } |
| 48 | |
| 49 | } // namespace extensions |