blob: 0b4d9a03ffee3b6e771d1762d5eb74e9fc9b4ad5 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/callback.h"
#include "ui/base/ui_base_export.h"
#include "ui/events/keycodes/keyboard_codes.h"
namespace ui {
class Accelerator;
// Create MediaKeyListener to receive accelerators on media keys.
class UI_BASE_EXPORT MediaKeysListener {
enum class Scope {
kGlobal, // Listener works whenever application in focus or not.
kFocused, // Listener only works whan application has focus.
// Media keys accelerators receiver.
class UI_BASE_EXPORT Delegate {
virtual ~Delegate();
// Called on media key event.
virtual void OnMediaKeysAccelerator(const Accelerator& accelerator) = 0;
// Can return nullptr if media keys listening is not implemented.
// Currently implemented only on mac.
static std::unique_ptr<MediaKeysListener> Create(Delegate* delegate,
Scope scope);
static bool IsMediaKeycode(KeyboardCode key_code);
virtual ~MediaKeysListener();
// Start listening for a given media key.
virtual void StartWatchingMediaKey(KeyboardCode key_code) = 0;
// Stop listening for a given media key.
virtual void StopWatchingMediaKey(KeyboardCode key_code) = 0;
} // namespace ui