1 // Copyright 2015 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.
5 #include "chrome/browser/extensions/error_console/error_console_factory.h"
7 #include "chrome/browser/extensions/error_console/error_console.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "extensions/browser/extension_registry_factory.h"
11 #include "extensions/browser/extensions_browser_client.h"
13 using content::BrowserContext
;
15 namespace extensions
{
18 ErrorConsole
* ErrorConsoleFactory::GetForBrowserContext(
19 BrowserContext
* context
) {
20 return static_cast<ErrorConsole
*>(
21 GetInstance()->GetServiceForBrowserContext(context
, true));
25 ErrorConsoleFactory
* ErrorConsoleFactory::GetInstance() {
26 return base::Singleton
<ErrorConsoleFactory
>::get();
29 ErrorConsoleFactory::ErrorConsoleFactory()
30 : BrowserContextKeyedServiceFactory(
32 BrowserContextDependencyManager::GetInstance()) {
33 DependsOn(ExtensionRegistryFactory::GetInstance());
36 ErrorConsoleFactory::~ErrorConsoleFactory() {
39 KeyedService
* ErrorConsoleFactory::BuildServiceInstanceFor(
40 BrowserContext
* context
) const {
41 return new ErrorConsole(Profile::FromBrowserContext(context
));
44 BrowserContext
* ErrorConsoleFactory::GetBrowserContextToUse(
45 BrowserContext
* context
) const {
46 // Redirected in incognito.
47 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
50 } // namespace extensions