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

Side by Side Diff: chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h

Issue 359493005: Extend contextMenus API to support browser/page actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments, naming, small changes 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Definition of helper functions for the ContextMenus API. 5 // Definition of helper functions for the ContextMenus API.
6 6
7 #ifndef CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_HELPERS_H_ 7 #ifndef CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_HELPERS_H_
8 #define CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_HELPERS_H_ 8 #define CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_HELPERS_H_
9 9
10 #include "chrome/browser/extensions/menu_manager.h" 10 #include "chrome/browser/extensions/menu_manager.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 case PropertyWithEnumT::CONTEXTS_TYPE_VIDEO: 79 case PropertyWithEnumT::CONTEXTS_TYPE_VIDEO:
80 contexts.Add(extensions::MenuItem::VIDEO); 80 contexts.Add(extensions::MenuItem::VIDEO);
81 break; 81 break;
82 case PropertyWithEnumT::CONTEXTS_TYPE_AUDIO: 82 case PropertyWithEnumT::CONTEXTS_TYPE_AUDIO:
83 contexts.Add(extensions::MenuItem::AUDIO); 83 contexts.Add(extensions::MenuItem::AUDIO);
84 break; 84 break;
85 case PropertyWithEnumT::CONTEXTS_TYPE_FRAME: 85 case PropertyWithEnumT::CONTEXTS_TYPE_FRAME:
86 contexts.Add(extensions::MenuItem::FRAME); 86 contexts.Add(extensions::MenuItem::FRAME);
87 break; 87 break;
88 case PropertyWithEnumT::CONTEXTS_TYPE_LAUNCHER: 88 case PropertyWithEnumT::CONTEXTS_TYPE_LAUNCHER:
89 // Not available for <webview>. 89 // Not available for <webview>.
gpdavis 2014/07/22 18:52:53 Should I add this comment in for the browser and p
Yoyo Zhou 2014/07/23 23:37:21 Yes, these are also not available for webview.
gpdavis 2014/07/23 23:57:58 Done.
90 contexts.Add(extensions::MenuItem::LAUNCHER); 90 contexts.Add(extensions::MenuItem::LAUNCHER);
91 break; 91 break;
92 case PropertyWithEnumT::CONTEXTS_TYPE_BROWSER_ACTION:
93 contexts.Add(extensions::MenuItem::BROWSER_ACTION);
94 break;
95 case PropertyWithEnumT::CONTEXTS_TYPE_PAGE_ACTION:
96 contexts.Add(extensions::MenuItem::PAGE_ACTION);
97 break;
92 case PropertyWithEnumT::CONTEXTS_TYPE_NONE: 98 case PropertyWithEnumT::CONTEXTS_TYPE_NONE:
93 NOTREACHED(); 99 NOTREACHED();
94 } 100 }
95 } 101 }
96 return contexts; 102 return contexts;
97 } 103 }
98 104
99 template<typename PropertyWithEnumT> 105 template<typename PropertyWithEnumT>
100 MenuItem::Type GetType(const PropertyWithEnumT& property, 106 MenuItem::Type GetType(const PropertyWithEnumT& property,
101 MenuItem::Type default_type) { 107 MenuItem::Type default_type) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return false; 142 return false;
137 } 143 }
138 144
139 // Contexts. 145 // Contexts.
140 MenuItem::ContextList contexts; 146 MenuItem::ContextList contexts;
141 if (create_properties.contexts.get()) 147 if (create_properties.contexts.get())
142 contexts = GetContexts(create_properties); 148 contexts = GetContexts(create_properties);
143 else 149 else
144 contexts.Add(MenuItem::PAGE); 150 contexts.Add(MenuItem::PAGE);
145 151
146 if (contexts.Contains(MenuItem::LAUNCHER)) { 152 if (contexts.Contains(MenuItem::LAUNCHER)) {
gpdavis 2014/07/23 23:09:52 @yoyo, Since you pointed out the bit about webvie
Yoyo Zhou 2014/07/23 23:37:21 Likewise, yes, this is where you should be returni
gpdavis 2014/07/23 23:57:58 Done.
147 // Launcher item is not allowed for <webview>. 153 // Launcher item is not allowed for <webview>.
148 if (!extension->is_platform_app() || is_webview) { 154 if (!extension->is_platform_app() || is_webview) {
149 *error = kLauncherNotAllowedError; 155 *error = kLauncherNotAllowedError;
150 return false; 156 return false;
151 } 157 }
152 } 158 }
153 159
154 // Title. 160 // Title.
155 std::string title; 161 std::string title;
156 if (create_properties.title.get()) 162 if (create_properties.title.get())
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return false; 308 return false;
303 309
304 menu_manager->WriteToStorage(extension, item_id.extension_key); 310 menu_manager->WriteToStorage(extension, item_id.extension_key);
305 return true; 311 return true;
306 } 312 }
307 313
308 } // namespace context_menus_api_helpers 314 } // namespace context_menus_api_helpers
309 } // namespace extensions 315 } // namespace extensions
310 316
311 #endif // CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_HELPERS _H_ 317 #endif // CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_HELPERS _H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/context_menu_matcher.h » ('j') | chrome/common/extensions/api/context_menus.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698