From be627568b23f6178184669b67b9399dbd354c50d Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 5 Mar 2021 16:39:01 -0800 Subject: [PATCH] refactor: blink::MenuItem::Type was moved to mojom Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2071443 --- .../gin_converters/content_converter.cc | 55 ------------------- .../common/gin_converters/content_converter.h | 1 + 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/shell/common/gin_converters/content_converter.cc b/shell/common/gin_converters/content_converter.cc index 4b308f4fb3d9..ac68e60250f5 100644 --- a/shell/common/gin_converters/content_converter.cc +++ b/shell/common/gin_converters/content_converter.cc @@ -21,61 +21,6 @@ #include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/keycodes/keyboard_code_conversion.h" -namespace { - -void ExecuteCommand(content::WebContents* web_contents, - int action, - const GURL& link_followed) { - web_contents->ExecuteCustomContextMenuCommand(action, link_followed); -} - -// Forward declaration for nested recursive call. -v8::Local MenuToV8(v8::Isolate* isolate, - content::WebContents* web_contents, - const GURL& link_followed, - const std::vector& menu); - -v8::Local MenuItemToV8(v8::Isolate* isolate, - content::WebContents* web_contents, - const GURL& link_followed, - const blink::MenuItem& item) { - gin_helper::Dictionary v8_item = gin::Dictionary::CreateEmpty(isolate); - switch (item.type) { - case blink::MenuItem::CHECKABLE_OPTION: - case blink::MenuItem::GROUP: - v8_item.Set("checked", item.checked); - FALLTHROUGH; - case blink::MenuItem::OPTION: - case blink::MenuItem::SUBMENU: - v8_item.Set("label", item.label); - v8_item.Set("enabled", item.enabled); - FALLTHROUGH; - default: - v8_item.Set("type", item.type); - } - if (item.type == blink::MenuItem::SUBMENU) - v8_item.Set("submenu", - MenuToV8(isolate, web_contents, link_followed, item.submenu)); - else if (item.action > 0) - v8_item.Set("click", base::BindRepeating(ExecuteCommand, web_contents, - item.action, link_followed)); - return v8_item.GetHandle(); -} - -v8::Local MenuToV8(v8::Isolate* isolate, - content::WebContents* web_contents, - const GURL& link_followed, - const std::vector& menu) { - std::vector> v8_menu; - v8_menu.reserve(menu.size()); - for (const auto& menu_item : menu) - v8_menu.push_back( - MenuItemToV8(isolate, web_contents, link_followed, menu_item)); - return gin::ConvertToV8(isolate, v8_menu); -} - -} // namespace - namespace gin { template <> diff --git a/shell/common/gin_converters/content_converter.h b/shell/common/gin_converters/content_converter.h index 9ec846004d98..61f846c987f8 100644 --- a/shell/common/gin_converters/content_converter.h +++ b/shell/common/gin_converters/content_converter.h @@ -11,6 +11,7 @@ #include "content/public/common/referrer.h" #include "content/public/common/stop_find_action.h" #include "gin/converter.h" +#include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h" #include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" namespace content {