1 // 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.
5 #include "chrome/browser/extensions/menu_manager_factory.h"
7 #include "chrome/browser/extensions/menu_manager.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "extensions/browser/extension_system.h"
11 #include "extensions/browser/extension_system_provider.h"
12 #include "extensions/browser/extensions_browser_client.h"
14 namespace extensions
{
17 MenuManager
* MenuManagerFactory::GetForProfile(
19 return static_cast<MenuManager
*>(
20 GetInstance()->GetServiceForBrowserContext(profile
, true));
24 MenuManagerFactory
* MenuManagerFactory::GetInstance() {
25 return Singleton
<MenuManagerFactory
>::get();
28 MenuManagerFactory::MenuManagerFactory()
29 : BrowserContextKeyedServiceFactory(
31 BrowserContextDependencyManager::GetInstance()) {
32 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
35 MenuManagerFactory::~MenuManagerFactory() {}
37 KeyedService
* MenuManagerFactory::BuildServiceInstanceFor(
38 content::BrowserContext
* context
) const {
39 Profile
* profile
= Profile::FromBrowserContext(context
);
40 return new MenuManager(
42 ExtensionSystem::Get(profile
)->state_store());
45 content::BrowserContext
* MenuManagerFactory::GetBrowserContextToUse(
46 content::BrowserContext
* context
) const {
47 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
50 bool MenuManagerFactory::ServiceIsCreatedWithBrowserContext() const {
54 bool MenuManagerFactory::ServiceIsNULLWhileTesting() const {
58 } // namespace extensions