2015-10-28 12:13:06 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "shell/common/gin_converters/content_converter.h"
|
2015-10-28 12:13:06 +00:00
|
|
|
|
2015-12-17 17:27:56 +00:00
|
|
|
#include <string>
|
2015-11-02 15:28:45 +00:00
|
|
|
|
2020-03-14 20:54:14 +00:00
|
|
|
#include "content/public/browser/context_menu_params.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "content/public/browser/native_web_keyboard_event.h"
|
2015-11-02 15:28:45 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2020-02-04 20:19:40 +00:00
|
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/web_contents_permission_helper.h"
|
2019-10-31 07:56:00 +00:00
|
|
|
#include "shell/common/gin_converters/blink_converter.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "shell/common/gin_converters/callback_converter.h"
|
2021-09-21 23:52:49 +00:00
|
|
|
#include "shell/common/gin_converters/frame_converter.h"
|
2020-12-16 05:32:11 +00:00
|
|
|
#include "shell/common/gin_converters/gfx_converter.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "shell/common/gin_converters/gurl_converter.h"
|
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
2021-02-09 20:16:21 +00:00
|
|
|
#include "third_party/blink/public/common/context_menu_data/untrustworthy_context_menu_params.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "ui/events/keycodes/dom/keycode_converter.h"
|
|
|
|
#include "ui/events/keycodes/keyboard_code_conversion.h"
|
2016-10-09 23:30:38 +00:00
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
namespace gin {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct Converter<ui::MenuSourceType> {
|
|
|
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
|
|
|
const ui::MenuSourceType& in) {
|
|
|
|
switch (in) {
|
|
|
|
case ui::MENU_SOURCE_MOUSE:
|
|
|
|
return StringToV8(isolate, "mouse");
|
|
|
|
case ui::MENU_SOURCE_KEYBOARD:
|
|
|
|
return StringToV8(isolate, "keyboard");
|
|
|
|
case ui::MENU_SOURCE_TOUCH:
|
|
|
|
return StringToV8(isolate, "touch");
|
|
|
|
case ui::MENU_SOURCE_TOUCH_EDIT_MENU:
|
|
|
|
return StringToV8(isolate, "touchMenu");
|
2020-12-16 05:32:11 +00:00
|
|
|
case ui::MENU_SOURCE_LONG_PRESS:
|
|
|
|
return StringToV8(isolate, "longPress");
|
|
|
|
case ui::MENU_SOURCE_LONG_TAP:
|
|
|
|
return StringToV8(isolate, "longTap");
|
|
|
|
case ui::MENU_SOURCE_TOUCH_HANDLE:
|
|
|
|
return StringToV8(isolate, "touchHandle");
|
|
|
|
case ui::MENU_SOURCE_STYLUS:
|
|
|
|
return StringToV8(isolate, "stylus");
|
|
|
|
case ui::MENU_SOURCE_ADJUST_SELECTION:
|
|
|
|
return StringToV8(isolate, "adjustSelection");
|
|
|
|
case ui::MENU_SOURCE_ADJUST_SELECTION_RESET:
|
|
|
|
return StringToV8(isolate, "adjustSelectionReset");
|
2019-10-25 13:03:28 +00:00
|
|
|
default:
|
|
|
|
return StringToV8(isolate, "none");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-10-31 13:39:07 +00:00
|
|
|
|
2015-10-28 12:13:06 +00:00
|
|
|
// static
|
2021-03-05 23:36:52 +00:00
|
|
|
v8::Local<v8::Value> Converter<blink::mojom::MenuItem::Type>::ToV8(
|
2018-04-18 01:55:30 +00:00
|
|
|
v8::Isolate* isolate,
|
2021-03-05 23:36:52 +00:00
|
|
|
const blink::mojom::MenuItem::Type& val) {
|
2015-11-02 15:28:45 +00:00
|
|
|
switch (val) {
|
2021-03-05 23:36:52 +00:00
|
|
|
case blink::mojom::MenuItem::Type::kCheckableOption:
|
2015-11-02 15:28:45 +00:00
|
|
|
return StringToV8(isolate, "checkbox");
|
2021-03-05 23:36:52 +00:00
|
|
|
case blink::mojom::MenuItem::Type::kGroup:
|
2015-11-02 15:28:45 +00:00
|
|
|
return StringToV8(isolate, "radio");
|
2021-03-05 23:36:52 +00:00
|
|
|
case blink::mojom::MenuItem::Type::kSeparator:
|
2015-11-02 15:28:45 +00:00
|
|
|
return StringToV8(isolate, "separator");
|
2021-03-05 23:36:52 +00:00
|
|
|
case blink::mojom::MenuItem::Type::kSubMenu:
|
2015-11-02 15:28:45 +00:00
|
|
|
return StringToV8(isolate, "submenu");
|
2021-03-05 23:36:52 +00:00
|
|
|
case blink::mojom::MenuItem::Type::kOption:
|
2015-11-02 15:28:45 +00:00
|
|
|
default:
|
|
|
|
return StringToV8(isolate, "normal");
|
|
|
|
}
|
2015-10-28 12:21:56 +00:00
|
|
|
}
|
2015-10-28 12:13:06 +00:00
|
|
|
|
|
|
|
// static
|
2021-09-21 23:52:49 +00:00
|
|
|
v8::Local<v8::Value> Converter<ContextMenuParamsWithRenderFrameHost>::ToV8(
|
2018-04-18 01:55:30 +00:00
|
|
|
v8::Isolate* isolate,
|
2021-09-21 23:52:49 +00:00
|
|
|
const ContextMenuParamsWithRenderFrameHost& val) {
|
2015-11-02 15:28:45 +00:00
|
|
|
const auto& params = val.first;
|
2021-09-21 23:52:49 +00:00
|
|
|
content::RenderFrameHost* render_frame_host = val.second;
|
2019-10-25 13:03:28 +00:00
|
|
|
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
2021-10-04 18:00:25 +00:00
|
|
|
dict.SetGetter("frame", render_frame_host, v8::DontEnum);
|
2015-11-02 15:28:45 +00:00
|
|
|
dict.Set("x", params.x);
|
|
|
|
dict.Set("y", params.y);
|
2016-05-03 00:02:33 +00:00
|
|
|
dict.Set("linkURL", params.link_url);
|
|
|
|
dict.Set("linkText", params.link_text);
|
|
|
|
dict.Set("pageURL", params.page_url);
|
|
|
|
dict.Set("frameURL", params.frame_url);
|
|
|
|
dict.Set("srcURL", params.src_url);
|
|
|
|
dict.Set("mediaType", params.media_type);
|
2019-10-31 07:56:00 +00:00
|
|
|
dict.Set("mediaFlags", MediaFlagsToV8(isolate, params.media_flags));
|
2016-08-11 19:25:20 +00:00
|
|
|
bool has_image_contents =
|
2021-01-12 23:31:23 +00:00
|
|
|
(params.media_type == blink::mojom::ContextMenuDataMediaType::kImage) &&
|
2018-04-18 01:55:30 +00:00
|
|
|
params.has_image_contents;
|
2016-08-11 19:25:20 +00:00
|
|
|
dict.Set("hasImageContents", has_image_contents);
|
2016-05-03 00:02:33 +00:00
|
|
|
dict.Set("isEditable", params.is_editable);
|
2019-10-31 07:56:00 +00:00
|
|
|
dict.Set("editFlags", EditFlagsToV8(isolate, params.edit_flags));
|
2016-05-03 00:02:33 +00:00
|
|
|
dict.Set("selectionText", params.selection_text);
|
|
|
|
dict.Set("titleText", params.title_text);
|
2020-12-16 05:32:11 +00:00
|
|
|
dict.Set("altText", params.alt_text);
|
|
|
|
dict.Set("suggestedFilename", params.suggested_filename);
|
2016-05-03 00:02:33 +00:00
|
|
|
dict.Set("misspelledWord", params.misspelled_word);
|
2020-12-16 05:32:11 +00:00
|
|
|
dict.Set("selectionRect", params.selection_rect);
|
2019-10-31 20:11:51 +00:00
|
|
|
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
|
|
|
dict.Set("dictionarySuggestions", params.dictionary_suggestions);
|
2020-12-16 05:32:11 +00:00
|
|
|
dict.Set("spellcheckEnabled", params.spellcheck_enabled);
|
|
|
|
#else
|
|
|
|
dict.Set("spellcheckEnabled", false);
|
2019-10-31 20:11:51 +00:00
|
|
|
#endif
|
2016-05-03 00:02:33 +00:00
|
|
|
dict.Set("frameCharset", params.frame_charset);
|
2020-12-16 05:32:11 +00:00
|
|
|
dict.Set("referrerPolicy", params.referrer_policy);
|
2016-05-03 00:02:33 +00:00
|
|
|
dict.Set("inputFieldType", params.input_field_type);
|
2018-04-18 01:55:30 +00:00
|
|
|
dict.Set("menuSourceType", params.source_type);
|
2016-05-03 00:02:33 +00:00
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
return gin::ConvertToV8(isolate, dict);
|
2015-10-28 12:21:56 +00:00
|
|
|
}
|
2015-10-28 12:13:06 +00:00
|
|
|
|
2016-01-30 11:19:18 +00:00
|
|
|
// static
|
2016-05-23 01:59:39 +00:00
|
|
|
bool Converter<blink::mojom::PermissionStatus>::FromV8(
|
2016-01-30 11:19:18 +00:00
|
|
|
v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
2016-05-23 01:59:39 +00:00
|
|
|
blink::mojom::PermissionStatus* out) {
|
2016-02-01 09:43:49 +00:00
|
|
|
bool result;
|
|
|
|
if (!ConvertFromV8(isolate, val, &result))
|
2016-01-30 11:19:18 +00:00
|
|
|
return false;
|
|
|
|
|
2016-02-01 09:43:49 +00:00
|
|
|
if (result)
|
2016-05-23 01:59:39 +00:00
|
|
|
*out = blink::mojom::PermissionStatus::GRANTED;
|
2016-01-30 11:19:18 +00:00
|
|
|
else
|
2016-05-23 01:59:39 +00:00
|
|
|
*out = blink::mojom::PermissionStatus::DENIED;
|
2016-01-30 11:19:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2022-05-17 16:48:40 +00:00
|
|
|
v8::Local<v8::Value> Converter<blink::PermissionType>::ToV8(
|
2018-04-18 01:55:30 +00:00
|
|
|
v8::Isolate* isolate,
|
2022-05-17 16:48:40 +00:00
|
|
|
const blink::PermissionType& val) {
|
2019-06-19 21:23:04 +00:00
|
|
|
using PermissionType = electron::WebContentsPermissionHelper::PermissionType;
|
2020-10-29 18:22:32 +00:00
|
|
|
// Based on mappings from content/browser/devtools/protocol/browser_handler.cc
|
|
|
|
// Not all permissions are currently used by Electron but this will future
|
|
|
|
// proof these conversions.
|
2016-01-30 11:19:18 +00:00
|
|
|
switch (val) {
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::ACCESSIBILITY_EVENTS:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "accessibility-events");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::AR:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "ar");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::BACKGROUND_FETCH:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "background-fetch");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::BACKGROUND_SYNC:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "background-sync");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::CLIPBOARD_READ_WRITE:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "clipboard-read");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::CLIPBOARD_SANITIZED_WRITE:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "clipboard-sanitized-write");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::LOCAL_FONTS:
|
2022-04-22 22:36:22 +00:00
|
|
|
return StringToV8(isolate, "local-fonts");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::IDLE_DETECTION:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "idle-detection");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::MIDI_SYSEX:
|
2016-01-30 11:19:18 +00:00
|
|
|
return StringToV8(isolate, "midiSysex");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::NFC:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "nfc");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::NOTIFICATIONS:
|
2016-01-30 11:19:18 +00:00
|
|
|
return StringToV8(isolate, "notifications");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::PAYMENT_HANDLER:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "payment-handler");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::PERIODIC_BACKGROUND_SYNC:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "periodic-background-sync");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::DURABLE_STORAGE:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "persistent-storage");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::GEOLOCATION:
|
2016-01-30 11:19:18 +00:00
|
|
|
return StringToV8(isolate, "geolocation");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::CAMERA_PAN_TILT_ZOOM:
|
|
|
|
case blink::PermissionType::AUDIO_CAPTURE:
|
|
|
|
case blink::PermissionType::VIDEO_CAPTURE:
|
2016-01-30 11:19:18 +00:00
|
|
|
return StringToV8(isolate, "media");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
|
2016-01-30 11:19:18 +00:00
|
|
|
return StringToV8(isolate, "mediaKeySystem");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::MIDI:
|
2016-01-30 11:19:18 +00:00
|
|
|
return StringToV8(isolate, "midi");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::WAKE_LOCK_SCREEN:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "screen-wake-lock");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::SENSORS:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "sensors");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::STORAGE_ACCESS_GRANT:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "storage-access");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::VR:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "vr");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::WAKE_LOCK_SYSTEM:
|
2020-10-29 18:22:32 +00:00
|
|
|
return StringToV8(isolate, "system-wake-lock");
|
2022-10-27 16:37:04 +00:00
|
|
|
case blink::PermissionType::WINDOW_MANAGEMENT:
|
|
|
|
return StringToV8(isolate, "window-management");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::DISPLAY_CAPTURE:
|
2020-12-22 22:14:44 +00:00
|
|
|
return StringToV8(isolate, "display-capture");
|
2023-01-06 02:35:34 +00:00
|
|
|
case blink::PermissionType::TOP_LEVEL_STORAGE_ACCESS:
|
|
|
|
return StringToV8(isolate, "top-level-storage-access");
|
2022-05-17 16:48:40 +00:00
|
|
|
case blink::PermissionType::NUM:
|
2016-02-01 09:43:49 +00:00
|
|
|
break;
|
2016-01-30 11:19:18 +00:00
|
|
|
}
|
2016-02-01 09:43:49 +00:00
|
|
|
|
2019-11-12 15:18:48 +00:00
|
|
|
switch (static_cast<PermissionType>(val)) {
|
|
|
|
case PermissionType::POINTER_LOCK:
|
|
|
|
return StringToV8(isolate, "pointerLock");
|
|
|
|
case PermissionType::FULLSCREEN:
|
|
|
|
return StringToV8(isolate, "fullscreen");
|
|
|
|
case PermissionType::OPEN_EXTERNAL:
|
|
|
|
return StringToV8(isolate, "openExternal");
|
2020-09-28 16:22:03 +00:00
|
|
|
case PermissionType::SERIAL:
|
|
|
|
return StringToV8(isolate, "serial");
|
2021-09-23 11:00:11 +00:00
|
|
|
case PermissionType::HID:
|
|
|
|
return StringToV8(isolate, "hid");
|
2022-11-22 21:50:32 +00:00
|
|
|
case PermissionType::USB:
|
|
|
|
return StringToV8(isolate, "usb");
|
2019-11-12 15:18:48 +00:00
|
|
|
default:
|
|
|
|
return StringToV8(isolate, "unknown");
|
|
|
|
}
|
2016-01-30 11:19:18 +00:00
|
|
|
}
|
|
|
|
|
2015-12-17 17:27:56 +00:00
|
|
|
// static
|
2018-04-18 01:55:30 +00:00
|
|
|
bool Converter<content::StopFindAction>::FromV8(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
|
|
|
content::StopFindAction* out) {
|
2015-12-17 17:27:56 +00:00
|
|
|
std::string action;
|
|
|
|
if (!ConvertFromV8(isolate, val, &action))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (action == "clearSelection")
|
|
|
|
*out = content::STOP_FIND_ACTION_CLEAR_SELECTION;
|
|
|
|
else if (action == "keepSelection")
|
|
|
|
*out = content::STOP_FIND_ACTION_KEEP_SELECTION;
|
2015-12-17 23:10:42 +00:00
|
|
|
else if (action == "activateSelection")
|
2015-12-17 17:27:56 +00:00
|
|
|
*out = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
|
2015-12-17 23:10:42 +00:00
|
|
|
else
|
|
|
|
return false;
|
2015-12-17 17:27:56 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-31 21:35:34 +00:00
|
|
|
// static
|
|
|
|
v8::Local<v8::Value> Converter<content::WebContents*>::ToV8(
|
2018-04-18 01:55:30 +00:00
|
|
|
v8::Isolate* isolate,
|
|
|
|
content::WebContents* val) {
|
2016-02-17 08:52:19 +00:00
|
|
|
if (!val)
|
|
|
|
return v8::Null(isolate);
|
2019-06-19 21:23:04 +00:00
|
|
|
return electron::api::WebContents::FromOrCreate(isolate, val).ToV8();
|
2016-01-31 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-26 07:10:27 +00:00
|
|
|
// static
|
2018-04-18 01:55:30 +00:00
|
|
|
bool Converter<content::WebContents*>::FromV8(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
|
|
|
content::WebContents** out) {
|
2020-09-16 19:25:49 +00:00
|
|
|
if (!val->IsObject())
|
|
|
|
return false;
|
|
|
|
// gin's unwrapping converter doesn't expect the pointer inside to ever be
|
|
|
|
// nullptr, so we check here first before attempting to unwrap.
|
|
|
|
if (gin_helper::Destroyable::IsDestroyed(val.As<v8::Object>()))
|
|
|
|
return false;
|
2019-06-19 21:23:04 +00:00
|
|
|
electron::api::WebContents* web_contents = nullptr;
|
2019-10-25 13:03:28 +00:00
|
|
|
if (!gin::ConvertFromV8(isolate, val, &web_contents) || !web_contents)
|
2016-04-26 07:10:27 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
*out = web_contents->web_contents();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-04-05 23:13:24 +00:00
|
|
|
// static
|
|
|
|
v8::Local<v8::Value> Converter<content::Referrer>::ToV8(
|
2018-04-18 01:55:30 +00:00
|
|
|
v8::Isolate* isolate,
|
|
|
|
const content::Referrer& val) {
|
2019-10-25 13:03:28 +00:00
|
|
|
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
2018-04-05 23:13:24 +00:00
|
|
|
dict.Set("url", ConvertToV8(isolate, val.url));
|
|
|
|
dict.Set("policy", ConvertToV8(isolate, val.policy));
|
2019-10-25 13:03:28 +00:00
|
|
|
return gin::ConvertToV8(isolate, dict);
|
2018-04-05 23:13:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2018-04-18 01:55:30 +00:00
|
|
|
bool Converter<content::Referrer>::FromV8(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
|
|
|
content::Referrer* out) {
|
2019-10-25 13:03:28 +00:00
|
|
|
gin_helper::Dictionary dict;
|
2018-04-05 23:13:24 +00:00
|
|
|
if (!ConvertFromV8(isolate, val, &dict))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!dict.Get("url", &out->url))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!dict.Get("policy", &out->policy))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
// static
|
|
|
|
bool Converter<content::NativeWebKeyboardEvent>::FromV8(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
|
|
|
content::NativeWebKeyboardEvent* out) {
|
|
|
|
gin_helper::Dictionary dict;
|
|
|
|
if (!ConvertFromV8(isolate, val, &dict))
|
|
|
|
return false;
|
|
|
|
if (!ConvertFromV8(isolate, val, static_cast<blink::WebKeyboardEvent*>(out)))
|
|
|
|
return false;
|
|
|
|
dict.Get("skipInBrowser", &out->skip_in_browser);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
const content::NativeWebKeyboardEvent& in) {
|
2021-07-14 11:50:02 +00:00
|
|
|
return ConvertToV8(isolate, static_cast<blink::WebKeyboardEvent>(in));
|
2019-10-25 13:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace gin
|