зеркало из https://github.com/electron/electron.git
refactor: blink::MenuItem::Type was moved to mojom
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2071443
This commit is contained in:
Родитель
59669e99cb
Коммит
be627568b2
|
@ -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<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 {
|
||||
|
||||
template <>
|
||||
|
|
|
@ -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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче