Commit f19f41ec authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

Global Media Controls: Don't handle media keys on lock screen

This CL adds a check to prevent handling media keys when the screen is
locked.

Bug: 951485
Change-Id: I1a2481894e20ceee1879d32066cf969a0b4263bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1562370Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649654}
parent 6da8af68
......@@ -11,6 +11,7 @@
#include "content/browser/browser_main_loop.h"
#include "content/browser/media/hardware_key_media_controller.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/idle/idle.h"
#include "ui/base/mpris/buildflags/buildflags.h"
#if BUILDFLAG(USE_MPRIS)
......@@ -128,6 +129,16 @@ void MediaKeysListenerManagerImpl::OnMediaKeysAccelerator(
// We should never receive an accelerator that was never registered.
DCHECK(delegate_map_.contains(accelerator.key_code()));
#if defined(OS_WIN) || defined(OS_MACOSX)
// For privacy, we don't want to handle media keys when the system is locked.
// On Windows and Mac OS X, this will happen unless we explicitly prevent it.
// TODO(steimel): Consider adding an idle monitor instead and disabling the
// RemoteCommandCenter/SystemMediaTransportControls on lock so that other OS
// apps can take control.
if (ui::CheckIdleStateIsLocked())
return;
#endif
ListeningData* listening_data = delegate_map_[accelerator.key_code()].get();
// If the HardwareKeyMediaController is listening and is allowed to listen,
......@@ -152,6 +163,10 @@ void MediaKeysListenerManagerImpl::EnsureAuxiliaryServices() {
#endif
#if defined(OS_MACOSX)
// On Mac OS, we need to initialize the idle monitor in order to check if the
// system is locked.
ui::InitIdleMonitor();
// Only create the NowPlayingInfoCenterNotifier if we're able to get a
// NowPlayingInfoCenterDelegate.
auto now_playing_info_center_delegate =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment