mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
8 Commits
v26.0.0-al
...
v26.0.0-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ce73b5989 | ||
|
|
2b254b1d6d | ||
|
|
6452e5c992 | ||
|
|
28604db7a0 | ||
|
|
236272bf9f | ||
|
|
26e6252ac8 | ||
|
|
548f84df40 | ||
|
|
779a4e700d |
2
DEPS
2
DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'116.0.5845.0',
|
||||
'116.0.5845.14',
|
||||
'node_version':
|
||||
'v18.16.0',
|
||||
'nan_version':
|
||||
|
||||
@@ -80,6 +80,10 @@ The `menu` object has the following instance methods:
|
||||
* `positioningItem` number (optional) _macOS_ - The index of the menu item to
|
||||
be positioned under the mouse cursor at the specified coordinates. Default
|
||||
is -1.
|
||||
* `sourceType` string (optional) _Windows_ _Linux_ - This should map to the `menuSourceType`
|
||||
provided by the `context-menu` event. It is not recommended to set this value manually,
|
||||
only provide values you receive from other APIs or leave it `undefined`.
|
||||
Can be `none`, `mouse`, `keyboard`, `touch`, `touchMenu`, `longPress`, `longTap`, `touchHandle`, `stylus`, `adjustSelection`, or `adjustSelectionReset`.
|
||||
* `callback` Function (optional) - Called when menu is closed.
|
||||
|
||||
Pops up this menu as a context menu in the [`BrowserWindow`](browser-window.md).
|
||||
|
||||
@@ -140,6 +140,16 @@ Possible values are:
|
||||
|
||||
* On Linux, possible types are `desktop`, `dock`, `toolbar`, `splash`,
|
||||
`notification`.
|
||||
* The `desktop` type places the window at the desktop background window level
|
||||
(kCGDesktopWindowLevel - 1). However, note that a desktop window will not
|
||||
receive focus, keyboard, or mouse events. You can still use globalShortcut to
|
||||
receive input sparingly.
|
||||
* The `dock` type creates a dock-like window behavior.
|
||||
* The `toolbar` type creates a window with a toolbar appearance.
|
||||
* The `splash` type behaves in a specific way. It is not
|
||||
draggable, even if the CSS styling of the window's body contains
|
||||
-webkit-app-region: drag. This type is commonly used for splash screens.
|
||||
* The `notification` type creates a window that behaves like a system notification.
|
||||
* On macOS, possible types are `desktop`, `textured`, `panel`.
|
||||
* The `textured` type adds metal gradient appearance
|
||||
(`NSWindowStyleMaskTexturedBackground`).
|
||||
|
||||
@@ -12,6 +12,15 @@ This document uses the following convention to categorize breaking changes:
|
||||
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
||||
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
||||
|
||||
## Planned Breaking API Changes (27.0)
|
||||
|
||||
### Removed: macOS 10.13 / 10.14 support
|
||||
|
||||
macOS 10.13 (High Sierra) and macOS 10.14 (Mojave) are no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/4629466).
|
||||
|
||||
Older versions of Electron will continue to run on these operating systems, but macOS 10.15 (Catalina)
|
||||
or later will be required to run Electron v27.0.0 and higher.
|
||||
|
||||
## Planned Breaking API Changes (25.0)
|
||||
|
||||
### Deprecated: `protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol`
|
||||
|
||||
@@ -63,9 +63,9 @@ const createWindow = () => {
|
||||
|
||||
In this next step, we will create our `BrowserWindow` and tell our application how to handle an event in which an external protocol is clicked.
|
||||
|
||||
This code will be different in Windows compared to MacOS and Linux. This is due to Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](../api/app.md#apprequestsingleinstancelockadditionaldata).
|
||||
This code will be different in Windows and Linux compared to MacOS. This is due to both platforms emitting the `second-instance` event rather than the `open-url` event and Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](../api/app.md#apprequestsingleinstancelockadditionaldata).
|
||||
|
||||
#### Windows code:
|
||||
#### Windows and Linux code:
|
||||
|
||||
```javascript @ts-type={mainWindow:Electron.BrowserWindow} @ts-type={createWindow:()=>void}
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
@@ -80,8 +80,7 @@ if (!gotTheLock) {
|
||||
mainWindow.focus()
|
||||
}
|
||||
// the commandLine is array of strings in which last element is deep link url
|
||||
// the url str ends with /
|
||||
dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop().slice(0, -1)}`)
|
||||
dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop()}`)
|
||||
})
|
||||
|
||||
// Create mainWindow, load the rest of the app, etc...
|
||||
@@ -91,7 +90,7 @@ if (!gotTheLock) {
|
||||
}
|
||||
```
|
||||
|
||||
#### MacOS and Linux code:
|
||||
#### MacOS code:
|
||||
|
||||
```javascript @ts-type={createWindow:()=>void}
|
||||
// This method will be called when Electron has finished
|
||||
|
||||
@@ -69,7 +69,7 @@ Menu.prototype.popup = function (options = {}) {
|
||||
if (options == null || typeof options !== 'object') {
|
||||
throw new TypeError('Options must be an object');
|
||||
}
|
||||
let { window, x, y, positioningItem, callback } = options;
|
||||
let { window, x, y, positioningItem, sourceType, callback } = options;
|
||||
|
||||
// no callback passed
|
||||
if (!callback || typeof callback !== 'function') callback = () => {};
|
||||
@@ -78,6 +78,7 @@ Menu.prototype.popup = function (options = {}) {
|
||||
if (typeof x !== 'number') x = -1;
|
||||
if (typeof y !== 'number') y = -1;
|
||||
if (typeof positioningItem !== 'number') positioningItem = -1;
|
||||
if (typeof sourceType !== 'string' || !sourceType) sourceType = 'mouse';
|
||||
|
||||
// find which window to use
|
||||
const wins = BaseWindow.getAllWindows();
|
||||
@@ -91,7 +92,7 @@ Menu.prototype.popup = function (options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, callback);
|
||||
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, sourceType, callback);
|
||||
return { browserWindow: window, x, y, position: positioningItem };
|
||||
};
|
||||
|
||||
|
||||
@@ -128,3 +128,5 @@ fix_remove_profiles_from_spellcheck_service.patch
|
||||
chore_patch_out_profile_methods_in_chrome_browser_pdf.patch
|
||||
chore_patch_out_profile_methods_in_titlebar_config.patch
|
||||
fix_crash_on_nativetheme_change_during_context_menu_close.patch
|
||||
potential_fix_for_flaky_desktopcaptureapitest_delegation_unittest.patch
|
||||
fix_select_the_first_menu_item_when_opened_via_keyboard.patch
|
||||
|
||||
@@ -46,7 +46,7 @@ index c7ff5942d379b068f13c470677c83845b960858a..cd9fd963dc720f7394b656afe6ec032b
|
||||
sources += [ "certificate_viewer_stub.cc" ]
|
||||
}
|
||||
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
|
||||
index 8d51f9ff0067aab05b4b31b9938575d9e84027be..c0c9d6a1da12d24bc61e4b5a3e26e6be02c4255f 100644
|
||||
index 1bf665b53c5a4018533fe1f9be322358043223cf..7d1aef6e02ada78ebb5a2976e942f6ca573c6914 100644
|
||||
--- a/chrome/test/BUILD.gn
|
||||
+++ b/chrome/test/BUILD.gn
|
||||
@@ -6581,7 +6581,6 @@ test("unit_tests") {
|
||||
@@ -68,7 +68,7 @@ index 8d51f9ff0067aab05b4b31b9938575d9e84027be..c0c9d6a1da12d24bc61e4b5a3e26e6be
|
||||
ldflags = [
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll",
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
|
||||
@@ -7531,7 +7534,6 @@ test("unit_tests") {
|
||||
@@ -7532,7 +7535,6 @@ test("unit_tests") {
|
||||
}
|
||||
|
||||
deps += [
|
||||
@@ -76,7 +76,7 @@ index 8d51f9ff0067aab05b4b31b9938575d9e84027be..c0c9d6a1da12d24bc61e4b5a3e26e6be
|
||||
"//chrome/browser/apps:icon_standardizer",
|
||||
"//chrome/browser/apps/app_service",
|
||||
"//chrome/browser/apps/app_service:test_support",
|
||||
@@ -7617,6 +7619,10 @@ test("unit_tests") {
|
||||
@@ -7618,6 +7620,10 @@ test("unit_tests") {
|
||||
"//ui/webui/resources/js/browser_command:mojo_bindings",
|
||||
]
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ index 488abc9ed0d61a4b73f4bec34cbca416abfbf715..7b1b36d6ab787e2c43d7556b1e4bb1d3
|
||||
|
||||
if (is_win) {
|
||||
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
|
||||
index 7901304acdeb5845f1c1292d6360bda41c0764e0..a3d148324a0d7bc7d5416fd8e6fbdfdd956d9ccf 100644
|
||||
index db63f3aee66b8e9defbbc1fcaa5f905de9cba918..0b9d69bc6b5185672f88edb722e1ebd05ff9b9d6 100644
|
||||
--- a/content/browser/BUILD.gn
|
||||
+++ b/content/browser/BUILD.gn
|
||||
@@ -56,6 +56,7 @@ source_set("browser") {
|
||||
@@ -128,7 +128,7 @@ index 65714a5dca013794527640645d8eb2ce36049ac6..b2df50b4cd64816ddf9c5b7e222c47b6
|
||||
|
||||
public_deps = [
|
||||
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
|
||||
index e4ad1503753b46cf9488eec9c41c122a0b2b8d68..3c71c505a49e9abd2ccfcb840d296fc270615dea 100644
|
||||
index dd42e72891b3cc5f32d8b69dba7cb9230efd033a..c8c6770a2382904edbffba0682b36747595f8754 100644
|
||||
--- a/content/test/BUILD.gn
|
||||
+++ b/content/test/BUILD.gn
|
||||
@@ -475,6 +475,7 @@ static_library("test_support") {
|
||||
@@ -306,10 +306,10 @@ index f5038c6478eeccc17e061681dbee0f384dac4911..bf23c3576bb7b2d10a840e6eb2a420b7
|
||||
if (is_win) {
|
||||
sources += [
|
||||
diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn
|
||||
index 2feb32f83513e4fe6f395ef4d0149af4fb74023e..045ad4c53a8670df70eedbd98ca5dc4763c711a1 100644
|
||||
index c2c93302e51f629594583e5c2f2b89fe084f819e..363892cfe0d359579cff47f85a0bc60794cee22f 100644
|
||||
--- a/ui/views/BUILD.gn
|
||||
+++ b/ui/views/BUILD.gn
|
||||
@@ -684,6 +684,7 @@ component("views") {
|
||||
@@ -682,6 +682,7 @@ component("views") {
|
||||
"IOSurface.framework",
|
||||
"QuartzCore.framework",
|
||||
]
|
||||
@@ -317,7 +317,7 @@ index 2feb32f83513e4fe6f395ef4d0149af4fb74023e..045ad4c53a8670df70eedbd98ca5dc47
|
||||
}
|
||||
|
||||
if (is_win) {
|
||||
@@ -1100,6 +1101,8 @@ source_set("test_support") {
|
||||
@@ -1098,6 +1099,8 @@ source_set("test_support") {
|
||||
"//testing/gtest",
|
||||
]
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ potentially prevent a window from being created.
|
||||
TODO(loc): this patch is currently broken.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
index 8bd1e3c02b5851d9178cc0e2573b5000847902ec..b40f3b4bcd7adf0d1341cbf0752e48d8abe1ce2c 100644
|
||||
index 04b898df25b5d2dfafbc0f0010af9325a90c28d4..45d2c05203cc6ef2cebb4a8c32a7954a85111df7 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
@@ -7843,6 +7843,7 @@ void RenderFrameHostImpl::CreateNewWindow(
|
||||
@@ -7828,6 +7828,7 @@ void RenderFrameHostImpl::CreateNewWindow(
|
||||
last_committed_origin_, params->window_container_type,
|
||||
params->target_url, params->referrer.To<Referrer>(),
|
||||
params->frame_name, params->disposition, *params->features,
|
||||
@@ -66,10 +66,10 @@ index 455703114d540328fafccdec7c9caafa838fdbee..5e37edd4295b501b21d5fe1cad31c993
|
||||
|
||||
// Operation result when the renderer asks the browser to create a new window.
|
||||
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
|
||||
index d9b45cc4c827738e2d958fc85eed0d2ffc10bf74..b9a817079ec336ff70a529a050caedc555ae1ba9 100644
|
||||
index d7a8a6d628b790ad9747335b45d1bb148f536ed7..7ba6f9bf054cf9b4d89cfa129caf91a865e1cf97 100644
|
||||
--- a/content/public/browser/content_browser_client.cc
|
||||
+++ b/content/public/browser/content_browser_client.cc
|
||||
@@ -658,6 +658,8 @@ bool ContentBrowserClient::CanCreateWindow(
|
||||
@@ -665,6 +665,8 @@ bool ContentBrowserClient::CanCreateWindow(
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
@@ -79,10 +79,10 @@ index d9b45cc4c827738e2d958fc85eed0d2ffc10bf74..b9a817079ec336ff70a529a050caedc5
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) {
|
||||
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
||||
index f750767092895262d2ac9432b6288d0d261caaa1..106d02d39b46ccec96d84577e0cdd720b8869465 100644
|
||||
index a558365d87cb4b46eb3bd016fc10889726811db0..1263f4042fe6d62af24131e4a4d7fda714275f48 100644
|
||||
--- a/content/public/browser/content_browser_client.h
|
||||
+++ b/content/public/browser/content_browser_client.h
|
||||
@@ -168,6 +168,7 @@ class NetworkService;
|
||||
@@ -169,6 +169,7 @@ class NetworkService;
|
||||
class TrustedURLLoaderHeaderClient;
|
||||
} // namespace mojom
|
||||
struct ResourceRequest;
|
||||
@@ -90,7 +90,7 @@ index f750767092895262d2ac9432b6288d0d261caaa1..106d02d39b46ccec96d84577e0cdd720
|
||||
} // namespace network
|
||||
|
||||
namespace sandbox {
|
||||
@@ -1068,6 +1069,8 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
@@ -1076,6 +1077,8 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
@@ -163,7 +163,7 @@ index b441530bf7da62ddac5a6f17b6b5c76363efea55..3829c1b7902c0fbc0bb2fb53e2917eca
|
||||
// moved on send.
|
||||
bool is_background_tab =
|
||||
diff --git a/content/web_test/browser/web_test_content_browser_client.cc b/content/web_test/browser/web_test_content_browser_client.cc
|
||||
index bdf18ff21a92c7cde33cb299b5c3c0a609ce2ea8..97822402213729a4204cf36c3cd42ee5f568fc21 100644
|
||||
index e4ee6ba03a5683ce7b1a72ac643b5b2520a2f998..44ac0ad92d22b2db8992c67910e420029f005433 100644
|
||||
--- a/content/web_test/browser/web_test_content_browser_client.cc
|
||||
+++ b/content/web_test/browser/web_test_content_browser_client.cc
|
||||
@@ -504,6 +504,8 @@ bool WebTestContentBrowserClient::CanCreateWindow(
|
||||
@@ -176,7 +176,7 @@ index bdf18ff21a92c7cde33cb299b5c3c0a609ce2ea8..97822402213729a4204cf36c3cd42ee5
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) {
|
||||
diff --git a/content/web_test/browser/web_test_content_browser_client.h b/content/web_test/browser/web_test_content_browser_client.h
|
||||
index 6e9041279578d8365a4eae6bd9f221baf79324d7..39ff665cc8b87ed4997a60a18c05cd42bc6ffd24 100644
|
||||
index d17a2d7f09d1899f2e8888c4747ecffbc5b5ff9a..894795fe392013e66513f1f578970908ec652d5d 100644
|
||||
--- a/content/web_test/browser/web_test_content_browser_client.h
|
||||
+++ b/content/web_test/browser/web_test_content_browser_client.h
|
||||
@@ -83,6 +83,8 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
|
||||
|
||||
@@ -33,7 +33,7 @@ index e74883df0950b2e462a7ebdde8a476259cf0f231..3033d9d9efd3302fba1698a8b8f549c4
|
||||
protected:
|
||||
// |routing_id| must not be MSG_ROUTING_NONE.
|
||||
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
index c01cc787de463b8dc7afb633c939c5b7afbdf822..97840e12fee6f7b378d812d8906a780be52bdf90 100644
|
||||
index 0e521106dda6bf6480e8c6a7fc6afda977e8ec08..9716c8f8a5fe15ffabe4eeedb7b5b35a57b61bac 100644
|
||||
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
@@ -606,7 +606,7 @@ void RenderWidgetHostViewAura::HideImpl() {
|
||||
|
||||
@@ -7,10 +7,10 @@ Subject: feat: filter out non-shareable windows in the current application in
|
||||
This patch ensures that windows protected via win.setContentProtection(true) do not appear in full display captures via desktopCapturer. This patch could be upstreamed but as the check is limited to in-process windows it doesn't make a lot of sense for Chromium itself. This patch currently has a limitation that it only function for windows created / protected BEFORE the stream is started. There is theoretical future work we can do via polling / observers to automatically update the SCContentFilter when new windows are made but for now this will solve 99+% of the problem and folks can re-order their logic a bit to get it working for their use cases.
|
||||
|
||||
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
|
||||
index c1949132c7c6c6f23eb1bb2d795f3dc4f55bbe2f..c552860ca6e0d3a57836149af33eea10508844e3 100644
|
||||
index ffc09580be4f78c10dab2f02bc6b89855c4f80ae..92a9f4e4d256a329b9ad2378819289abe1cc8d66 100644
|
||||
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
|
||||
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
|
||||
@@ -168,7 +168,15 @@ void OnShareableContentCreated(
|
||||
@@ -170,7 +170,15 @@ void OnShareableContentCreated(
|
||||
case DesktopMediaID::TYPE_SCREEN:
|
||||
for (SCDisplay* display : [content displays]) {
|
||||
if (source_.id == [display displayID]) {
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <marshallofsound@electronjs.org>
|
||||
Date: Mon, 26 Jun 2023 00:50:45 -0700
|
||||
Subject: fix: select the first menu item when opened via keyboard
|
||||
|
||||
This fixes an accessibility issue where the root view is 'focused' to the screen reader instead of the first menu item as with all other native menus. This patch will be upstreamed.
|
||||
|
||||
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
|
||||
index f8b3ded1dba82259f7d536ed5bab1a972d182419..b095843c8b28783bf51c0bf7becb111010651486 100644
|
||||
--- a/ui/views/controls/menu/menu_controller.cc
|
||||
+++ b/ui/views/controls/menu/menu_controller.cc
|
||||
@@ -563,6 +563,7 @@ void MenuController::Run(Widget* parent,
|
||||
MenuAnchorPosition position,
|
||||
bool context_menu,
|
||||
bool is_nested_drag,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures) {
|
||||
exit_type_ = ExitType::kNone;
|
||||
possible_drag_ = false;
|
||||
@@ -627,6 +628,14 @@ void MenuController::Run(Widget* parent,
|
||||
// Set the selection, which opens the initial menu.
|
||||
SetSelection(root, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
|
||||
|
||||
+ if (source_type == ui::MENU_SOURCE_KEYBOARD && context_menu && root->HasSubmenu()) {
|
||||
+ // For context menus opened via the keyboard we select the first item by default
|
||||
+ // to match accessibility expectations
|
||||
+ MenuItemView* first_item = FindInitialSelectableMenuItem(root, INCREMENT_SELECTION_DOWN);
|
||||
+ if (first_item)
|
||||
+ SetSelection(first_item, SELECTION_UPDATE_IMMEDIATELY);
|
||||
+ }
|
||||
+
|
||||
if (button_controller) {
|
||||
pressed_lock_ = button_controller->TakeLock(
|
||||
false, ui::LocatedEvent::FromIfValid(event));
|
||||
@@ -2262,19 +2271,15 @@ void MenuController::OpenMenuImpl(MenuItemView* item, bool show) {
|
||||
}
|
||||
item->GetSubmenu()->ShowAt(params);
|
||||
|
||||
- // Figure out if the mouse is under the menu; if so, remember the mouse
|
||||
- // location so we can ignore the first mouse move event(s) with that
|
||||
- // location. We do this after `ShowAt` because `ConvertFromScreen` doesn't
|
||||
- // work correctly if the widget isn't shown.
|
||||
+ // Remember the mouse location so we can ignore the first mouse move
|
||||
+ // event(s) with that location. We do this after `ShowAt` because
|
||||
+ // `ConvertFromScreen` doesn't work correctly if the widget isn't shown.
|
||||
if (item->GetSubmenu()->GetWidget()) {
|
||||
const gfx::Point mouse_pos = ConvertFromScreen(
|
||||
*item->submenu_,
|
||||
display::Screen::GetScreen()->GetCursorScreenPoint());
|
||||
- MenuPart part_under_mouse = GetMenuPart(item->submenu_, mouse_pos);
|
||||
- if (part_under_mouse.type != MenuPartType::kNone) {
|
||||
- menu_open_mouse_loc_ =
|
||||
- GetLocationInRootMenu(*item->submenu_, mouse_pos);
|
||||
- }
|
||||
+ menu_open_mouse_loc_ =
|
||||
+ GetLocationInRootMenu(*item->submenu_, mouse_pos);
|
||||
}
|
||||
|
||||
item->GetSubmenu()->GetWidget()->SetNativeWindowProperty(
|
||||
diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h
|
||||
index e10b92be74908f8d96e421843cb2231f712a4895..82dc2f014d2e333057836290a00c7142b460bb57 100644
|
||||
--- a/ui/views/controls/menu/menu_controller.h
|
||||
+++ b/ui/views/controls/menu/menu_controller.h
|
||||
@@ -134,6 +134,7 @@ class VIEWS_EXPORT MenuController
|
||||
MenuAnchorPosition position,
|
||||
bool context_menu,
|
||||
bool is_nested_drag,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures = gfx::NativeView());
|
||||
|
||||
bool for_drop() const { return for_drop_; }
|
||||
diff --git a/ui/views/controls/menu/menu_runner.cc b/ui/views/controls/menu/menu_runner.cc
|
||||
index adb22671b94fa16854773baad0e6bff1322c6646..fae32722f1209151fa1da59d0c7892aba8956108 100644
|
||||
--- a/ui/views/controls/menu/menu_runner.cc
|
||||
+++ b/ui/views/controls/menu/menu_runner.cc
|
||||
@@ -82,7 +82,7 @@ void MenuRunner::RunMenuAt(Widget* parent,
|
||||
}
|
||||
|
||||
impl_->RunMenuAt(parent, button_controller, bounds, anchor, run_types_,
|
||||
- native_view_for_gestures, corners);
|
||||
+ source_type, native_view_for_gestures, corners);
|
||||
}
|
||||
|
||||
bool MenuRunner::IsRunning() const {
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl.cc b/ui/views/controls/menu/menu_runner_impl.cc
|
||||
index c2513d2889a2baabb1464a53b6b0a32176d52d0c..54f4f863d9ecdf22e3087944f773a866e6c50024 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl.cc
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl.cc
|
||||
@@ -116,6 +116,7 @@ void MenuRunnerImpl::RunMenuAt(Widget* parent,
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t run_types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners) {
|
||||
closing_event_time_ = base::TimeTicks();
|
||||
@@ -184,7 +185,7 @@ void MenuRunnerImpl::RunMenuAt(Widget* parent,
|
||||
controller->Run(parent, button_controller, menu_, bounds, anchor,
|
||||
(run_types & MenuRunner::CONTEXT_MENU) != 0,
|
||||
(run_types & MenuRunner::NESTED_DRAG) != 0,
|
||||
- native_view_for_gestures);
|
||||
+ source_type, native_view_for_gestures);
|
||||
}
|
||||
|
||||
void MenuRunnerImpl::Cancel() {
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl.h b/ui/views/controls/menu/menu_runner_impl.h
|
||||
index 4d2909b5094ab2a4af63504ac0b9f905b5b17759..c49038f592ab1f219ba8b902b69ec7b320e1f74d 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl.h
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl.h
|
||||
@@ -52,6 +52,7 @@ class VIEWS_EXPORT MenuRunnerImpl : public MenuRunnerImplInterface,
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t run_types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners = absl::nullopt) override;
|
||||
void Cancel() override;
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl_adapter.cc b/ui/views/controls/menu/menu_runner_impl_adapter.cc
|
||||
index b6c680063889bb997814cd1be45dfbe5f0989f74..dec5f4b2d609aa7b0cec0f16cc89e222bf9d7b85 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl_adapter.cc
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl_adapter.cc
|
||||
@@ -33,10 +33,11 @@ void MenuRunnerImplAdapter::RunMenuAt(
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners) {
|
||||
impl_->RunMenuAt(parent, button_controller, bounds, anchor, types,
|
||||
- native_view_for_gestures);
|
||||
+ source_type, native_view_for_gestures);
|
||||
}
|
||||
|
||||
void MenuRunnerImplAdapter::Cancel() {
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl_adapter.h b/ui/views/controls/menu/menu_runner_impl_adapter.h
|
||||
index e6587d2208a13576af1831b94724a6286f0e0607..91223ef3f099e20aee5cf1d685c45d2c7f53628e 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl_adapter.h
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl_adapter.h
|
||||
@@ -43,6 +43,7 @@ class VIEWS_EXPORT MenuRunnerImplAdapter : public MenuRunnerImplInterface {
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners = absl::nullopt) override;
|
||||
void Cancel() override;
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl_cocoa.h b/ui/views/controls/menu/menu_runner_impl_cocoa.h
|
||||
index 50291eb07440a35173410336927490f44aae604b..febdb941ff72f7e8e9cc9b36e04c35b0f4c0227d 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl_cocoa.h
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl_cocoa.h
|
||||
@@ -42,6 +42,7 @@ class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface {
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t run_types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners = absl::nullopt) override;
|
||||
void Cancel() override;
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl_cocoa.mm b/ui/views/controls/menu/menu_runner_impl_cocoa.mm
|
||||
index 46a50f5a808c3bda24f44c1ce3a9944327f22fa4..0bfdf45ed43b0701d927940ca78be765b9184b4f 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl_cocoa.mm
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl_cocoa.mm
|
||||
@@ -192,6 +192,7 @@
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t run_types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners) {
|
||||
DCHECK(!IsRunning());
|
||||
diff --git a/ui/views/controls/menu/menu_runner_impl_interface.h b/ui/views/controls/menu/menu_runner_impl_interface.h
|
||||
index cf696fbcf071455007422b95608485c358d8a2b8..b18a6f9b1b4858af0fcb65d1a2e36ba2596e9726 100644
|
||||
--- a/ui/views/controls/menu/menu_runner_impl_interface.h
|
||||
+++ b/ui/views/controls/menu/menu_runner_impl_interface.h
|
||||
@@ -45,6 +45,7 @@ class MenuRunnerImplInterface {
|
||||
const gfx::Rect& bounds,
|
||||
MenuAnchorPosition anchor,
|
||||
int32_t run_types,
|
||||
+ ui::MenuSourceType source_type,
|
||||
gfx::NativeView native_view_for_gestures,
|
||||
absl::optional<gfx::RoundedCornersF> corners = absl::nullopt) = 0;
|
||||
|
||||
@@ -20,10 +20,10 @@ index 02c8f132c266a599c335f83474b3322700a0e5d1..19f731476a2a2beacef7c4493a586c4a
|
||||
}
|
||||
|
||||
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
||||
index 106d02d39b46ccec96d84577e0cdd720b8869465..84ae879b787e3bd4b117f9717355957a84bf3b0c 100644
|
||||
index 1263f4042fe6d62af24131e4a4d7fda714275f48..c671e038868679d282d67158750f6c90b59d237d 100644
|
||||
--- a/content/public/browser/content_browser_client.h
|
||||
+++ b/content/public/browser/content_browser_client.h
|
||||
@@ -304,6 +304,11 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
@@ -305,6 +305,11 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
|
||||
virtual ~ContentBrowserClient() = default;
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ needed in chromium but our autofill implementation uses them. This patch can be
|
||||
our autofill implementation to work like Chromium's.
|
||||
|
||||
diff --git a/ui/color/color_id.h b/ui/color/color_id.h
|
||||
index 0a9045ddd0c02064ce2557cc8ff8c893713e1d80..eaa24c5e32bc1080481acb84be6df1515ee57915 100644
|
||||
index 713dacb89ef7770449383cb8c5c83e679741a78d..0eaef82b4416e3fd4b51c71a544adb328084be39 100644
|
||||
--- a/ui/color/color_id.h
|
||||
+++ b/ui/color/color_id.h
|
||||
@@ -373,6 +373,10 @@
|
||||
@@ -371,6 +371,10 @@
|
||||
E_CPONLY(kColorScrollbarThumbInactive) \
|
||||
E_CPONLY(kColorScrollbarThumbPressed) \
|
||||
E_CPONLY(kColorScrollbarTrack) \
|
||||
@@ -22,7 +22,7 @@ index 0a9045ddd0c02064ce2557cc8ff8c893713e1d80..eaa24c5e32bc1080481acb84be6df151
|
||||
E_CPONLY(kColorSegmentedButtonBorder) \
|
||||
E_CPONLY(kColorSegmentedButtonFocus) \
|
||||
E_CPONLY(kColorSegmentedButtonForegroundChecked) \
|
||||
@@ -460,6 +464,7 @@
|
||||
@@ -458,6 +462,7 @@
|
||||
E_CPONLY(kColorTreeNodeForeground) \
|
||||
E_CPONLY(kColorTreeNodeForegroundSelectedFocused) \
|
||||
E_CPONLY(kColorTreeNodeForegroundSelectedUnfocused) \
|
||||
@@ -31,10 +31,10 @@ index 0a9045ddd0c02064ce2557cc8ff8c893713e1d80..eaa24c5e32bc1080481acb84be6df151
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
diff --git a/ui/color/ui_color_mixer.cc b/ui/color/ui_color_mixer.cc
|
||||
index 5f73cfc2dc8b80eb82e7793dee538cb6d03364bf..8378aa22e901e1f128cd9930aef6779bab979741 100644
|
||||
index 22fda2a88beb6d9495baf54b3d313fc13381dda0..d50d76000d7350c0ea42f24c9ade75ee29c8826f 100644
|
||||
--- a/ui/color/ui_color_mixer.cc
|
||||
+++ b/ui/color/ui_color_mixer.cc
|
||||
@@ -224,6 +224,17 @@ void AddUiColorMixer(ColorProvider* provider,
|
||||
@@ -219,6 +219,17 @@ void AddUiColorMixer(ColorProvider* provider,
|
||||
: SkColorSetA(SK_ColorBLACK, 0x80)};
|
||||
mixer[kColorScrollbarTrack] = {dark_mode ? SkColorSetRGB(0x42, 0x42, 0x42)
|
||||
: SkColorSetRGB(0xF1, 0xF1, 0xF1)};
|
||||
@@ -52,7 +52,7 @@ index 5f73cfc2dc8b80eb82e7793dee538cb6d03364bf..8378aa22e901e1f128cd9930aef6779b
|
||||
mixer[kColorSeparator] = {kColorMidground};
|
||||
mixer[kColorShadowBase] = {dark_mode ? SK_ColorBLACK : gfx::kGoogleGrey800};
|
||||
mixer[kColorShadowValueAmbientShadowElevationThree] =
|
||||
@@ -322,6 +333,7 @@ void AddUiColorMixer(ColorProvider* provider,
|
||||
@@ -317,6 +328,7 @@ void AddUiColorMixer(ColorProvider* provider,
|
||||
mixer[kColorTreeNodeForegroundSelectedFocused] = {kColorTreeNodeForeground};
|
||||
mixer[kColorTreeNodeForegroundSelectedUnfocused] = {
|
||||
kColorTreeNodeForegroundSelectedFocused};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: henrika <henrika@chromium.org>
|
||||
Date: Thu, 22 Jun 2023 18:32:32 +0000
|
||||
Subject: Potential fix for flaky DesktopCaptureApiTest.Delegation unittest
|
||||
|
||||
Bug: 1457052
|
||||
Change-Id: I0b53347eafb60106a250d4fa1ca74a3c6862822e
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4632824
|
||||
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
|
||||
Commit-Queue: Henrik Andreasson <henrika@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#1161343}
|
||||
|
||||
diff --git a/content/browser/media/capture/desktop_capture_device.cc b/content/browser/media/capture/desktop_capture_device.cc
|
||||
index ef10371aa95ce930956975171077cccb6567e614..27687ee9f362c708af3e45d61effb20cebb413ae 100644
|
||||
--- a/content/browser/media/capture/desktop_capture_device.cc
|
||||
+++ b/content/browser/media/capture/desktop_capture_device.cc
|
||||
@@ -159,7 +159,7 @@ class ScopedHighResolutionTimer {
|
||||
}
|
||||
|
||||
private:
|
||||
- bool enabled_;
|
||||
+ bool enabled_ = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -913,10 +913,10 @@ index d971e446859507456da153a9d59f3ed4857b66cb..9ab75731a941e7065dfaa481508cfa47
|
||||
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Set options for print preset from source PDF document.
|
||||
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
|
||||
index f57b2e228134e72e6b1f1766faf6e119fc15a4aa..7901304acdeb5845f1c1292d6360bda41c0764e0 100644
|
||||
index b7029ee5a65e6a2174d62d797fe7354fab0689b7..db63f3aee66b8e9defbbc1fcaa5f905de9cba918 100644
|
||||
--- a/content/browser/BUILD.gn
|
||||
+++ b/content/browser/BUILD.gn
|
||||
@@ -2899,8 +2899,9 @@ source_set("browser") {
|
||||
@@ -2901,8 +2901,9 @@ source_set("browser") {
|
||||
"//ppapi/shared_impl",
|
||||
]
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: render_widget_host_view_base.patch
|
||||
... something to do with OSR? and maybe <webview> as well? terrifying.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc
|
||||
index d7ff9f7303d80635de3add7477cd8611b6aa0afc..4650d3074a9ae3b8936ba37a1204b748e464c64e 100644
|
||||
index f1d50fba17a0a7be9e183467863ad9555438d1f6..8ebc730affa1ecd09426aa23c22f55f95bf07162 100644
|
||||
--- a/content/browser/renderer_host/render_widget_host_view_base.cc
|
||||
+++ b/content/browser/renderer_host/render_widget_host_view_base.cc
|
||||
@@ -683,6 +683,13 @@ bool RenderWidgetHostViewBase::ScreenRectIsUnstableFor(
|
||||
@@ -684,6 +684,13 @@ bool RenderWidgetHostViewBase::ScreenRectIsUnstableFor(
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ Note that we also need to manually update embedder's
|
||||
`api::WebContents::IsFullscreenForTabOrPending` value.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
index b40f3b4bcd7adf0d1341cbf0752e48d8abe1ce2c..4faa6e471eecce952b30618f09f8a6c7086bc98a 100644
|
||||
index 45d2c05203cc6ef2cebb4a8c32a7954a85111df7..2cc189dd47b2ca8dd14e4a836e4bed3ba6dae3a1 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
@@ -7060,6 +7060,17 @@ void RenderFrameHostImpl::EnterFullscreen(
|
||||
@@ -7045,6 +7045,17 @@ void RenderFrameHostImpl::EnterFullscreen(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/common/gin_converters/accelerator_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
|
||||
@@ -78,6 +78,7 @@ class Menu : public gin::Wrappable<Menu>,
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
ui::MenuSourceType source_type,
|
||||
base::OnceClosure callback) = 0;
|
||||
virtual void ClosePopupAt(int32_t window_id) = 0;
|
||||
virtual std::u16string GetAcceleratorTextAtForTesting(int index) const;
|
||||
|
||||
@@ -24,6 +24,7 @@ class MenuMac : public Menu {
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
ui::MenuSourceType source_type,
|
||||
base::OnceClosure callback) override;
|
||||
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||
int32_t window_id,
|
||||
|
||||
@@ -52,6 +52,7 @@ void MenuMac::PopupAt(BaseWindow* window,
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
ui::MenuSourceType source_type,
|
||||
base::OnceClosure callback) {
|
||||
NativeWindow* native_window = window->window();
|
||||
if (!native_window)
|
||||
|
||||
@@ -22,6 +22,7 @@ void MenuViews::PopupAt(BaseWindow* window,
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
ui::MenuSourceType source_type,
|
||||
base::OnceClosure callback) {
|
||||
auto* native_window = static_cast<NativeWindowViews*>(window->window());
|
||||
if (!native_window)
|
||||
@@ -55,7 +56,7 @@ void MenuViews::PopupAt(BaseWindow* window,
|
||||
std::make_unique<MenuRunner>(model(), flags, std::move(close_callback));
|
||||
menu_runners_[window_id]->RunMenuAt(
|
||||
native_window->widget(), nullptr, gfx::Rect(location, gfx::Size()),
|
||||
views::MenuAnchorPosition::kTopLeft, ui::MENU_SOURCE_MOUSE);
|
||||
views::MenuAnchorPosition::kTopLeft, source_type);
|
||||
}
|
||||
|
||||
void MenuViews::ClosePopupAt(int32_t window_id) {
|
||||
|
||||
@@ -25,6 +25,7 @@ class MenuViews : public Menu {
|
||||
int x,
|
||||
int y,
|
||||
int positioning_item,
|
||||
ui::MenuSourceType source_type,
|
||||
base::OnceClosure callback) override;
|
||||
void ClosePopupAt(int32_t window_id) override;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/browser/api/electron_api_menu.h"
|
||||
@@ -29,27 +30,16 @@ struct Converter<electron::TrayIcon::IconType> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
electron::TrayIcon::IconType* out) {
|
||||
using IconType = electron::TrayIcon::IconType;
|
||||
std::string mode;
|
||||
if (ConvertFromV8(isolate, val, &mode)) {
|
||||
if (mode == "none") {
|
||||
*out = IconType::kNone;
|
||||
return true;
|
||||
} else if (mode == "info") {
|
||||
*out = IconType::kInfo;
|
||||
return true;
|
||||
} else if (mode == "warning") {
|
||||
*out = IconType::kWarning;
|
||||
return true;
|
||||
} else if (mode == "error") {
|
||||
*out = IconType::kError;
|
||||
return true;
|
||||
} else if (mode == "custom") {
|
||||
*out = IconType::kCustom;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
using Val = electron::TrayIcon::IconType;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"custom", Val::kCustom},
|
||||
{"error", Val::kError},
|
||||
{"info", Val::kInfo},
|
||||
{"none", Val::kNone},
|
||||
{"warning", Val::kWarning},
|
||||
});
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/containers/id_map.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/json/json_reader.h"
|
||||
@@ -208,26 +209,15 @@ struct Converter<printing::mojom::MarginType> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
printing::mojom::MarginType* out) {
|
||||
std::string type;
|
||||
if (ConvertFromV8(isolate, val, &type)) {
|
||||
if (type == "default") {
|
||||
*out = printing::mojom::MarginType::kDefaultMargins;
|
||||
return true;
|
||||
}
|
||||
if (type == "none") {
|
||||
*out = printing::mojom::MarginType::kNoMargins;
|
||||
return true;
|
||||
}
|
||||
if (type == "printableArea") {
|
||||
*out = printing::mojom::MarginType::kPrintableAreaMargins;
|
||||
return true;
|
||||
}
|
||||
if (type == "custom") {
|
||||
*out = printing::mojom::MarginType::kCustomMargins;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
using Val = printing::mojom::MarginType;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"custom", Val::kCustomMargins},
|
||||
{"default", Val::kDefaultMargins},
|
||||
{"none", Val::kNoMargins},
|
||||
{"printableArea", Val::kPrintableAreaMargins},
|
||||
});
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -236,22 +226,14 @@ struct Converter<printing::mojom::DuplexMode> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
printing::mojom::DuplexMode* out) {
|
||||
std::string mode;
|
||||
if (ConvertFromV8(isolate, val, &mode)) {
|
||||
if (mode == "simplex") {
|
||||
*out = printing::mojom::DuplexMode::kSimplex;
|
||||
return true;
|
||||
}
|
||||
if (mode == "longEdge") {
|
||||
*out = printing::mojom::DuplexMode::kLongEdge;
|
||||
return true;
|
||||
}
|
||||
if (mode == "shortEdge") {
|
||||
*out = printing::mojom::DuplexMode::kShortEdge;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
using Val = printing::mojom::DuplexMode;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"longEdge", Val::kLongEdge},
|
||||
{"shortEdge", Val::kShortEdge},
|
||||
{"simplex", Val::kSimplex},
|
||||
});
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -291,20 +273,14 @@ struct Converter<content::SavePageType> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::SavePageType* out) {
|
||||
std::string save_type;
|
||||
if (!ConvertFromV8(isolate, val, &save_type))
|
||||
return false;
|
||||
save_type = base::ToLowerASCII(save_type);
|
||||
if (save_type == "htmlonly") {
|
||||
*out = content::SAVE_PAGE_TYPE_AS_ONLY_HTML;
|
||||
} else if (save_type == "htmlcomplete") {
|
||||
*out = content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML;
|
||||
} else if (save_type == "mhtml") {
|
||||
*out = content::SAVE_PAGE_TYPE_AS_MHTML;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
using Val = content::SavePageType;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"htmlcomplete", Val::SAVE_PAGE_TYPE_AS_COMPLETE_HTML},
|
||||
{"htmlonly", Val::SAVE_PAGE_TYPE_AS_ONLY_HTML},
|
||||
{"mhtml", Val::SAVE_PAGE_TYPE_AS_MHTML},
|
||||
});
|
||||
return FromV8WithLowerLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -342,24 +318,19 @@ struct Converter<electron::api::WebContents::Type> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
electron::api::WebContents::Type* out) {
|
||||
using Type = electron::api::WebContents::Type;
|
||||
std::string type;
|
||||
if (!ConvertFromV8(isolate, val, &type))
|
||||
return false;
|
||||
if (type == "backgroundPage") {
|
||||
*out = Type::kBackgroundPage;
|
||||
} else if (type == "browserView") {
|
||||
*out = Type::kBrowserView;
|
||||
} else if (type == "webview") {
|
||||
*out = Type::kWebView;
|
||||
using Val = electron::api::WebContents::Type;
|
||||
// clang-format off
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"backgroundPage", Val::kBackgroundPage},
|
||||
{"browserView", Val::kBrowserView},
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
} else if (type == "offscreen") {
|
||||
*out = Type::kOffScreen;
|
||||
{"offscreen", Val::kOffScreen},
|
||||
#endif
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
{"webview", Val::kWebView},
|
||||
});
|
||||
// clang-format on
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/uuid.h"
|
||||
@@ -45,22 +46,17 @@ struct Converter<electron::ProtocolType> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
electron::ProtocolType* out) {
|
||||
std::string type;
|
||||
if (!ConvertFromV8(isolate, val, &type))
|
||||
return false;
|
||||
if (type == "buffer")
|
||||
*out = electron::ProtocolType::kBuffer;
|
||||
else if (type == "string")
|
||||
*out = electron::ProtocolType::kString;
|
||||
else if (type == "file")
|
||||
*out = electron::ProtocolType::kFile;
|
||||
else if (type == "http")
|
||||
*out = electron::ProtocolType::kHttp;
|
||||
else if (type == "stream")
|
||||
*out = electron::ProtocolType::kStream;
|
||||
else // note "free" is internal type, not allowed to be passed from user
|
||||
return false;
|
||||
return true;
|
||||
using Val = electron::ProtocolType;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
// note "free" is internal type, not allowed to be passed from user
|
||||
{"buffer", Val::kBuffer},
|
||||
{"file", Val::kFile},
|
||||
{"http", Val::kHttp},
|
||||
{"stream", Val::kStream},
|
||||
{"string", Val::kString},
|
||||
});
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@@ -43,20 +44,15 @@ struct Converter<blink::mojom::AutoplayPolicy> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
blink::mojom::AutoplayPolicy* out) {
|
||||
std::string policy_str;
|
||||
if (!ConvertFromV8(isolate, val, &policy_str))
|
||||
return false;
|
||||
if (policy_str == "no-user-gesture-required") {
|
||||
*out = blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
|
||||
return true;
|
||||
} else if (policy_str == "user-gesture-required") {
|
||||
*out = blink::mojom::AutoplayPolicy::kUserGestureRequired;
|
||||
return true;
|
||||
} else if (policy_str == "document-user-activation-required") {
|
||||
*out = blink::mojom::AutoplayPolicy::kDocumentUserActivationRequired;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
using Val = blink::mojom::AutoplayPolicy;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"document-user-activation-required",
|
||||
Val::kDocumentUserActivationRequired},
|
||||
{"no-user-gesture-required", Val::kNoUserGestureRequired},
|
||||
{"user-gesture-required", Val::kUserGestureRequired},
|
||||
});
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,23 +61,15 @@ struct Converter<blink::mojom::V8CacheOptions> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
blink::mojom::V8CacheOptions* out) {
|
||||
std::string v8_cache_options;
|
||||
if (!ConvertFromV8(isolate, val, &v8_cache_options))
|
||||
return false;
|
||||
if (v8_cache_options == "none") {
|
||||
*out = blink::mojom::V8CacheOptions::kNone;
|
||||
return true;
|
||||
} else if (v8_cache_options == "code") {
|
||||
*out = blink::mojom::V8CacheOptions::kCode;
|
||||
return true;
|
||||
} else if (v8_cache_options == "bypassHeatCheck") {
|
||||
*out = blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck;
|
||||
return true;
|
||||
} else if (v8_cache_options == "bypassHeatCheckAndEagerCompile") {
|
||||
*out = blink::mojom::V8CacheOptions::kFullCodeWithoutHeatCheck;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
using Val = blink::mojom::V8CacheOptions;
|
||||
static constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, Val>({
|
||||
{"bypassHeatCheck", Val::kCodeWithoutHeatCheck},
|
||||
{"bypassHeatCheckAndEagerCompile", Val::kFullCodeWithoutHeatCheck},
|
||||
{"code", Val::kCode},
|
||||
{"none", Val::kNone},
|
||||
});
|
||||
return FromV8WithLookup(isolate, val, Lookup, out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "content/public/browser/context_menu_params.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
@@ -23,36 +24,81 @@
|
||||
|
||||
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");
|
||||
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");
|
||||
default:
|
||||
return StringToV8(isolate, "none");
|
||||
}
|
||||
// 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");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<blink::mojom::MenuItem::Type>::ToV8(
|
||||
@@ -222,20 +268,14 @@ v8::Local<v8::Value> Converter<blink::PermissionType>::ToV8(
|
||||
bool Converter<content::StopFindAction>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::StopFindAction* out) {
|
||||
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;
|
||||
else if (action == "activateSelection")
|
||||
*out = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
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);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "third_party/blink/public/common/permissions/permission_utils.h"
|
||||
#include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h"
|
||||
#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h"
|
||||
#include "ui/base/ui_base_types.h"
|
||||
|
||||
namespace content {
|
||||
struct ContextMenuParams;
|
||||
@@ -39,6 +40,15 @@ struct Converter<ContextMenuParamsWithRenderFrameHost> {
|
||||
const ContextMenuParamsWithRenderFrameHost& val);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<ui::MenuSourceType> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const ui::MenuSourceType& val);
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
ui::MenuSourceType* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::mojom::PermissionStatus> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "shell/common/keyboard_util.h"
|
||||
@@ -14,320 +15,275 @@ namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
// Return key code represented by |str|.
|
||||
ui::KeyboardCode KeyboardCodeFromKeyIdentifier(
|
||||
const std::string& s,
|
||||
absl::optional<char16_t>* shifted_char) {
|
||||
std::string str = base::ToLowerASCII(s);
|
||||
if (str == "ctrl" || str == "control") {
|
||||
return ui::VKEY_CONTROL;
|
||||
} else if (str == "super" || str == "cmd" || str == "command" ||
|
||||
str == "meta") {
|
||||
return ui::VKEY_COMMAND;
|
||||
} else if (str == "commandorcontrol" || str == "cmdorctrl") {
|
||||
using CodeAndShiftedChar =
|
||||
std::pair<ui::KeyboardCode, absl::optional<char16_t>>;
|
||||
|
||||
constexpr CodeAndShiftedChar KeyboardCodeFromKeyIdentifier(
|
||||
base::StringPiece str) {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
return ui::VKEY_COMMAND;
|
||||
constexpr auto CommandOrControl = ui::VKEY_COMMAND;
|
||||
#else
|
||||
return ui::VKEY_CONTROL;
|
||||
constexpr auto CommandOrControl = ui::VKEY_CONTROL;
|
||||
#endif
|
||||
} else if (str == "alt" || str == "option") {
|
||||
return ui::VKEY_MENU;
|
||||
} else if (str == "shift") {
|
||||
return ui::VKEY_SHIFT;
|
||||
} else if (str == "altgr") {
|
||||
return ui::VKEY_ALTGR;
|
||||
} else if (str == "plus") {
|
||||
shifted_char->emplace('+');
|
||||
return ui::VKEY_OEM_PLUS;
|
||||
} else if (str == "capslock") {
|
||||
return ui::VKEY_CAPITAL;
|
||||
} else if (str == "numlock") {
|
||||
return ui::VKEY_NUMLOCK;
|
||||
} else if (str == "scrolllock") {
|
||||
return ui::VKEY_SCROLL;
|
||||
} else if (str == "tab") {
|
||||
return ui::VKEY_TAB;
|
||||
} else if (str == "num0") {
|
||||
return ui::VKEY_NUMPAD0;
|
||||
} else if (str == "num1") {
|
||||
return ui::VKEY_NUMPAD1;
|
||||
} else if (str == "num2") {
|
||||
return ui::VKEY_NUMPAD2;
|
||||
} else if (str == "num3") {
|
||||
return ui::VKEY_NUMPAD3;
|
||||
} else if (str == "num4") {
|
||||
return ui::VKEY_NUMPAD4;
|
||||
} else if (str == "num5") {
|
||||
return ui::VKEY_NUMPAD5;
|
||||
} else if (str == "num6") {
|
||||
return ui::VKEY_NUMPAD6;
|
||||
} else if (str == "num7") {
|
||||
return ui::VKEY_NUMPAD7;
|
||||
} else if (str == "num8") {
|
||||
return ui::VKEY_NUMPAD8;
|
||||
} else if (str == "num9") {
|
||||
return ui::VKEY_NUMPAD9;
|
||||
} else if (str == "numadd") {
|
||||
return ui::VKEY_ADD;
|
||||
} else if (str == "nummult") {
|
||||
return ui::VKEY_MULTIPLY;
|
||||
} else if (str == "numdec") {
|
||||
return ui::VKEY_DECIMAL;
|
||||
} else if (str == "numsub") {
|
||||
return ui::VKEY_SUBTRACT;
|
||||
} else if (str == "numdiv") {
|
||||
return ui::VKEY_DIVIDE;
|
||||
} else if (str == "space") {
|
||||
return ui::VKEY_SPACE;
|
||||
} else if (str == "backspace") {
|
||||
return ui::VKEY_BACK;
|
||||
} else if (str == "delete") {
|
||||
return ui::VKEY_DELETE;
|
||||
} else if (str == "insert") {
|
||||
return ui::VKEY_INSERT;
|
||||
} else if (str == "enter" || str == "return") {
|
||||
return ui::VKEY_RETURN;
|
||||
} else if (str == "up") {
|
||||
return ui::VKEY_UP;
|
||||
} else if (str == "down") {
|
||||
return ui::VKEY_DOWN;
|
||||
} else if (str == "left") {
|
||||
return ui::VKEY_LEFT;
|
||||
} else if (str == "right") {
|
||||
return ui::VKEY_RIGHT;
|
||||
} else if (str == "home") {
|
||||
return ui::VKEY_HOME;
|
||||
} else if (str == "end") {
|
||||
return ui::VKEY_END;
|
||||
} else if (str == "pageup") {
|
||||
return ui::VKEY_PRIOR;
|
||||
} else if (str == "pagedown") {
|
||||
return ui::VKEY_NEXT;
|
||||
} else if (str == "esc" || str == "escape") {
|
||||
return ui::VKEY_ESCAPE;
|
||||
} else if (str == "volumemute") {
|
||||
return ui::VKEY_VOLUME_MUTE;
|
||||
} else if (str == "volumeup") {
|
||||
return ui::VKEY_VOLUME_UP;
|
||||
} else if (str == "volumedown") {
|
||||
return ui::VKEY_VOLUME_DOWN;
|
||||
} else if (str == "medianexttrack") {
|
||||
return ui::VKEY_MEDIA_NEXT_TRACK;
|
||||
} else if (str == "mediaprevioustrack") {
|
||||
return ui::VKEY_MEDIA_PREV_TRACK;
|
||||
} else if (str == "mediastop") {
|
||||
return ui::VKEY_MEDIA_STOP;
|
||||
} else if (str == "mediaplaypause") {
|
||||
return ui::VKEY_MEDIA_PLAY_PAUSE;
|
||||
} else if (str == "printscreen") {
|
||||
return ui::VKEY_SNAPSHOT;
|
||||
} else if (str.size() > 1 && str[0] == 'f') {
|
||||
// F1 - F24.
|
||||
int n;
|
||||
if (base::StringToInt(str.c_str() + 1, &n) && n > 0 && n < 25) {
|
||||
return static_cast<ui::KeyboardCode>(ui::VKEY_F1 + n - 1);
|
||||
} else {
|
||||
LOG(WARNING) << str << "is not available on keyboard";
|
||||
return ui::VKEY_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
if (str.size() > 2)
|
||||
LOG(WARNING) << "Invalid accelerator token: " << str;
|
||||
return ui::VKEY_UNKNOWN;
|
||||
|
||||
constexpr auto Lookup =
|
||||
base::MakeFixedFlatMapSorted<base::StringPiece, CodeAndShiftedChar>({
|
||||
{"alt", {ui::VKEY_MENU, {}}},
|
||||
{"altgr", {ui::VKEY_ALTGR, {}}},
|
||||
{"backspace", {ui::VKEY_BACK, {}}},
|
||||
{"capslock", {ui::VKEY_CAPITAL, {}}},
|
||||
{"cmd", {ui::VKEY_COMMAND, {}}},
|
||||
{"cmdorctrl", {CommandOrControl, {}}},
|
||||
{"command", {ui::VKEY_COMMAND, {}}},
|
||||
{"commandorcontrol", {CommandOrControl, {}}},
|
||||
{"control", {ui::VKEY_CONTROL, {}}},
|
||||
{"ctrl", {ui::VKEY_CONTROL, {}}},
|
||||
{"delete", {ui::VKEY_DELETE, {}}},
|
||||
{"down", {ui::VKEY_DOWN, {}}},
|
||||
{"end", {ui::VKEY_END, {}}},
|
||||
{"enter", {ui::VKEY_RETURN, {}}},
|
||||
{"esc", {ui::VKEY_ESCAPE, {}}},
|
||||
{"escape", {ui::VKEY_ESCAPE, {}}},
|
||||
{"f1", {ui::VKEY_F1, {}}},
|
||||
{"f10", {ui::VKEY_F10, {}}},
|
||||
{"f11", {ui::VKEY_F11, {}}},
|
||||
{"f12", {ui::VKEY_F12, {}}},
|
||||
{"f13", {ui::VKEY_F13, {}}},
|
||||
{"f14", {ui::VKEY_F14, {}}},
|
||||
{"f15", {ui::VKEY_F15, {}}},
|
||||
{"f16", {ui::VKEY_F16, {}}},
|
||||
{"f17", {ui::VKEY_F17, {}}},
|
||||
{"f18", {ui::VKEY_F18, {}}},
|
||||
{"f19", {ui::VKEY_F19, {}}},
|
||||
{"f2", {ui::VKEY_F2, {}}},
|
||||
{"f20", {ui::VKEY_F20, {}}},
|
||||
{"f21", {ui::VKEY_F21, {}}},
|
||||
{"f22", {ui::VKEY_F22, {}}},
|
||||
{"f23", {ui::VKEY_F23, {}}},
|
||||
{"f24", {ui::VKEY_F24, {}}},
|
||||
{"f3", {ui::VKEY_F3, {}}},
|
||||
{"f4", {ui::VKEY_F4, {}}},
|
||||
{"f5", {ui::VKEY_F5, {}}},
|
||||
{"f6", {ui::VKEY_F6, {}}},
|
||||
{"f7", {ui::VKEY_F7, {}}},
|
||||
{"f8", {ui::VKEY_F8, {}}},
|
||||
{"f9", {ui::VKEY_F9, {}}},
|
||||
{"home", {ui::VKEY_HOME, {}}},
|
||||
{"insert", {ui::VKEY_INSERT, {}}},
|
||||
{"left", {ui::VKEY_LEFT, {}}},
|
||||
{"medianexttrack", {ui::VKEY_MEDIA_NEXT_TRACK, {}}},
|
||||
{"mediaplaypause", {ui::VKEY_MEDIA_PLAY_PAUSE, {}}},
|
||||
{"mediaprevioustrack", {ui::VKEY_MEDIA_PREV_TRACK, {}}},
|
||||
{"mediastop", {ui::VKEY_MEDIA_STOP, {}}},
|
||||
{"meta", {ui::VKEY_COMMAND, {}}},
|
||||
{"num0", {ui::VKEY_NUMPAD0, {}}},
|
||||
{"num1", {ui::VKEY_NUMPAD1, {}}},
|
||||
{"num2", {ui::VKEY_NUMPAD2, {}}},
|
||||
{"num3", {ui::VKEY_NUMPAD3, {}}},
|
||||
{"num4", {ui::VKEY_NUMPAD4, {}}},
|
||||
{"num5", {ui::VKEY_NUMPAD5, {}}},
|
||||
{"num6", {ui::VKEY_NUMPAD6, {}}},
|
||||
{"num7", {ui::VKEY_NUMPAD7, {}}},
|
||||
{"num8", {ui::VKEY_NUMPAD8, {}}},
|
||||
{"num9", {ui::VKEY_NUMPAD9, {}}},
|
||||
{"numadd", {ui::VKEY_ADD, {}}},
|
||||
{"numdec", {ui::VKEY_DECIMAL, {}}},
|
||||
{"numdiv", {ui::VKEY_DIVIDE, {}}},
|
||||
{"numlock", {ui::VKEY_NUMLOCK, {}}},
|
||||
{"nummult", {ui::VKEY_MULTIPLY, {}}},
|
||||
{"numsub", {ui::VKEY_SUBTRACT, {}}},
|
||||
{"option", {ui::VKEY_MENU, {}}},
|
||||
{"pagedown", {ui::VKEY_NEXT, {}}},
|
||||
{"pageup", {ui::VKEY_PRIOR, {}}},
|
||||
{"plus", {ui::VKEY_OEM_PLUS, '+'}},
|
||||
{"printscreen", {ui::VKEY_SNAPSHOT, {}}},
|
||||
{"return", {ui::VKEY_RETURN, {}}},
|
||||
{"right", {ui::VKEY_RIGHT, {}}},
|
||||
{"scrolllock", {ui::VKEY_SCROLL, {}}},
|
||||
{"shift", {ui::VKEY_SHIFT, {}}},
|
||||
{"space", {ui::VKEY_SPACE, {}}},
|
||||
{"super", {ui::VKEY_COMMAND, {}}},
|
||||
{"tab", {ui::VKEY_TAB, {}}},
|
||||
{"up", {ui::VKEY_UP, {}}},
|
||||
{"volumedown", {ui::VKEY_VOLUME_DOWN, {}}},
|
||||
{"volumemute", {ui::VKEY_VOLUME_MUTE, {}}},
|
||||
{"volumeup", {ui::VKEY_VOLUME_UP, {}}},
|
||||
});
|
||||
|
||||
if (auto* const iter = Lookup.find(str); iter != Lookup.end())
|
||||
return iter->second;
|
||||
|
||||
return {ui::VKEY_UNKNOWN, {}};
|
||||
}
|
||||
|
||||
constexpr CodeAndShiftedChar KeyboardCodeFromCharCode(char16_t c) {
|
||||
switch (c) {
|
||||
case ' ':
|
||||
return {ui::VKEY_SPACE, {}};
|
||||
case '!':
|
||||
return {ui::VKEY_1, '!'};
|
||||
case '"':
|
||||
return {ui::VKEY_OEM_7, '"'};
|
||||
case '#':
|
||||
return {ui::VKEY_3, '#'};
|
||||
case '$':
|
||||
return {ui::VKEY_4, '$'};
|
||||
case '%':
|
||||
return {ui::VKEY_5, '%'};
|
||||
case '&':
|
||||
return {ui::VKEY_7, '&'};
|
||||
case '(':
|
||||
return {ui::VKEY_9, '('};
|
||||
case ')':
|
||||
return {ui::VKEY_0, ')'};
|
||||
case '*':
|
||||
return {ui::VKEY_8, '*'};
|
||||
case '+':
|
||||
return {ui::VKEY_OEM_PLUS, '+'};
|
||||
case ',':
|
||||
return {ui::VKEY_OEM_COMMA, {}};
|
||||
case '-':
|
||||
return {ui::VKEY_OEM_MINUS, {}};
|
||||
case '.':
|
||||
return {ui::VKEY_OEM_PERIOD, {}};
|
||||
case '/':
|
||||
return {ui::VKEY_OEM_2, {}};
|
||||
case '0':
|
||||
return {ui::VKEY_0, {}};
|
||||
case '1':
|
||||
return {ui::VKEY_1, {}};
|
||||
case '2':
|
||||
return {ui::VKEY_2, {}};
|
||||
case '3':
|
||||
return {ui::VKEY_3, {}};
|
||||
case '4':
|
||||
return {ui::VKEY_4, {}};
|
||||
case '5':
|
||||
return {ui::VKEY_5, {}};
|
||||
case '6':
|
||||
return {ui::VKEY_6, {}};
|
||||
case '7':
|
||||
return {ui::VKEY_7, {}};
|
||||
case '8':
|
||||
return {ui::VKEY_8, {}};
|
||||
case '9':
|
||||
return {ui::VKEY_9, {}};
|
||||
case ':':
|
||||
return {ui::VKEY_OEM_1, ':'};
|
||||
case ';':
|
||||
return {ui::VKEY_OEM_1, {}};
|
||||
case '<':
|
||||
return {ui::VKEY_OEM_COMMA, '<'};
|
||||
case '=':
|
||||
return {ui::VKEY_OEM_PLUS, {}};
|
||||
case '>':
|
||||
return {ui::VKEY_OEM_PERIOD, '>'};
|
||||
case '?':
|
||||
return {ui::VKEY_OEM_2, '?'};
|
||||
case '@':
|
||||
return {ui::VKEY_2, '@'};
|
||||
case '[':
|
||||
return {ui::VKEY_OEM_4, {}};
|
||||
case '\'':
|
||||
return {ui::VKEY_OEM_7, {}};
|
||||
case '\\':
|
||||
return {ui::VKEY_OEM_5, {}};
|
||||
case ']':
|
||||
return {ui::VKEY_OEM_6, {}};
|
||||
case '^':
|
||||
return {ui::VKEY_6, '^'};
|
||||
case '_':
|
||||
return {ui::VKEY_OEM_MINUS, '_'};
|
||||
case '`':
|
||||
return {ui::VKEY_OEM_3, {}};
|
||||
case 'a':
|
||||
return {ui::VKEY_A, {}};
|
||||
case 'b':
|
||||
return {ui::VKEY_B, {}};
|
||||
case 'c':
|
||||
return {ui::VKEY_C, {}};
|
||||
case 'd':
|
||||
return {ui::VKEY_D, {}};
|
||||
case 'e':
|
||||
return {ui::VKEY_E, {}};
|
||||
case 'f':
|
||||
return {ui::VKEY_F, {}};
|
||||
case 'g':
|
||||
return {ui::VKEY_G, {}};
|
||||
case 'h':
|
||||
return {ui::VKEY_H, {}};
|
||||
case 'i':
|
||||
return {ui::VKEY_I, {}};
|
||||
case 'j':
|
||||
return {ui::VKEY_J, {}};
|
||||
case 'k':
|
||||
return {ui::VKEY_K, {}};
|
||||
case 'l':
|
||||
return {ui::VKEY_L, {}};
|
||||
case 'm':
|
||||
return {ui::VKEY_M, {}};
|
||||
case 'n':
|
||||
return {ui::VKEY_N, {}};
|
||||
case 'o':
|
||||
return {ui::VKEY_O, {}};
|
||||
case 'p':
|
||||
return {ui::VKEY_P, {}};
|
||||
case 'q':
|
||||
return {ui::VKEY_Q, {}};
|
||||
case 'r':
|
||||
return {ui::VKEY_R, {}};
|
||||
case 's':
|
||||
return {ui::VKEY_S, {}};
|
||||
case 't':
|
||||
return {ui::VKEY_T, {}};
|
||||
case 'u':
|
||||
return {ui::VKEY_U, {}};
|
||||
case 'v':
|
||||
return {ui::VKEY_V, {}};
|
||||
case 'w':
|
||||
return {ui::VKEY_W, {}};
|
||||
case 'x':
|
||||
return {ui::VKEY_X, {}};
|
||||
case 'y':
|
||||
return {ui::VKEY_Y, {}};
|
||||
case 'z':
|
||||
return {ui::VKEY_Z, {}};
|
||||
case '{':
|
||||
return {ui::VKEY_OEM_4, '{'};
|
||||
case '|':
|
||||
return {ui::VKEY_OEM_5, '|'};
|
||||
case '}':
|
||||
return {ui::VKEY_OEM_6, '}'};
|
||||
case '~':
|
||||
return {ui::VKEY_OEM_3, '~'};
|
||||
case 0x08:
|
||||
return {ui::VKEY_BACK, {}};
|
||||
case 0x09:
|
||||
return {ui::VKEY_TAB, {}};
|
||||
case 0x0D:
|
||||
return {ui::VKEY_RETURN, {}};
|
||||
case 0x1B:
|
||||
return {ui::VKEY_ESCAPE, {}};
|
||||
case 0x7F:
|
||||
return {ui::VKEY_DELETE, {}};
|
||||
default:
|
||||
return {ui::VKEY_UNKNOWN, {}};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ui::KeyboardCode KeyboardCodeFromCharCode(char16_t c, bool* shifted) {
|
||||
c = base::ToLowerASCII(c);
|
||||
*shifted = false;
|
||||
switch (c) {
|
||||
case 0x08:
|
||||
return ui::VKEY_BACK;
|
||||
case 0x7F:
|
||||
return ui::VKEY_DELETE;
|
||||
case 0x09:
|
||||
return ui::VKEY_TAB;
|
||||
case 0x0D:
|
||||
return ui::VKEY_RETURN;
|
||||
case 0x1B:
|
||||
return ui::VKEY_ESCAPE;
|
||||
case ' ':
|
||||
return ui::VKEY_SPACE;
|
||||
case 'a':
|
||||
return ui::VKEY_A;
|
||||
case 'b':
|
||||
return ui::VKEY_B;
|
||||
case 'c':
|
||||
return ui::VKEY_C;
|
||||
case 'd':
|
||||
return ui::VKEY_D;
|
||||
case 'e':
|
||||
return ui::VKEY_E;
|
||||
case 'f':
|
||||
return ui::VKEY_F;
|
||||
case 'g':
|
||||
return ui::VKEY_G;
|
||||
case 'h':
|
||||
return ui::VKEY_H;
|
||||
case 'i':
|
||||
return ui::VKEY_I;
|
||||
case 'j':
|
||||
return ui::VKEY_J;
|
||||
case 'k':
|
||||
return ui::VKEY_K;
|
||||
case 'l':
|
||||
return ui::VKEY_L;
|
||||
case 'm':
|
||||
return ui::VKEY_M;
|
||||
case 'n':
|
||||
return ui::VKEY_N;
|
||||
case 'o':
|
||||
return ui::VKEY_O;
|
||||
case 'p':
|
||||
return ui::VKEY_P;
|
||||
case 'q':
|
||||
return ui::VKEY_Q;
|
||||
case 'r':
|
||||
return ui::VKEY_R;
|
||||
case 's':
|
||||
return ui::VKEY_S;
|
||||
case 't':
|
||||
return ui::VKEY_T;
|
||||
case 'u':
|
||||
return ui::VKEY_U;
|
||||
case 'v':
|
||||
return ui::VKEY_V;
|
||||
case 'w':
|
||||
return ui::VKEY_W;
|
||||
case 'x':
|
||||
return ui::VKEY_X;
|
||||
case 'y':
|
||||
return ui::VKEY_Y;
|
||||
case 'z':
|
||||
return ui::VKEY_Z;
|
||||
case ')':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '0':
|
||||
return ui::VKEY_0;
|
||||
case '!':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '1':
|
||||
return ui::VKEY_1;
|
||||
case '@':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '2':
|
||||
return ui::VKEY_2;
|
||||
case '#':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '3':
|
||||
return ui::VKEY_3;
|
||||
case '$':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '4':
|
||||
return ui::VKEY_4;
|
||||
case '%':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '5':
|
||||
return ui::VKEY_5;
|
||||
case '^':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '6':
|
||||
return ui::VKEY_6;
|
||||
case '&':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '7':
|
||||
return ui::VKEY_7;
|
||||
case '*':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '8':
|
||||
return ui::VKEY_8;
|
||||
case '(':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '9':
|
||||
return ui::VKEY_9;
|
||||
case ':':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case ';':
|
||||
return ui::VKEY_OEM_1;
|
||||
case '+':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '=':
|
||||
return ui::VKEY_OEM_PLUS;
|
||||
case '<':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case ',':
|
||||
return ui::VKEY_OEM_COMMA;
|
||||
case '_':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '-':
|
||||
return ui::VKEY_OEM_MINUS;
|
||||
case '>':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '.':
|
||||
return ui::VKEY_OEM_PERIOD;
|
||||
case '?':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '/':
|
||||
return ui::VKEY_OEM_2;
|
||||
case '~':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '`':
|
||||
return ui::VKEY_OEM_3;
|
||||
case '{':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '[':
|
||||
return ui::VKEY_OEM_4;
|
||||
case '|':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '\\':
|
||||
return ui::VKEY_OEM_5;
|
||||
case '}':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case ']':
|
||||
return ui::VKEY_OEM_6;
|
||||
case '"':
|
||||
*shifted = true;
|
||||
[[fallthrough]];
|
||||
case '\'':
|
||||
return ui::VKEY_OEM_7;
|
||||
default:
|
||||
return ui::VKEY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
ui::KeyboardCode KeyboardCodeFromStr(const std::string& str,
|
||||
ui::KeyboardCode KeyboardCodeFromStr(base::StringPiece str,
|
||||
absl::optional<char16_t>* shifted_char) {
|
||||
if (str.size() == 1) {
|
||||
bool shifted = false;
|
||||
auto ret = KeyboardCodeFromCharCode(str[0], &shifted);
|
||||
if (shifted)
|
||||
shifted_char->emplace(str[0]);
|
||||
return ret;
|
||||
} else {
|
||||
return KeyboardCodeFromKeyIdentifier(str, shifted_char);
|
||||
}
|
||||
auto const [code, shifted] =
|
||||
str.size() == 1 ? KeyboardCodeFromCharCode(base::ToLowerASCII(str[0]))
|
||||
: KeyboardCodeFromKeyIdentifier(base::ToLowerASCII(str));
|
||||
|
||||
if (code == ui::VKEY_UNKNOWN)
|
||||
LOG(WARNING) << "Invalid accelerator token: " << str;
|
||||
|
||||
*shifted_char = shifted;
|
||||
return code;
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -5,21 +5,16 @@
|
||||
#ifndef ELECTRON_SHELL_COMMON_KEYBOARD_UTIL_H_
|
||||
#define ELECTRON_SHELL_COMMON_KEYBOARD_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
// Return key code of the char, and also determine whether the SHIFT key is
|
||||
// pressed.
|
||||
ui::KeyboardCode KeyboardCodeFromCharCode(char16_t c, bool* shifted);
|
||||
|
||||
// Return key code of the |str|, if the original key is a shifted character,
|
||||
// for example + and /, set it in |shifted_char|.
|
||||
// pressed.
|
||||
ui::KeyboardCode KeyboardCodeFromStr(const std::string& str,
|
||||
ui::KeyboardCode KeyboardCodeFromStr(base::StringPiece str,
|
||||
absl::optional<char16_t>* shifted_char);
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -63,7 +63,7 @@ void ElectronRenderFrameObserver::DidClearWindowObject() {
|
||||
// Check DidInstallConditionalFeatures below for the background.
|
||||
auto* web_frame =
|
||||
static_cast<blink::WebLocalFrameImpl*>(render_frame_->GetWebFrame());
|
||||
if (has_delayed_node_initialization_ && web_frame->Opener() &&
|
||||
if (has_delayed_node_initialization_ &&
|
||||
!web_frame->IsOnInitialEmptyDocument()) {
|
||||
v8::Isolate* isolate = blink::MainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
@@ -1150,6 +1150,23 @@ describe('chromium features', () => {
|
||||
expect(eventData).to.equal('size: 350 450');
|
||||
});
|
||||
|
||||
it('loads preload script after setting opener to null', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.webContents.setWindowOpenHandler(() => ({
|
||||
action: 'allow',
|
||||
overrideBrowserWindowOptions: {
|
||||
webPreferences: {
|
||||
preload: path.join(fixturesPath, 'module', 'preload.js')
|
||||
}
|
||||
}
|
||||
}));
|
||||
w.loadURL('about:blank');
|
||||
w.webContents.executeJavaScript('window.child = window.open(); child.opener = null');
|
||||
const [, { webContents }] = await once(app, 'browser-window-created');
|
||||
const [,, message] = await once(webContents, 'console-message');
|
||||
expect(message).to.equal('{"require":"function","module":"undefined","process":"object","Buffer":"function"}');
|
||||
});
|
||||
|
||||
it('disables the <webview> tag when it is disabled on the parent window', async () => {
|
||||
const windowUrl = url.pathToFileURL(path.join(fixturesPath, 'pages', 'window-opener-no-webview-tag.html'));
|
||||
windowUrl.searchParams.set('p', `${fixturesPath}/pages/window-opener-webview.html`);
|
||||
|
||||
2
typings/internal-electron.d.ts
vendored
2
typings/internal-electron.d.ts
vendored
@@ -115,7 +115,7 @@ declare namespace Electron {
|
||||
commandsMap: Record<string, MenuItem>;
|
||||
groupsMap: Record<string, MenuItem[]>;
|
||||
getItemCount(): number;
|
||||
popupAt(window: BaseWindow, x: number, y: number, positioning: number, callback: () => void): void;
|
||||
popupAt(window: BaseWindow, x: number, y: number, positioning: number, sourceType: Required<Electron.PopupOptions>['sourceType'], callback: () => void): void;
|
||||
closePopupAt(id: number): void;
|
||||
setSublabel(index: number, label: string): void;
|
||||
setToolTip(index: number, tooltip: string): void;
|
||||
|
||||
Reference in New Issue
Block a user