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>
|
2024-01-11 01:00:37 +00:00
|
|
|
#include <string_view>
|
2015-11-02 15:28:45 +00:00
|
|
|
|
2023-06-22 12:33:44 +00:00
|
|
|
#include "base/containers/fixed_flat_map.h"
|
2024-06-07 21:18:35 +00:00
|
|
|
#include "components/input/native_web_keyboard_event.h"
|
2020-03-14 20:54:14 +00:00
|
|
|
#include "content/public/browser/context_menu_params.h"
|
2015-11-02 15:28:45 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/api/electron_api_web_contents.h"
|
|
|
|
#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 {
|
|
|
|
|
2023-12-20 23:44:17 +00:00
|
|
|
static constexpr auto MenuSourceTypes =
|
2024-01-11 01:00:37 +00:00
|
|
|
base::MakeFixedFlatMap<std::string_view, ui::MenuSourceType>({
|
2023-12-20 23:44:17 +00:00
|
|
|
{"adjustSelection", ui::MENU_SOURCE_ADJUST_SELECTION},
|
|
|
|
{"adjustSelectionReset", ui::MENU_SOURCE_ADJUST_SELECTION_RESET},
|
|
|
|
{"keyboard", ui::MENU_SOURCE_KEYBOARD},
|
|
|
|
{"longPress", ui::MENU_SOURCE_LONG_PRESS},
|
|
|
|
{"longTap", ui::MENU_SOURCE_LONG_TAP},
|
|
|
|
{"mouse", ui::MENU_SOURCE_MOUSE},
|
|
|
|
{"none", ui::MENU_SOURCE_NONE},
|
|
|
|
{"stylus", ui::MENU_SOURCE_STYLUS},
|
|
|
|
{"touch", ui::MENU_SOURCE_TOUCH},
|
|
|
|
{"touchHandle", ui::MENU_SOURCE_TOUCH_HANDLE},
|
|
|
|
{"touchMenu", ui::MENU_SOURCE_TOUCH_EDIT_MENU},
|
|
|
|
});
|
|
|
|
|
|
|
|
// let us know when upstream changes & we need to update MenuSourceTypes
|
|
|
|
static_assert(std::size(MenuSourceTypes) == ui::MENU_SOURCE_TYPE_LAST + 1U);
|
|
|
|
|
2023-06-29 22:54:06 +00:00
|
|
|
// static
|
|
|
|
v8::Local<v8::Value> Converter<ui::MenuSourceType>::ToV8(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
const ui::MenuSourceType& in) {
|
2023-12-20 23:44:17 +00:00
|
|
|
for (auto const& [key, val] : MenuSourceTypes)
|
|
|
|
if (in == val)
|
|
|
|
return StringToV8(isolate, key);
|
|
|
|
return {};
|
2023-06-29 22:54:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
bool Converter<ui::MenuSourceType>::FromV8(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
|
|
|
ui::MenuSourceType* out) {
|
2023-12-20 23:44:17 +00:00
|
|
|
return FromV8WithLookup(isolate, val, MenuSourceTypes, out);
|
2023-06-29 22:54:06 +00:00
|
|
|
}
|
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;
|
2023-08-21 01:43:41 +00:00
|
|
|
auto dict = gin_helper::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);
|
2023-11-01 14:02:12 +00:00
|
|
|
dict.Set("formControlType", params.form_control_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) {
|
2016-02-01 09:43:49 +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");
|
2024-07-02 07:51:33 +00:00
|
|
|
case blink::PermissionType::AUTOMATIC_FULLSCREEN:
|
|
|
|
return StringToV8(isolate, "automatic-fullscreen");
|
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");
|
2024-01-03 08:52:49 +00:00
|
|
|
case blink::PermissionType::CAPTURED_SURFACE_CONTROL:
|
|
|
|
return StringToV8(isolate, "captured-surface-control");
|
|
|
|
case blink::PermissionType::SMART_CARD:
|
|
|
|
return StringToV8(isolate, "smart-card");
|
2024-01-11 06:33:40 +00:00
|
|
|
case blink::PermissionType::WEB_PRINTING:
|
|
|
|
return StringToV8(isolate, "web-printing");
|
2024-02-21 20:27:05 +00:00
|
|
|
case blink::PermissionType::SPEAKER_SELECTION:
|
|
|
|
return StringToV8(isolate, "speaker-selection");
|
2024-03-13 08:44:49 +00:00
|
|
|
case blink::PermissionType::POINTER_LOCK:
|
|
|
|
return StringToV8(isolate, "pointerLock");
|
|
|
|
case blink::PermissionType::KEYBOARD_LOCK:
|
|
|
|
return StringToV8(isolate, "keyboardLock");
|
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::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");
|
2024-04-10 20:06:47 +00:00
|
|
|
case PermissionType::FILE_SYSTEM:
|
|
|
|
return StringToV8(isolate, "fileSystem");
|
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) {
|
2023-06-22 12:33:44 +00:00
|
|
|
using Val = content::StopFindAction;
|
2024-01-11 01:00:37 +00:00
|
|
|
static constexpr auto Lookup = base::MakeFixedFlatMap<std::string_view, Val>({
|
|
|
|
{"activateSelection", Val::STOP_FIND_ACTION_ACTIVATE_SELECTION},
|
|
|
|
{"clearSelection", Val::STOP_FIND_ACTION_CLEAR_SELECTION},
|
|
|
|
{"keepSelection", Val::STOP_FIND_ACTION_KEEP_SELECTION},
|
|
|
|
});
|
2023-06-22 12:33:44 +00:00
|
|
|
return FromV8WithLookup(isolate, val, Lookup, out);
|
2015-12-17 17:27:56 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2018-10-19 08:52:07 +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;
|
2016-04-26 07:10:27 +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) {
|
2023-08-21 01:43:41 +00:00
|
|
|
auto dict = gin_helper::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
|
2024-06-07 21:18:35 +00:00
|
|
|
bool Converter<input::NativeWebKeyboardEvent>::FromV8(
|
2019-10-25 13:03:28 +00:00
|
|
|
v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
2024-06-07 21:18:35 +00:00
|
|
|
input::NativeWebKeyboardEvent* out) {
|
2019-10-25 13:03:28 +00:00
|
|
|
gin_helper::Dictionary dict;
|
|
|
|
if (!ConvertFromV8(isolate, val, &dict))
|
|
|
|
return false;
|
|
|
|
if (!ConvertFromV8(isolate, val, static_cast<blink::WebKeyboardEvent*>(out)))
|
|
|
|
return false;
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
dict.Get("skipIfUnhandled", &out->skip_if_unhandled);
|
2019-10-25 13:03:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2024-06-07 21:18:35 +00:00
|
|
|
v8::Local<v8::Value> Converter<input::NativeWebKeyboardEvent>::ToV8(
|
2019-10-25 13:03:28 +00:00
|
|
|
v8::Isolate* isolate,
|
2024-06-07 21:18:35 +00:00
|
|
|
const input::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
|