electron/patches/common/chromium/command-ismediakey.patch
Electron Bot 716cb28430 chore: bump chromium to 1e9f9a24aa12 (master) (#17880)
* chore: bump chromium in DEPS to 1e9f9a24aa12bea9cf194a82a7e249bd1242ec4f

* chore: update patches

* Make WebContents' theme color a base::Optional<SkColor>

https://chromium-review.googlesource.com/c/chromium/src/+/1540022

* update autofill patch for incorrect header includes

* Move Shell messages to web_test and rename to BlinkTest.

https://chromium-review.googlesource.com/c/chromium/src/+/1525181

* Make PlatformNotificationServiceImpl a KeyedService.

https://chromium-review.googlesource.com/c/chromium/src/+/1336150

* Move MediaPlayerId to its own file.

https://chromium-review.googlesource.com/c/chromium/src/+/1547057

* Remove net/base/completion_callback.h, which is no longer used

https://chromium-review.googlesource.com/c/chromium/src/+/1552821

* AW NS: support file scheme cookies

https://chromium-review.googlesource.com/c/chromium/src/+/1533486

* Remove SecurityInfo and adapt remaining consumers

https://chromium-review.googlesource.com/c/chromium/src/+/1509455

* Remove deprecated type-specific number to string conversion functions

https://chromium-review.googlesource.com/c/chromium/src/+/1545881

* DevTools: Adding new performance histograms for launch of top 4 tools

https://chromium-review.googlesource.com/c/chromium/src/+/1506388

* Update include paths for //base/hash/hash.h

https://chromium-review.googlesource.com/c/chromium/src/+/1544630

* build: Disable ensure_gn_version gclient hook for mac CI checkout

* update patches

* use maybe version of v8::String::NewFromTwoByte

* bump appveyor image version

* fix mac ci hopefully

* Convert enum to enum class for MenuAnchorPosition

https://chromium-review.googlesource.com/c/chromium/src/+/1530508

* use maybe version of ToObject

* RenderViewHost::GetProcess is no longer const

* Unrefcount AuthChallengeInfo

https://chromium-review.googlesource.com/c/chromium/src/+/1550631

* MenuButtonController takes Button rather than MenuButton

https://chromium-review.googlesource.com/c/chromium/src/+/1500935

* add //ui/views_bridge_mac to deps to fix link error

* forward declare views::Button in atom::MenuDelegate

* more v8 patches

* base/{=> hash}/md5.h

https://chromium-review.googlesource.com/c/chromium/src/+/1535124

* gfx::{PlatformFontWin => win}::*

https://chromium-review.googlesource.com/c/chromium/src/+/1534178

* fix v8 patches

* [base] Rename TaskScheduler to ThreadPool

https://chromium-review.googlesource.com/c/chromium/src/+/1561552

* use internal_config_base for bytecode_builtins_list_generator

avoids windows link errors

* FIXME: temporarily disable v8/breakpad integration

* FIXME: temporarily disable prevent-will-redirect test

* FIXME: disable neon on aarch64 pending crbug.com/953815

* update to account for WebCursor refactor

https://chromium-review.googlesource.com/c/chromium/src/+/1562755

* enable stack dumping on appveyor

* Revert "FIXME: disable neon on aarch64 pending crbug.com/953815"

This reverts commit 57f082026be3d83069f2a2814684abf4dc9e7b53.

* fix: remove const qualifiers to match upstream

* fix: remove const qualifiers to match upstream in cc files as well

* don't throw an error when testing if an object is an object

* use non-deprecated Buffer constructor

* Remove net::CookieSameSite::DEFAULT_MODE enum value

https://chromium-review.googlesource.com/c/chromium/src/+/1567955

* depend on modded dbus-native to work around buffer deprecation

https://github.com/sidorares/dbus-native/pull/262

* revert clang roll to fix arm build on linux

* fixup! depend on modded dbus-native to work around buffer deprecation

need more coffee

* update coffee-script

* robustify verify-mksnapshot w.r.t. command-line parameters

* Revert "robustify verify-mksnapshot w.r.t. command-line parameters"

This reverts commit a49af01411f684f6025528d604895c3696e0bc57.

* fix mksnapshot by matching args

* update patches

* TMP: enable rdp on appveyor

* Changed ContentBrowserClient::CreateQuotaPermissionContext() to return scoped_refptr.

https://chromium-review.googlesource.com/c/chromium/src/+/1569376

* Make content::ResourceType an enum class.

https://chromium-review.googlesource.com/c/chromium/src/+/1569345

* fixup! Make content::ResourceType an enum class.

* turn off rdp

* use net::CompletionRepeatingCallback instead of base::Callback<void(int)>

* remove disable_ensure_gn_version_gclient_hook.patch

* copy repeating callback instead of std::move

* fix lint

* add completion_repeating_callback.h include
2019-04-20 10:20:37 -07:00

118 lines
5.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <jeremya@chromium.org>
Date: Wed, 10 Oct 2018 15:07:34 -0700
Subject: define Command::IsMediaKey on mac
the definition is copied from //chrome/common/extensions/command.cc,
which also defines a bunch of other stuff that depends on extensions.
since we only need IsMediaKey, and we don't want the extensions stuff
(and aren't compiling command.cc), it's safe to duplicate the
definition. A candidate for upstreaming would be to move the IsMediaKey
function into //ui.
Also apply electron/electron@0f67b1866a9f00b852370e721affa4efda623f3a
and electron/electron@d2368d2d3b3de9eec4cc32b6aaf035cc89921bf1 as
patches.
diff --git a/chrome/browser/extensions/global_shortcut_listener_mac.mm b/chrome/browser/extensions/global_shortcut_listener_mac.mm
index befe726af9c10b1563a7fc0bb77cc55f65943d5c..46c6fe08bab8471007f78d3ef227e5195bfdf0e1 100644
--- a/chrome/browser/extensions/global_shortcut_listener_mac.mm
+++ b/chrome/browser/extensions/global_shortcut_listener_mac.mm
@@ -21,6 +21,26 @@
namespace extensions {
+// NOTE: this is defined in command.cc, but command.cc is full of
+// chrome-extensions-specific logic that we don't want to depend on.
+// Since we don't build command.cc in Electron, it's safe to re-define this
+// function here. Ideally, though, `IsMediaKey` would be the responsibility of
+// `ui::Accelerator`, rather than `extensions::Command`.
+
+// static
+bool Command::IsMediaKey(const ui::Accelerator& accelerator) {
+ if (accelerator.modifiers() != 0)
+ return false;
+
+ return (accelerator.key_code() == ui::VKEY_MEDIA_NEXT_TRACK ||
+ accelerator.key_code() == ui::VKEY_MEDIA_PREV_TRACK ||
+ accelerator.key_code() == ui::VKEY_MEDIA_PLAY_PAUSE ||
+ accelerator.key_code() == ui::VKEY_MEDIA_STOP ||
+ accelerator.key_code() == ui::VKEY_VOLUME_UP ||
+ accelerator.key_code() == ui::VKEY_VOLUME_DOWN ||
+ accelerator.key_code() == ui::VKEY_VOLUME_MUTE);
+}
+
// static
GlobalShortcutListener* GlobalShortcutListener::GetInstance() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/extensions/global_shortcut_listener_win.cc b/chrome/browser/extensions/global_shortcut_listener_win.cc
index c5125495b4d178ffb18be4d2d9670f7556412cbd..cddb321abb938c667a4a2089f87eab999510e9b1 100644
--- a/chrome/browser/extensions/global_shortcut_listener_win.cc
+++ b/chrome/browser/extensions/global_shortcut_listener_win.cc
@@ -62,6 +62,8 @@ void GlobalShortcutListenerWin::OnWndProc(HWND hwnd,
modifiers |= (LOWORD(lparam) & MOD_SHIFT) ? ui::EF_SHIFT_DOWN : 0;
modifiers |= (LOWORD(lparam) & MOD_ALT) ? ui::EF_ALT_DOWN : 0;
modifiers |= (LOWORD(lparam) & MOD_CONTROL) ? ui::EF_CONTROL_DOWN : 0;
+ modifiers |= (LOWORD(lparam) & MOD_WIN) ? ui::EF_COMMAND_DOWN : 0;
+
ui::Accelerator accelerator(
ui::KeyboardCodeForWindowsKeyCode(key_code), modifiers);
@@ -92,6 +94,7 @@ bool GlobalShortcutListenerWin::RegisterAcceleratorImpl(
modifiers |= accelerator.IsShiftDown() ? MOD_SHIFT : 0;
modifiers |= accelerator.IsCtrlDown() ? MOD_CONTROL : 0;
modifiers |= accelerator.IsAltDown() ? MOD_ALT : 0;
+ modifiers |= accelerator.IsCmdDown() ? MOD_WIN : 0;
// Create an observer that registers a hot key for |accelerator|.
std::unique_ptr<gfx::SingletonHwndHotKeyObserver> observer =
diff --git a/chrome/browser/extensions/global_shortcut_listener_x11.cc b/chrome/browser/extensions/global_shortcut_listener_x11.cc
index 392cf3d58c64c088596e8d321a2ce37b0ec60b6e..43e30f47240dc10a3a9b950255d4e48792cc4159 100644
--- a/chrome/browser/extensions/global_shortcut_listener_x11.cc
+++ b/chrome/browser/extensions/global_shortcut_listener_x11.cc
@@ -38,6 +38,7 @@ int GetNativeModifiers(const ui::Accelerator& accelerator) {
modifiers |= accelerator.IsShiftDown() ? ShiftMask : 0;
modifiers |= accelerator.IsCtrlDown() ? ControlMask : 0;
modifiers |= accelerator.IsAltDown() ? Mod1Mask : 0;
+ modifiers |= accelerator.IsCmdDown() ? Mod4Mask : 0;
return modifiers;
}
@@ -151,6 +152,8 @@ void GlobalShortcutListenerX11::OnXKeyPressEvent(::XEvent* x_event) {
modifiers |= (x_event->xkey.state & ShiftMask) ? ui::EF_SHIFT_DOWN : 0;
modifiers |= (x_event->xkey.state & ControlMask) ? ui::EF_CONTROL_DOWN : 0;
modifiers |= (x_event->xkey.state & Mod1Mask) ? ui::EF_ALT_DOWN : 0;
+ // For Windows key
+ modifiers |= (x_event->xkey.state & Mod4Mask) ? ui::EF_COMMAND_DOWN: 0;
ui::Accelerator accelerator(
ui::KeyboardCodeFromXKeyEvent(x_event), modifiers);
diff --git a/ui/base/accelerators/media_keys_listener_mac.mm b/ui/base/accelerators/media_keys_listener_mac.mm
index 71b417ee8b64aa2ff7f1b2390851668ec1dcd7cf..1768af408d4cc3075e5bae046649e4955cc400b3 100644
--- a/ui/base/accelerators/media_keys_listener_mac.mm
+++ b/ui/base/accelerators/media_keys_listener_mac.mm
@@ -33,6 +33,12 @@ KeyboardCode MediaKeyCodeToKeyboardCode(int key_code) {
case NX_KEYTYPE_NEXT:
case NX_KEYTYPE_FAST:
return VKEY_MEDIA_NEXT_TRACK;
+ case NX_KEYTYPE_SOUND_UP:
+ return VKEY_VOLUME_UP;
+ case NX_KEYTYPE_SOUND_DOWN:
+ return VKEY_VOLUME_DOWN;
+ case NX_KEYTYPE_MUTE:
+ return VKEY_VOLUME_MUTE;
}
return VKEY_UNKNOWN;
}
@@ -192,7 +198,10 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy,
int key_code = (data1 & 0xFFFF0000) >> 16;
if (key_code != NX_KEYTYPE_PLAY && key_code != NX_KEYTYPE_NEXT &&
key_code != NX_KEYTYPE_PREVIOUS && key_code != NX_KEYTYPE_FAST &&
- key_code != NX_KEYTYPE_REWIND) {
+ key_code != NX_KEYTYPE_REWIND &&
+ key_code != NX_KEYTYPE_SOUND_UP &&
+ key_code != NX_KEYTYPE_SOUND_DOWN &&
+ key_code != NX_KEYTYPE_MUTE) {
return event;
}