blob: 8a6d8aed0d55169088a470a7728371dd71f05f1a [file] [log] [blame]
[email protected]b673a5942013-11-14 11:14:191// Copyright 2013 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 "chrome/browser/extensions/menu_manager_factory.h"
6
dchengc963c7142016-04-08 03:55:227#include "base/memory/ptr_util.h"
[email protected]b673a5942013-11-14 11:14:198#include "chrome/browser/extensions/menu_manager.h"
[email protected]b673a5942013-11-14 11:14:199#include "chrome/browser/profiles/profile.h"
[email protected]b33f0b112014-03-13 17:05:3010#include "components/keyed_service/content/browser_context_dependency_manager.h"
[email protected]59b0e602014-01-30 00:41:2411#include "extensions/browser/extension_system.h"
[email protected]d46c0502014-02-14 13:33:3612#include "extensions/browser/extension_system_provider.h"
[email protected]175a74d2014-02-08 02:06:2013#include "extensions/browser/extensions_browser_client.h"
[email protected]b673a5942013-11-14 11:14:1914
15namespace extensions {
16
17// static
[email protected]f5fede02014-07-29 02:48:2118MenuManager* MenuManagerFactory::GetForBrowserContext(
19 content::BrowserContext* context) {
[email protected]b673a5942013-11-14 11:14:1920 return static_cast<MenuManager*>(
[email protected]f5fede02014-07-29 02:48:2121 GetInstance()->GetServiceForBrowserContext(context, true));
[email protected]b673a5942013-11-14 11:14:1922}
23
24// static
25MenuManagerFactory* MenuManagerFactory::GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2226 return base::Singleton<MenuManagerFactory>::get();
[email protected]b673a5942013-11-14 11:14:1927}
28
[email protected]69e1c12d2014-08-13 08:25:3429// static
dchengc963c7142016-04-08 03:55:2230std::unique_ptr<KeyedService>
31MenuManagerFactory::BuildServiceInstanceForTesting(
[email protected]69e1c12d2014-08-13 08:25:3432 content::BrowserContext* context) {
dchengc963c7142016-04-08 03:55:2233 return base::WrapUnique(GetInstance()->BuildServiceInstanceFor(context));
[email protected]69e1c12d2014-08-13 08:25:3434}
35
[email protected]b673a5942013-11-14 11:14:1936MenuManagerFactory::MenuManagerFactory()
37 : BrowserContextKeyedServiceFactory(
38 "MenuManager",
39 BrowserContextDependencyManager::GetInstance()) {
[email protected]d46c0502014-02-14 13:33:3640 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
[email protected]b673a5942013-11-14 11:14:1941}
42
43MenuManagerFactory::~MenuManagerFactory() {}
44
[email protected]b33f0b112014-03-13 17:05:3045KeyedService* MenuManagerFactory::BuildServiceInstanceFor(
46 content::BrowserContext* context) const {
[email protected]b673a5942013-11-14 11:14:1947 Profile* profile = Profile::FromBrowserContext(context);
[email protected]69e1c12d2014-08-13 08:25:3448 return new MenuManager(profile, ExtensionSystem::Get(profile)->state_store());
[email protected]b673a5942013-11-14 11:14:1949}
50
51content::BrowserContext* MenuManagerFactory::GetBrowserContextToUse(
52 content::BrowserContext* context) const {
[email protected]175a74d2014-02-08 02:06:2053 return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
[email protected]b673a5942013-11-14 11:14:1954}
55
56bool MenuManagerFactory::ServiceIsCreatedWithBrowserContext() const {
57 return true;
58}
59
60bool MenuManagerFactory::ServiceIsNULLWhileTesting() const {
61 return true;
62}
63
64} // namespace extensions