system_media_controls_mac.mm 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/system_media_controls/mac/system_media_controls_mac.h"
  5. namespace system_media_controls {
  6. // static
  7. std::unique_ptr<SystemMediaControls> SystemMediaControls::Create(
  8. const std::string& product_name) {
  9. // The required APIs for interacting with the Now Playing Info Center only
  10. // exist on 10.13.1 or later.
  11. if (@available(macOS 10.13.1, *))
  12. return std::make_unique<internal::SystemMediaControlsMac>();
  13. return nullptr;
  14. }
  15. namespace internal {
  16. SystemMediaControlsMac::SystemMediaControlsMac() = default;
  17. SystemMediaControlsMac::~SystemMediaControlsMac() = default;
  18. void SystemMediaControlsMac::AddObserver(
  19. SystemMediaControlsObserver* observer) {
  20. remote_command_center_delegate_.AddObserver(observer);
  21. }
  22. void SystemMediaControlsMac::RemoveObserver(
  23. SystemMediaControlsObserver* observer) {
  24. remote_command_center_delegate_.RemoveObserver(observer);
  25. }
  26. void SystemMediaControlsMac::SetIsNextEnabled(bool value) {
  27. remote_command_center_delegate_.SetIsNextEnabled(value);
  28. }
  29. void SystemMediaControlsMac::SetIsPreviousEnabled(bool value) {
  30. remote_command_center_delegate_.SetIsPreviousEnabled(value);
  31. }
  32. void SystemMediaControlsMac::SetIsPlayPauseEnabled(bool value) {
  33. remote_command_center_delegate_.SetIsPlayPauseEnabled(value);
  34. }
  35. void SystemMediaControlsMac::SetIsStopEnabled(bool value) {
  36. remote_command_center_delegate_.SetIsStopEnabled(value);
  37. }
  38. void SystemMediaControlsMac::SetIsSeekToEnabled(bool value) {
  39. remote_command_center_delegate_.SetIsSeekToEnabled(value);
  40. }
  41. void SystemMediaControlsMac::SetPlaybackStatus(PlaybackStatus status) {
  42. now_playing_info_center_delegate_.SetPlaybackStatus(status);
  43. }
  44. void SystemMediaControlsMac::SetTitle(const std::u16string& title) {
  45. now_playing_info_center_delegate_.SetTitle(title);
  46. }
  47. void SystemMediaControlsMac::SetArtist(const std::u16string& artist) {
  48. now_playing_info_center_delegate_.SetArtist(artist);
  49. }
  50. void SystemMediaControlsMac::SetAlbum(const std::u16string& album) {
  51. now_playing_info_center_delegate_.SetAlbum(album);
  52. }
  53. void SystemMediaControlsMac::SetThumbnail(const SkBitmap& bitmap) {
  54. now_playing_info_center_delegate_.SetThumbnail(bitmap);
  55. }
  56. void SystemMediaControlsMac::SetPosition(
  57. const media_session::MediaPosition& position) {
  58. now_playing_info_center_delegate_.SetPosition(position);
  59. }
  60. void SystemMediaControlsMac::ClearMetadata() {
  61. now_playing_info_center_delegate_.ClearMetadata();
  62. }
  63. } // namespace internal
  64. } // namespace system_media_controls