diff options
author | juncai <juncai@chromium.org> | 2015-05-18 14:00:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-18 21:00:24 +0000 |
commit | 6b9c265cac013bab0acc7b7dd7c11e6a1e5e71f8 (patch) | |
tree | 465f31e2d0408e5d9f73727f6756bcce634e1c34 /extensions/browser/declarative_user_script_manager_factory.cc | |
parent | ad6fc44cec8b05ff4ef34f9d38e578b08673646e (diff) | |
download | chromium_src-6b9c265cac013bab0acc7b7dd7c11e6a1e5e71f8.zip chromium_src-6b9c265cac013bab0acc7b7dd7c11e6a1e5e71f8.tar.gz chromium_src-6b9c265cac013bab0acc7b7dd7c11e6a1e5e71f8.tar.bz2 |
Extract DeclarativeUserScriptManager from ExtensionSystem.
This patch removes declarative_user_script_manager accessor from ExtensionSystem.
DeclarativeUserScriptManager is now a browser context keyed service.
Review URL: https://codereview.chromium.org/1132113008
Cr-Commit-Position: refs/heads/master@{#330418}
Diffstat (limited to 'extensions/browser/declarative_user_script_manager_factory.cc')
-rw-r--r-- | extensions/browser/declarative_user_script_manager_factory.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/extensions/browser/declarative_user_script_manager_factory.cc b/extensions/browser/declarative_user_script_manager_factory.cc new file mode 100644 index 0000000..cc19c78 --- /dev/null +++ b/extensions/browser/declarative_user_script_manager_factory.cc @@ -0,0 +1,51 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "extensions/browser/declarative_user_script_manager_factory.h" + +#include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "extensions/browser/declarative_user_script_manager.h" +#include "extensions/browser/extension_registry_factory.h" +#include "extensions/browser/extensions_browser_client.h" + +using content::BrowserContext; + +namespace extensions { + +// static +DeclarativeUserScriptManager* +DeclarativeUserScriptManagerFactory::GetForBrowserContext( + BrowserContext* context) { + return static_cast<DeclarativeUserScriptManager*>( + GetInstance()->GetServiceForBrowserContext(context, true)); +} + +// static +DeclarativeUserScriptManagerFactory* +DeclarativeUserScriptManagerFactory::GetInstance() { + return Singleton<DeclarativeUserScriptManagerFactory>::get(); +} + +DeclarativeUserScriptManagerFactory::DeclarativeUserScriptManagerFactory() + : BrowserContextKeyedServiceFactory( + "DeclarativeUserScriptManager", + BrowserContextDependencyManager::GetInstance()) { + DependsOn(ExtensionRegistryFactory::GetInstance()); +} + +DeclarativeUserScriptManagerFactory::~DeclarativeUserScriptManagerFactory() { +} + +KeyedService* DeclarativeUserScriptManagerFactory::BuildServiceInstanceFor( + BrowserContext* context) const { + return new DeclarativeUserScriptManager(context); +} + +BrowserContext* DeclarativeUserScriptManagerFactory::GetBrowserContextToUse( + BrowserContext* context) const { + // Redirected in incognito. + return ExtensionsBrowserClient::Get()->GetOriginalContext(context); +} + +} // namespace extensions |