Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: chrome/browser/extensions/menu_manager_factory.cc

Issue 359493005: Extend contextMenus API to support browser/page actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fixes Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/menu_manager_factory.h" 5 #include "chrome/browser/extensions/menu_manager_factory.h"
6 6
7 #include "chrome/browser/extensions/menu_manager.h" 7 #include "chrome/browser/extensions/menu_manager.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h" 9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "extensions/browser/extension_system.h" 10 #include "extensions/browser/extension_system.h"
11 #include "extensions/browser/extension_system_provider.h" 11 #include "extensions/browser/extension_system_provider.h"
12 #include "extensions/browser/extensions_browser_client.h" 12 #include "extensions/browser/extensions_browser_client.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 // static 16 // static
17 MenuManager* MenuManagerFactory::GetForProfile( 17 MenuManager* MenuManagerFactory::GetForProfile(
18 Profile* profile) { 18 Profile* profile) {
19 return static_cast<MenuManager*>( 19 return static_cast<MenuManager*>(
20 GetInstance()->GetServiceForBrowserContext(profile, true)); 20 GetInstance()->GetServiceForBrowserContext(profile, true));
21 } 21 }
22 22
23 // static 23 // static
24 MenuManagerFactory* MenuManagerFactory::GetInstance() { 24 MenuManagerFactory* MenuManagerFactory::GetInstance() {
25 return Singleton<MenuManagerFactory>::get(); 25 return Singleton<MenuManagerFactory>::get();
26 } 26 }
27 27
28 // static
29 KeyedService* MenuManagerFactory::BuildInstanceFor(
Devlin 2014/07/24 21:51:28 If you're gonna do this, why not just make BuildSe
gpdavis 2014/07/28 21:08:22 BuildServiceInstanceFor is an overridden non-stati
Yoyo Zhou 2014/07/28 23:23:25 We have presubmits that warn about the use of meth
30 content::BrowserContext* context) {
31 Profile* profile = Profile::FromBrowserContext(context);
32 return new MenuManager(profile, ExtensionSystem::Get(profile)->state_store());
33 }
34
28 MenuManagerFactory::MenuManagerFactory() 35 MenuManagerFactory::MenuManagerFactory()
29 : BrowserContextKeyedServiceFactory( 36 : BrowserContextKeyedServiceFactory(
30 "MenuManager", 37 "MenuManager",
31 BrowserContextDependencyManager::GetInstance()) { 38 BrowserContextDependencyManager::GetInstance()) {
32 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 39 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
33 } 40 }
34 41
35 MenuManagerFactory::~MenuManagerFactory() {} 42 MenuManagerFactory::~MenuManagerFactory() {}
36 43
37 KeyedService* MenuManagerFactory::BuildServiceInstanceFor( 44 KeyedService* MenuManagerFactory::BuildServiceInstanceFor(
38 content::BrowserContext* context) const { 45 content::BrowserContext* context) const {
39 Profile* profile = Profile::FromBrowserContext(context); 46 return BuildInstanceFor(context);
40 return new MenuManager(
41 profile,
42 ExtensionSystem::Get(profile)->state_store());
43 } 47 }
44 48
45 content::BrowserContext* MenuManagerFactory::GetBrowserContextToUse( 49 content::BrowserContext* MenuManagerFactory::GetBrowserContextToUse(
46 content::BrowserContext* context) const { 50 content::BrowserContext* context) const {
47 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); 51 return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
48 } 52 }
49 53
50 bool MenuManagerFactory::ServiceIsCreatedWithBrowserContext() const { 54 bool MenuManagerFactory::ServiceIsCreatedWithBrowserContext() const {
51 return true; 55 return true;
52 } 56 }
53 57
54 bool MenuManagerFactory::ServiceIsNULLWhileTesting() const { 58 bool MenuManagerFactory::ServiceIsNULLWhileTesting() const {
55 return true; 59 return true;
56 } 60 }
57 61
58 } // namespace extensions 62 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698