Chromium Code Reviews| 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> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 // forwards them to the corresponding managers. The managers are responsible | 35 // forwards them to the corresponding managers. The managers are responsible |
| 36 // for sending IPCs back to the RenderFrameObservers at the render side. | 36 // for sending IPCs back to the RenderFrameObservers at the render side. |
| 37 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { | 37 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { |
| 38 public: | 38 public: |
| 39 explicit MediaWebContentsObserver(WebContents* web_contents); | 39 explicit MediaWebContentsObserver(WebContents* web_contents); |
| 40 ~MediaWebContentsObserver() override; | 40 ~MediaWebContentsObserver() override; |
| 41 | 41 |
| 42 // Called by WebContentsImpl when the audible state may have changed. | 42 // Called by WebContentsImpl when the audible state may have changed. |
| 43 void MaybeUpdateAudibleState(); | 43 void MaybeUpdateAudibleState(); |
| 44 | 44 |
| 45 // Called by WebContentsImpl to know if an active player is currently | |
| 46 // fullscreen dominant. | |
| 47 // It should only be called while the WebContents is fullscreen. | |
| 48 bool HasActiveFullscreenDominantVideo() const; | |
|
liberato (no reviews please)
2017/02/14 23:00:01
naming is a little confusing.
personally, i'd go
mlamouri (slow - plz ping)
2017/02/17 16:36:24
Renamed to `HasActiveEffectivelyFullscreenVideo`.
| |
| 49 | |
| 45 // WebContentsObserver implementation. | 50 // WebContentsObserver implementation. |
| 46 void WebContentsDestroyed() override; | 51 void WebContentsDestroyed() override; |
| 47 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; | 52 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
| 48 bool OnMessageReceived(const IPC::Message& message, | 53 bool OnMessageReceived(const IPC::Message& message, |
| 49 RenderFrameHost* render_frame_host) override; | 54 RenderFrameHost* render_frame_host) override; |
| 50 void WasShown() override; | 55 void WasShown() override; |
| 51 void WasHidden() override; | 56 void WasHidden() override; |
| 52 | 57 |
| 53 bool has_audio_power_save_blocker_for_testing() const { | 58 bool has_audio_power_save_blocker_for_testing() const { |
| 54 return !!audio_power_save_blocker_; | 59 return !!audio_power_save_blocker_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 67 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); | 72 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); |
| 68 void OnMediaPaused(RenderFrameHost* render_frame_host, | 73 void OnMediaPaused(RenderFrameHost* render_frame_host, |
| 69 int delegate_id, | 74 int delegate_id, |
| 70 bool reached_end_of_stream); | 75 bool reached_end_of_stream); |
| 71 void OnMediaPlaying(RenderFrameHost* render_frame_host, | 76 void OnMediaPlaying(RenderFrameHost* render_frame_host, |
| 72 int delegate_id, | 77 int delegate_id, |
| 73 bool has_video, | 78 bool has_video, |
| 74 bool has_audio, | 79 bool has_audio, |
| 75 bool is_remote, | 80 bool is_remote, |
| 76 media::MediaContentType media_content_type); | 81 media::MediaContentType media_content_type); |
| 82 void OnMediaFullscreenChange(RenderFrameHost* render_frame_host, | |
| 83 int delegate_id, | |
| 84 bool is_fullscreen); | |
| 85 void OnMediaDominantChange(RenderFrameHost* render_frame_host, | |
| 86 int delegate_id, | |
| 87 bool is_dominant); | |
| 77 | 88 |
| 78 // Clear |render_frame_host|'s tracking entry for its power save blockers. | 89 // Clear |render_frame_host|'s tracking entry for its power save blockers. |
| 79 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); | 90 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); |
| 80 | 91 |
| 81 // Creates an audio or video power save blocker respectively. | 92 // Creates an audio or video power save blocker respectively. |
| 82 void CreateAudioPowerSaveBlocker(); | 93 void CreateAudioPowerSaveBlocker(); |
| 83 void CreateVideoPowerSaveBlocker(); | 94 void CreateVideoPowerSaveBlocker(); |
| 84 | 95 |
| 85 // Releases the audio power save blockers if |active_audio_players_| is empty. | 96 // Releases the audio power save blockers if |active_audio_players_| is empty. |
| 86 // Likewise, releases the video power save blockers if |active_video_players_| | 97 // Likewise, releases the video power save blockers if |active_video_players_| |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 100 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | 111 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, |
| 101 ActiveMediaPlayerMap* player_map, | 112 ActiveMediaPlayerMap* player_map, |
| 102 std::set<MediaPlayerId>* removed_players); | 113 std::set<MediaPlayerId>* removed_players); |
| 103 | 114 |
| 104 // Tracking variables and associated power save blockers for media playback. | 115 // Tracking variables and associated power save blockers for media playback. |
| 105 ActiveMediaPlayerMap active_audio_players_; | 116 ActiveMediaPlayerMap active_audio_players_; |
| 106 ActiveMediaPlayerMap active_video_players_; | 117 ActiveMediaPlayerMap active_video_players_; |
| 107 std::unique_ptr<device::PowerSaveBlocker> audio_power_save_blocker_; | 118 std::unique_ptr<device::PowerSaveBlocker> audio_power_save_blocker_; |
| 108 std::unique_ptr<device::PowerSaveBlocker> video_power_save_blocker_; | 119 std::unique_ptr<device::PowerSaveBlocker> video_power_save_blocker_; |
| 109 | 120 |
| 121 // FullscreenDominantInfo keeps track of whether a MediaPlayerId is fullscreen | |
| 122 // or dominant inside a fullscreen frame. | |
| 123 struct FullscreenDominantInfo { | |
| 124 FullscreenDominantInfo() = delete; | |
| 125 FullscreenDominantInfo(const FullscreenDominantInfo&) = default; | |
| 126 FullscreenDominantInfo& operator=(const FullscreenDominantInfo&) = default; | |
| 127 | |
| 128 FullscreenDominantInfo(bool fullscreen, bool dominant) | |
| 129 : fullscreen(fullscreen), dominant(dominant) {} | |
| 130 | |
| 131 bool fullscreen = false; | |
| 132 bool dominant = false; | |
| 133 }; | |
| 134 | |
| 135 // If the |MediaPlayerId| is set to |{ nullptr, 0 }|, |FullscreenDominantInfo| | |
| 136 // should be ignored. | |
| 137 std::pair<MediaPlayerId, FullscreenDominantInfo> fullscreen_dominant_video_ = | |
|
liberato (no reviews please)
2017/02/14 23:00:01
nit: perhaps move MediaPlayerId into FullscreenDom
mlamouri (slow - plz ping)
2017/02/17 16:36:24
I switched to base::Optional<MediaPlayerId>. Shoul
| |
| 138 {{nullptr, 0}, FullscreenDominantInfo(false, false)}; | |
| 139 | |
| 110 MediaSessionControllersManager session_controllers_manager_; | 140 MediaSessionControllersManager session_controllers_manager_; |
| 111 | 141 |
| 112 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); | 142 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); |
| 113 }; | 143 }; |
| 114 | 144 |
| 115 } // namespace content | 145 } // namespace content |
| 116 | 146 |
| 117 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 147 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |