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 "extensions/browser/declarative_user_script_manager_factory.h"
7 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "extensions/browser/declarative_user_script_manager.h"
9 #include "extensions/browser/extension_registry_factory.h"
10 #include "extensions/browser/extensions_browser_client.h"
12 using content::BrowserContext
;
14 namespace extensions
{
17 DeclarativeUserScriptManager
*
18 DeclarativeUserScriptManagerFactory::GetForBrowserContext(
19 BrowserContext
* context
) {
20 return static_cast<DeclarativeUserScriptManager
*>(
21 GetInstance()->GetServiceForBrowserContext(context
, true));
25 DeclarativeUserScriptManagerFactory
*
26 DeclarativeUserScriptManagerFactory::GetInstance() {
27 return base::Singleton
<DeclarativeUserScriptManagerFactory
>::get();
30 DeclarativeUserScriptManagerFactory::DeclarativeUserScriptManagerFactory()
31 : BrowserContextKeyedServiceFactory(
32 "DeclarativeUserScriptManager",
33 BrowserContextDependencyManager::GetInstance()) {
34 DependsOn(ExtensionRegistryFactory::GetInstance());
37 DeclarativeUserScriptManagerFactory::~DeclarativeUserScriptManagerFactory() {
40 KeyedService
* DeclarativeUserScriptManagerFactory::BuildServiceInstanceFor(
41 BrowserContext
* context
) const {
42 return new DeclarativeUserScriptManager(context
);
45 BrowserContext
* DeclarativeUserScriptManagerFactory::GetBrowserContextToUse(
46 BrowserContext
* context
) const {
47 // Redirected in incognito.
48 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
51 } // namespace extensions