refactor: blink::MenuItem::Type was moved to mojom
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2071443
This commit is contained in:
parent
59669e99cb
commit
be627568b2
2 changed files with 1 additions and 55 deletions
|
@ -21,61 +21,6 @@
|
||||||
#include "ui/events/keycodes/dom/keycode_converter.h"
|
#include "ui/events/keycodes/dom/keycode_converter.h"
|
||||||
#include "ui/events/keycodes/keyboard_code_conversion.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<v8::Value> MenuToV8(v8::Isolate* isolate,
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
const GURL& link_followed,
|
|
||||||
const std::vector<blink::MenuItem>& menu);
|
|
||||||
|
|
||||||
v8::Local<v8::Value> 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<v8::Value> MenuToV8(v8::Isolate* isolate,
|
|
||||||
content::WebContents* web_contents,
|
|
||||||
const GURL& link_followed,
|
|
||||||
const std::vector<blink::MenuItem>& menu) {
|
|
||||||
std::vector<v8::Local<v8::Value>> 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 {
|
namespace gin {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "content/public/common/referrer.h"
|
#include "content/public/common/referrer.h"
|
||||||
#include "content/public/common/stop_find_action.h"
|
#include "content/public/common/stop_find_action.h"
|
||||||
#include "gin/converter.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"
|
#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
|
|
Loading…
Reference in a new issue