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::GetForBrowserContext(
18 content::BrowserContext
* context
) {
19 return static_cast<MenuManager
*>(
20 GetInstance()->GetServiceForBrowserContext(context
, true));
24 MenuManagerFactory
* MenuManagerFactory::GetInstance() {
25 return Singleton
<MenuManagerFactory
>::get();
29 scoped_ptr
<KeyedService
> MenuManagerFactory::BuildServiceInstanceForTesting(
30 content::BrowserContext
* context
) {
31 return make_scoped_ptr(GetInstance()->BuildServiceInstanceFor(context
));
34 MenuManagerFactory::MenuManagerFactory()
35 : BrowserContextKeyedServiceFactory(
37 BrowserContextDependencyManager::GetInstance()) {
38 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
41 MenuManagerFactory::~MenuManagerFactory() {}
43 KeyedService
* MenuManagerFactory::BuildServiceInstanceFor(
44 content::BrowserContext
* context
) const {
45 Profile
* profile
= Profile::FromBrowserContext(context
);
46 return new MenuManager(profile
, ExtensionSystem::Get(profile
)->state_store());
49 content::BrowserContext
* MenuManagerFactory::GetBrowserContextToUse(
50 content::BrowserContext
* context
) const {
51 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
54 bool MenuManagerFactory::ServiceIsCreatedWithBrowserContext() const {
58 bool MenuManagerFactory::ServiceIsNULLWhileTesting() const {
62 } // namespace extensions