Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11249)

Unified Diff: content/browser/media/media_web_contents_observer.cc

Issue 1570043002: Implement MediaSession on top of the WebMediaPlayerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_session
Patch Set: Merge. Cleanup. Fix RequestPlay. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/media/media_web_contents_observer.cc
diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc
index 0591e25b73eaf5dcb8d5d1b5377f9708a6a38f77..e4f16d8223c320484f3f653fe3366c7c8bcd6c2f 100644
--- a/content/browser/media/media_web_contents_observer.cc
+++ b/content/browser/media/media_web_contents_observer.cc
@@ -41,6 +41,8 @@ bool MediaWebContentsObserver::OnMessageReceived(
// TODO(dalecurtis): These should no longer be FrameHostMsg.
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MediaWebContentsObserver, msg,
render_frame_host)
+ IPC_MESSAGE_HANDLER(FrameHostMsg_MediaDestroyedNotification,
+ OnMediaDestroyedNotification)
IPC_MESSAGE_HANDLER(FrameHostMsg_MediaPlayingNotification,
OnMediaPlayingNotification)
IPC_MESSAGE_HANDLER(FrameHostMsg_MediaPausedNotification,
@@ -50,12 +52,32 @@ bool MediaWebContentsObserver::OnMessageReceived(
return handled;
}
+void MediaWebContentsObserver::WasShown() {
+ // Restore power save blocker if there are active video players running.
+ if (!active_video_players_.empty() && !video_power_save_blocker_)
+ CreateVideoPowerSaveBlocker();
+}
+
+void MediaWebContentsObserver::WasHidden() {
+ // If there are entities capturing screenshots or video (e.g., mirroring),
+ // don't release the power save blocker.
+ if (!web_contents()->GetCapturerCount())
+ video_power_save_blocker_.reset();
+}
+
+void MediaWebContentsObserver::OnMediaDestroyedNotification(
+ RenderFrameHost* render_frame_host,
+ int64_t player_cookie) {
+ OnMediaPausedNotification(render_frame_host, player_cookie, true);
+}
+
void MediaWebContentsObserver::OnMediaPlayingNotification(
RenderFrameHost* render_frame_host,
int64_t player_cookie,
bool has_video,
bool has_audio,
- bool is_remote) {
+ bool is_remote,
+ base::TimeDelta duration) {
// Ignore the videos playing remotely and don't hold the wake lock for the
// screen. TODO(dalecurtis): Is this correct? It means observers will not
// receive play and pause messages.
@@ -91,7 +113,8 @@ void MediaWebContentsObserver::OnMediaPlayingNotification(
void MediaWebContentsObserver::OnMediaPausedNotification(
RenderFrameHost* render_frame_host,
- int64_t player_cookie) {
+ int64_t player_cookie,
+ bool reached_end_of_stream) {
const MediaPlayerId id(render_frame_host, player_cookie);
const bool removed_audio = RemoveMediaPlayerEntry(id, &active_audio_players_);
const bool removed_video = RemoveMediaPlayerEntry(id, &active_video_players_);
@@ -138,19 +161,6 @@ void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() {
#endif
}
-void MediaWebContentsObserver::WasShown() {
- // Restore power save blocker if there are active video players running.
- if (!active_video_players_.empty() && !video_power_save_blocker_)
- CreateVideoPowerSaveBlocker();
-}
-
-void MediaWebContentsObserver::WasHidden() {
- // If there are entities capturing screenshots or video (e.g., mirroring),
- // don't release the power save blocker.
- if (!web_contents()->GetCapturerCount())
- video_power_save_blocker_.reset();
-}
-
void MediaWebContentsObserver::MaybeReleasePowerSaveBlockers() {
// If there are no more audio players and we don't have audio stream
// monitoring, release the audio power save blocker here instead of during

Powered by Google App Engine
This is Rietveld 408576698