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

Unified 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: Rebase Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/context_menus/context_menus_api_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h
diff --git a/chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h b/chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h
index 773bd6249014a07855af73cdd2f518564e0e2e9c..bcd3a4bb2a5b4edc4269a1834afdff4dff5391e2 100644
--- a/chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h
+++ b/chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h
@@ -38,6 +38,7 @@ scoped_ptr<extensions::MenuItem::Id> GetParentId(
} // namespace
+extern const char kActionNotAllowedError[];
extern const char kCannotFindItemError[];
extern const char kCheckedError[];
extern const char kDuplicateIDError[];
@@ -89,6 +90,14 @@ MenuItem::ContextList GetContexts(const PropertyWithEnumT& property) {
// Not available for <webview>.
contexts.Add(extensions::MenuItem::LAUNCHER);
break;
+ case PropertyWithEnumT::CONTEXTS_TYPE_BROWSER_ACTION:
+ // Not available for <webview>.
+ contexts.Add(extensions::MenuItem::BROWSER_ACTION);
+ break;
+ case PropertyWithEnumT::CONTEXTS_TYPE_PAGE_ACTION:
+ // Not available for <webview>.
+ contexts.Add(extensions::MenuItem::PAGE_ACTION);
+ break;
case PropertyWithEnumT::CONTEXTS_TYPE_NONE:
NOTREACHED();
}
@@ -151,6 +160,15 @@ bool CreateMenuItem(const PropertyWithEnumT& create_properties,
}
}
+ if (contexts.Contains(MenuItem::BROWSER_ACTION) ||
+ contexts.Contains(MenuItem::PAGE_ACTION)) {
+ // Action items are not allowed for <webview>.
+ if (!extension->is_extension() || is_webview) {
+ *error = kActionNotAllowedError;
+ return false;
+ }
+ }
+
// Title.
std::string title;
if (create_properties.title.get())
« no previous file with comments | « no previous file | chrome/browser/extensions/api/context_menus/context_menus_api_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698