Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use the new MediaPlayPause key listener for internal chrome logic #21998

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion buildflags/BUILD.gn
Expand Up @@ -21,7 +21,6 @@ buildflag_header("buildflags") {
"ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions",
"ENABLE_BUILTIN_SPELLCHECKER=$enable_builtin_spellchecker",
"ENABLE_PICTURE_IN_PICTURE=$enable_picture_in_picture",
"ENABLE_MEDIA_KEY_OVERRIDES=$enable_media_key_overrides",
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
]
}
2 changes: 0 additions & 2 deletions buildflags/buildflags.gni
Expand Up @@ -22,8 +22,6 @@ declare_args() {

enable_picture_in_picture = true

enable_media_key_overrides = true

# Provide a fake location provider for mocking
# the geolocation responses. Disable it if you
# need to test with chromium's location provider.
Expand Down
1 change: 1 addition & 0 deletions patches/chromium/.patches
Expand Up @@ -83,3 +83,4 @@ add_trustedauthclient_to_urlloaderfactory.patch
feat_allow_disbaling_blink_scheduler_throttling_per_renderview.patch
accessible_pane_view.patch
fix_add_executable_to_chromedriver_s_rpath_for_electron_8.patch
fix_use_the_new_mediaplaypause_key_listener_for_internal_chrome.patch
15 changes: 0 additions & 15 deletions patches/chromium/command-ismediakey.patch
Expand Up @@ -109,18 +109,3 @@ index 85378bb565de617b1bd611d28c8714361747a357..94a899e76586d2c7bb199828bfa4aa1e
return event;
}

@@ -223,12 +233,14 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy,
// For Mac OS 10.12.2 or later, we want to use MPRemoteCommandCenter for
// getting media keys globally if there is a RemoteCommandCenterDelegate
// available.
+#if !BUILDFLAG(ENABLE_MEDIA_KEY_OVERRIDES)
if (scope == Scope::kGlobal) {
auto listener =
std::make_unique<SystemMediaControlsMediaKeysListener>(delegate);
if (listener->Initialize())
return listener;
}
+#endif

return std::make_unique<MediaKeysListenerImpl>(delegate, scope);
}
@@ -0,0 +1,65 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Wed, 29 Jan 2020 12:28:48 -0800
Subject: fix: use the new MediaPlayPause key listener for internal chrome
logic

The new kGlobalRequiresAccessibility Scope type should be upstreamed
and then we can use that and minimize this patch to just the change in
global_shortcut_listener_mac.mm

diff --git a/chrome/browser/extensions/global_shortcut_listener_mac.mm b/chrome/browser/extensions/global_shortcut_listener_mac.mm
index befe726af9c10b1563a7fc0bb77cc55f65943d5c..bac51f33f35f96fe4ecc764cf5ca887176642f74 100644
--- a/chrome/browser/extensions/global_shortcut_listener_mac.mm
+++ b/chrome/browser/extensions/global_shortcut_listener_mac.mm
@@ -39,7 +39,7 @@
// global MediaKeysListener to receive media keys.
if (!content::MediaKeysListenerManager::IsMediaKeysListenerManagerEnabled()) {
media_keys_listener_ = ui::MediaKeysListener::Create(
- this, ui::MediaKeysListener::Scope::kGlobal);
+ this, ui::MediaKeysListener::Scope::kGlobalRequiresAccessibility);
DCHECK(media_keys_listener_);
}
}
diff --git a/ui/base/accelerators/media_keys_listener.h b/ui/base/accelerators/media_keys_listener.h
index 997718d8affaa193fcaabff4cd4c8b0c23df8891..e121598d46e7c62a3b14cb7960136f655cc69ab6 100644
--- a/ui/base/accelerators/media_keys_listener.h
+++ b/ui/base/accelerators/media_keys_listener.h
@@ -20,8 +20,9 @@ class Accelerator;
class UI_BASE_EXPORT MediaKeysListener {
public:
enum class Scope {
- kGlobal, // Listener works whenever application in focus or not.
- kFocused, // Listener only works whan application has focus.
+ kGlobalRequiresAccessibility, // Listener works whenever application in focus or not but requires accessibility permissions on macOS
+ kGlobal, // Listener works whenever application in focus or not but requires media to be playnig.
+ kFocused, // Listener only works whan application has focus.
};

// Media keys accelerators receiver.
diff --git a/ui/base/accelerators/media_keys_listener_linux.cc b/ui/base/accelerators/media_keys_listener_linux.cc
index c74807dfae799851bb2e40996e634d8513e590a0..48f459941cae385e49af09410bb1812db5e6d971 100644
--- a/ui/base/accelerators/media_keys_listener_linux.cc
+++ b/ui/base/accelerators/media_keys_listener_linux.cc
@@ -13,7 +13,7 @@ std::unique_ptr<MediaKeysListener> MediaKeysListener::Create(
MediaKeysListener::Scope scope) {
DCHECK(delegate);

- if (scope == Scope::kGlobal) {
+ if (scope == Scope::kGlobal || scope == Scope::kGlobalRequiresAccessibility) {
if (!SystemMediaControlsMediaKeysListener::has_instance()) {
auto listener =
std::make_unique<SystemMediaControlsMediaKeysListener>(delegate);
diff --git a/ui/base/accelerators/media_keys_listener_win.cc b/ui/base/accelerators/media_keys_listener_win.cc
index c50ea0ca2b8d612b96c0c822f5d36e9eb4ff861d..8b89fea7c09be007d8a020eb4d75f783c887f1a7 100644
--- a/ui/base/accelerators/media_keys_listener_win.cc
+++ b/ui/base/accelerators/media_keys_listener_win.cc
@@ -14,7 +14,7 @@ std::unique_ptr<MediaKeysListener> MediaKeysListener::Create(
MediaKeysListener::Scope scope) {
DCHECK(delegate);

- if (scope == Scope::kGlobal) {
+ if (scope == Scope::kGlobal || scope == Scope::kGlobalRequiresAccessibility) {
// We should never have more than one global media keys listener.
if (!SystemMediaControlsMediaKeysListener::has_instance() &&
!GlobalMediaKeysListenerWin::has_instance()) {