| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "content/browser/media/session/media_session_controllers_manager.h" | 15 #include "content/browser/media/session/media_session_controllers_manager.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" | 18 #include "device/wake_lock/public/interfaces/wake_lock.mojom.h" |
| 19 | 19 |
| 20 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 21 #include "ui/android/view_android.h" | 21 #include "ui/android/view_android.h" |
| 22 #endif // OS_ANDROID | 22 #endif // OS_ANDROID |
| 23 | 23 |
| 24 namespace media { | 24 namespace media { |
| 25 enum class MediaContentType; | 25 enum class MediaContentType; |
| 26 } // namespace media | 26 } // namespace media |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bool has_audio, | 84 bool has_audio, |
| 85 bool is_remote, | 85 bool is_remote, |
| 86 media::MediaContentType media_content_type); | 86 media::MediaContentType media_content_type); |
| 87 void OnMediaEffectivelyFullscreenChange(RenderFrameHost* render_frame_host, | 87 void OnMediaEffectivelyFullscreenChange(RenderFrameHost* render_frame_host, |
| 88 int delegate_id, | 88 int delegate_id, |
| 89 bool is_fullscreen); | 89 bool is_fullscreen); |
| 90 | 90 |
| 91 // Clear |render_frame_host|'s tracking entry for its WakeLocks. | 91 // Clear |render_frame_host|'s tracking entry for its WakeLocks. |
| 92 void ClearWakeLocks(RenderFrameHost* render_frame_host); | 92 void ClearWakeLocks(RenderFrameHost* render_frame_host); |
| 93 | 93 |
| 94 device::mojom::WakeLockService* GetAudioWakeLock(); | 94 device::mojom::WakeLock* GetAudioWakeLock(); |
| 95 device::mojom::WakeLockService* GetVideoWakeLock(); | 95 device::mojom::WakeLock* GetVideoWakeLock(); |
| 96 | 96 |
| 97 void LockAudio(); | 97 void LockAudio(); |
| 98 void LockVideo(); | 98 void LockVideo(); |
| 99 | 99 |
| 100 void CancelAudioLock(); | 100 void CancelAudioLock(); |
| 101 void CancelVideoLock(); | 101 void CancelVideoLock(); |
| 102 void MaybeCancelVideoLock(); | 102 void MaybeCancelVideoLock(); |
| 103 | 103 |
| 104 // Helper methods for adding or removing player entries in |player_map|. | 104 // Helper methods for adding or removing player entries in |player_map|. |
| 105 using PlayerSet = std::set<int>; | 105 using PlayerSet = std::set<int>; |
| 106 using ActiveMediaPlayerMap = std::map<RenderFrameHost*, PlayerSet>; | 106 using ActiveMediaPlayerMap = std::map<RenderFrameHost*, PlayerSet>; |
| 107 void AddMediaPlayerEntry(const MediaPlayerId& id, | 107 void AddMediaPlayerEntry(const MediaPlayerId& id, |
| 108 ActiveMediaPlayerMap* player_map); | 108 ActiveMediaPlayerMap* player_map); |
| 109 // Returns true if an entry is actually removed. | 109 // Returns true if an entry is actually removed. |
| 110 bool RemoveMediaPlayerEntry(const MediaPlayerId& id, | 110 bool RemoveMediaPlayerEntry(const MediaPlayerId& id, |
| 111 ActiveMediaPlayerMap* player_map); | 111 ActiveMediaPlayerMap* player_map); |
| 112 // Removes all entries from |player_map| for |render_frame_host|. Removed | 112 // Removes all entries from |player_map| for |render_frame_host|. Removed |
| 113 // entries are added to |removed_players|. | 113 // entries are added to |removed_players|. |
| 114 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | 114 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, |
| 115 ActiveMediaPlayerMap* player_map, | 115 ActiveMediaPlayerMap* player_map, |
| 116 std::set<MediaPlayerId>* removed_players); | 116 std::set<MediaPlayerId>* removed_players); |
| 117 | 117 |
| 118 // Tracking variables and associated wake locks for media playback. | 118 // Tracking variables and associated wake locks for media playback. |
| 119 ActiveMediaPlayerMap active_audio_players_; | 119 ActiveMediaPlayerMap active_audio_players_; |
| 120 ActiveMediaPlayerMap active_video_players_; | 120 ActiveMediaPlayerMap active_video_players_; |
| 121 device::mojom::WakeLockServicePtr audio_wake_lock_; | 121 device::mojom::WakeLockPtr audio_wake_lock_; |
| 122 device::mojom::WakeLockServicePtr video_wake_lock_; | 122 device::mojom::WakeLockPtr video_wake_lock_; |
| 123 base::Optional<MediaPlayerId> fullscreen_player_; | 123 base::Optional<MediaPlayerId> fullscreen_player_; |
| 124 bool has_audio_wake_lock_for_testing_; | 124 bool has_audio_wake_lock_for_testing_; |
| 125 bool has_video_wake_lock_for_testing_; | 125 bool has_video_wake_lock_for_testing_; |
| 126 | 126 |
| 127 MediaSessionControllersManager session_controllers_manager_; | 127 MediaSessionControllersManager session_controllers_manager_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); | 129 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 } // namespace content | 132 } // namespace content |
| 133 | 133 |
| 134 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 134 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |