mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
chore: bump chromium to 148.0.7733.0 42-x-y * chore: bump chromium in DEPS to 147.0.7727.2 * chore: bump chromium in DEPS to 148.0.7728.0 * chore: bump chromium in DEPS to 148.0.7729.0 * chore: bump chromium in DEPS to 148.0.7730.0 * chore: bump chromium in DEPS to 148.0.7732.0 * chore: update WrappablePointerTag patch Refs https://chromium-review.googlesource.com/c/chromium/src/+/7641766 * chore: update custom protocol patch for removed code Refs https://chromium-review.googlesource.com/c/chromium/src/+/7653454 * chore: update patches * fix: cleanup removed CHILD_PLUGIN code Refs https://chromium-review.googlesource.com/c/chromium/src/+/7653455 * fix: move from int to ChildProcessId Refs https://chromium-review.googlesource.com/c/chromium/src/+/7621912 * fix: update extensions CreateTab signature Refs https://chromium-review.googlesource.com/c/chromium/src/+/7644389 * fix: draggable hit region test interface update for mac windows Refs https://chromium-review.googlesource.com/c/chromium/src/+/7655245 * chore: bump chromium in DEPS to 148.0.7733.0 * feat: restore macos child plugin process Refs https://chromium-review.googlesource.com/c/chromium/src/+/7653455 * fixup! chore: merge main * chore: update patches * fix: replace clipboard IsFormatAvailable with async GetAllAvailableFormats Refs https://chromium-review.googlesource.com/c/chromium/src/+/7631097 Async API pending RFC https://github.com/electron/rfcs/pull/19 --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
100 lines
4.6 KiB
Diff
100 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shelley Vohr <shelley.vohr@gmail.com>
|
|
Date: Mon, 16 Aug 2021 17:55:32 +0200
|
|
Subject: fix: media key usage with globalShortcuts
|
|
|
|
This patch enables media keys to work properly with Electron's globalShortcut
|
|
module. Chromium's default usage of RemoteCommandCenterDelegate on macOS falls
|
|
down into MPRemoteCommandCenter, which makes it such that an app will not
|
|
receive remote control events until it begins playing audio. This runs
|
|
counter to the design of globalShortcuts, and so we need to instead
|
|
use `ui::MediaKeysListener`.
|
|
|
|
diff --git a/content/browser/media/media_keys_listener_manager_impl.cc b/content/browser/media/media_keys_listener_manager_impl.cc
|
|
index 42e37564e585987d367921568f0f1d2b7507f953..9baf89efbade01e8b60c579255f10799914e144f 100644
|
|
--- a/content/browser/media/media_keys_listener_manager_impl.cc
|
|
+++ b/content/browser/media/media_keys_listener_manager_impl.cc
|
|
@@ -87,7 +87,11 @@ bool MediaKeysListenerManagerImpl::StartWatchingMediaKey(
|
|
CanActiveMediaSessionControllerReceiveEvents();
|
|
|
|
// Tell the underlying MediaKeysListener to listen for the key.
|
|
- if (should_start_watching && media_keys_listener_ &&
|
|
+ if (
|
|
+#if BUILDFLAG(IS_MAC)
|
|
+ !media_key_handling_enabled_ &&
|
|
+#endif // BUILDFLAG(IS_MAC)
|
|
+ should_start_watching && media_keys_listener_ &&
|
|
!media_keys_listener_->StartWatchingMediaKey(key_code)) {
|
|
return false;
|
|
}
|
|
@@ -361,6 +365,20 @@ void MediaKeysListenerManagerImpl::StartListeningForMediaKeysIfNecessary() {
|
|
this, ui::MediaKeysListener::Scope::kGlobal);
|
|
DCHECK(media_keys_listener_);
|
|
}
|
|
+
|
|
+#if BUILDFLAG(IS_MAC)
|
|
+ // Chromium's implementation of SystemMediaControls falls
|
|
+ // down into MPRemoteCommandCenter, which makes it such that an app will not
|
|
+ // will not receive remote control events until it begins playing audio.
|
|
+ // If there's not already a MediaKeysListener instance, create one so
|
|
+ // that globalShortcuts work correctly.
|
|
+ if (!media_keys_listener_) {
|
|
+ media_keys_listener_ = ui::MediaKeysListener::Create(
|
|
+ this, ui::MediaKeysListener::Scope::kGlobal);
|
|
+ DCHECK(media_keys_listener_);
|
|
+ }
|
|
+#endif
|
|
+
|
|
EnsureAuxiliaryServices();
|
|
}
|
|
|
|
diff --git a/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc b/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc
|
|
index 0e9bffaf0203d39d9fb82d717f36b449d5566181..5cf3d98f4679a252290a34c15491a8a4a619ac1c 100644
|
|
--- a/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc
|
|
+++ b/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc
|
|
@@ -62,6 +62,22 @@ void GlobalAcceleratorListener::UnregisterAccelerator(
|
|
}
|
|
}
|
|
|
|
+// static
|
|
+void GlobalAcceleratorListener::SetShouldUseInternalMediaKeyHandling(bool should_use) {
|
|
+ if (content::MediaKeysListenerManager::
|
|
+ IsMediaKeysListenerManagerEnabled()) {
|
|
+ content::MediaKeysListenerManager* media_keys_listener_manager =
|
|
+ content::MediaKeysListenerManager::GetInstance();
|
|
+ DCHECK(media_keys_listener_manager);
|
|
+
|
|
+ if (should_use) {
|
|
+ media_keys_listener_manager->EnableInternalMediaKeyHandling();
|
|
+ } else {
|
|
+ media_keys_listener_manager->DisableInternalMediaKeyHandling();
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
void GlobalAcceleratorListener::UnregisterAccelerators(Observer* observer) {
|
|
auto it = accelerator_map_.begin();
|
|
while (it != accelerator_map_.end()) {
|
|
diff --git a/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h b/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h
|
|
index 4a343f4e701928644ff3f2a855cc04c3fea2932a..a48b7b73508942cc05e0dcf0fe108313f265c7c6 100644
|
|
--- a/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h
|
|
+++ b/ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.h
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include "base/functional/callback.h"
|
|
#include "base/memory/raw_ptr.h"
|
|
+#include "content/public/browser/media_keys_listener_manager.h"
|
|
#include "ui/base/accelerators/command.h"
|
|
#include "ui/gfx/native_ui_types.h"
|
|
|
|
@@ -43,6 +44,9 @@ class GlobalAcceleratorListener {
|
|
// The instance may be nullptr.
|
|
static GlobalAcceleratorListener* GetInstance();
|
|
|
|
+ // enables media keys to work with Electron's globalShortcut module.
|
|
+ static void SetShouldUseInternalMediaKeyHandling(bool should_use);
|
|
+
|
|
// Register an observer for when a certain `accelerator` is struck. Returns
|
|
// true if register successfully, or false if the specified `accelerator`
|
|
// has been registered by another caller or other native applications.
|