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. 4 5 #include "chrome/browser/extensions/menu_manager_factory.h" 6 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" 13 14 namespace extensions { 15 16 // static GetForProfile(Profile * profile)17MenuManager* MenuManagerFactory::GetForProfile( 18 Profile* profile) { 19 return static_cast<MenuManager*>( 20 GetInstance()->GetServiceForBrowserContext(profile, true)); 21 } 22 23 // static GetInstance()24MenuManagerFactory* MenuManagerFactory::GetInstance() { 25 return Singleton<MenuManagerFactory>::get(); 26 } 27 MenuManagerFactory()28MenuManagerFactory::MenuManagerFactory() 29 : BrowserContextKeyedServiceFactory( 30 "MenuManager", 31 BrowserContextDependencyManager::GetInstance()) { 32 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 33 } 34 ~MenuManagerFactory()35MenuManagerFactory::~MenuManagerFactory() {} 36 BuildServiceInstanceFor(content::BrowserContext * context) const37KeyedService* MenuManagerFactory::BuildServiceInstanceFor( 38 content::BrowserContext* context) const { 39 Profile* profile = Profile::FromBrowserContext(context); 40 return new MenuManager( 41 profile, 42 ExtensionSystem::Get(profile)->state_store()); 43 } 44 GetBrowserContextToUse(content::BrowserContext * context) const45content::BrowserContext* MenuManagerFactory::GetBrowserContextToUse( 46 content::BrowserContext* context) const { 47 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); 48 } 49 ServiceIsCreatedWithBrowserContext() const50bool MenuManagerFactory::ServiceIsCreatedWithBrowserContext() const { 51 return true; 52 } 53 ServiceIsNULLWhileTesting() const54bool MenuManagerFactory::ServiceIsNULLWhileTesting() const { 55 return true; 56 } 57 58 } // namespace extensions 59