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
|
|
|
|
2023-06-22 12:33:44 +00:00
|
|
|
#include "base/containers/fixed_flat_map.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"
|
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
|
|
|
#include "content/public/common/input/native_web_keyboard_event.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
|
|
|
|
2023-11-01 14:02:12 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr base::StringPiece FormControlToInputFieldTypeString(
|
|
|
|
const absl::optional<blink::mojom::FormControlType> form_control_type) {
|
|
|
|
if (!form_control_type)
|
|
|
|
return "none";
|
|
|
|
|
|
|
|
switch (*form_control_type) {
|
|
|
|
case blink::mojom::FormControlType::kInputPassword:
|
|
|
|
return "password";
|
|
|
|
|
|
|
|
case blink::mojom::FormControlType::kInputText:
|
|
|
|
return "plainText";
|
|
|
|
|
|
|
|
// other input types:
|
|
|
|
case blink::mojom::FormControlType::kInputButton:
|
|
|
|
case blink::mojom::FormControlType::kInputCheckbox:
|
|
|
|
case blink::mojom::FormControlType::kInputColor:
|
|
|
|
case blink::mojom::FormControlType::kInputDate:
|
|
|
|
case blink::mojom::FormControlType::kInputDatetimeLocal:
|
|
|
|
case blink::mojom::FormControlType::kInputEmail:
|
|
|
|
case blink::mojom::FormControlType::kInputFile:
|
|
|
|
case blink::mojom::FormControlType::kInputHidden:
|
|
|
|
case blink::mojom::FormControlType::kInputImage:
|
|
|
|
case blink::mojom::FormControlType::kInputMonth:
|
|
|
|
case blink::mojom::FormControlType::kInputNumber:
|
|
|
|
case blink::mojom::FormControlType::kInputRadio:
|
|
|
|
case blink::mojom::FormControlType::kInputRange:
|
|
|
|
case blink::mojom::FormControlType::kInputReset:
|
|
|
|
case blink::mojom::FormControlType::kInputSearch:
|
|
|
|
case blink::mojom::FormControlType::kInputSubmit:
|
|
|
|
case blink::mojom::FormControlType::kInputTelephone:
|
|
|
|
case blink::mojom::FormControlType::kInputTime:
|
|
|
|
case blink::mojom::FormControlType::kInputUrl:
|
|
|
|
case blink::mojom::FormControlType::kInputWeek:
|
|
|
|
return "other";
|
|
|
|
|
|
|
|
// not an input type
|
|
|
|
default:
|
|
|
|
return "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
namespace gin {
|
|
|
|
|
2023-06-29 22:54:06 +00:00
|
|
|
// static
|
|
|
|
v8::Local<v8::Value> Converter<ui::MenuSourceType>::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");
|
|
|
|
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");
|
|
|
|
case ui::MENU_SOURCE_NONE:
|
|
|
|
return StringToV8(isolate, "none");
|
2019-10-25 13:03:28 +00:00
|
|
|
}
|
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) {
|
|
|
|
std::string type;
|
|
|
|
if (!ConvertFromV8(isolate, val, &type))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (type == "mouse") {
|
|
|
|
*out = ui::MENU_SOURCE_MOUSE;
|
|
|
|
return true;
|
|
|
|
} else if (type == "keyboard") {
|
|
|
|
*out = ui::MENU_SOURCE_KEYBOARD;
|
|
|
|
return true;
|
|
|
|
} else if (type == "touch") {
|
|
|
|
*out = ui::MENU_SOURCE_TOUCH;
|
|
|
|
return true;
|
|
|
|
} else if (type == "touchMenu") {
|
|
|
|
*out = ui::MENU_SOURCE_TOUCH_EDIT_MENU;
|
|
|
|
return true;
|
|
|
|
} else if (type == "longPress") {
|
|
|
|
*out = ui::MENU_SOURCE_LONG_PRESS;
|
|
|
|
return true;
|
|
|
|
} else if (type == "longTap") {
|
|
|
|
*out = ui::MENU_SOURCE_LONG_TAP;
|
|
|
|
return true;
|
|
|
|
} else if (type == "touchHandle") {
|
|
|
|
*out = ui::MENU_SOURCE_TOUCH_HANDLE;
|
|
|
|
return true;
|
|
|
|
} else if (type == "stylus") {
|
|
|
|
*out = ui::MENU_SOURCE_STYLUS;
|
|
|
|
return true;
|
|
|
|
} else if (type == "adjustSelection") {
|
|
|
|
*out = ui::MENU_SOURCE_ADJUST_SELECTION;
|
|
|
|
return true;
|
|
|
|
} else if (type == "adjustSelectionReset") {
|
|
|
|
*out = ui::MENU_SOURCE_ADJUST_SELECTION_RESET;
|
|
|
|
return true;
|
|
|
|
} else if (type == "none") {
|
|
|
|
*out = ui::MENU_SOURCE_NONE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
// NB: inputFieldType is deprecated because the upstream
|
|
|
|
// field was removed; we are emulating it now until removal
|
|
|
|
dict.Set("inputFieldType",
|
|
|
|
FormControlToInputFieldTypeString(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) {
|
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");
|
2023-11-06 19:54:31 +00:00
|
|
|
case PermissionType::KEYBOARD_LOCK:
|
|
|
|
return StringToV8(isolate, "keyboardLock");
|
2019-11-12 15:18:48 +00:00
|
|
|
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) {
|
2023-06-22 12:33:44 +00:00
|
|
|
using Val = content::StopFindAction;
|
|
|
|
static constexpr auto Lookup =
|
|
|
|
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
|
|
|
{"activateSelection", Val::STOP_FIND_ACTION_ACTIVATE_SELECTION},
|
|
|
|
{"clearSelection", Val::STOP_FIND_ACTION_CLEAR_SELECTION},
|
|
|
|
{"keepSelection", Val::STOP_FIND_ACTION_KEEP_SELECTION},
|
|
|
|
});
|
|
|
|
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);
|
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) {
|
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
|
|
|
|
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;
|
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
|
|
|
|
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
|