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

Unified Diff: content/renderer/media/renderer_webmediaplayer_delegate.cc

Issue 2681863005: [Video] MediaSession API event handlers can resume background video. (Closed)
Patch Set: Restore permanent 5s pause. Created 3 years, 10 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/renderer/media/renderer_webmediaplayer_delegate.cc
diff --git a/content/renderer/media/renderer_webmediaplayer_delegate.cc b/content/renderer/media/renderer_webmediaplayer_delegate.cc
index 92d1140e8a6c52c2500f4daa21383717f482f37d..ef851b37229cdcf33678719062870473785025e5 100644
--- a/content/renderer/media/renderer_webmediaplayer_delegate.cc
+++ b/content/renderer/media/renderer_webmediaplayer_delegate.cc
@@ -98,6 +98,8 @@ void RendererWebMediaPlayerDelegate::DidPlay(
playing_videos_.insert(player_id);
has_played_video_ = true;
}
+ if (has_video && IsFrameHidden() && !IsFrameClosed())
sandersd (OOO until July 31) 2017/02/13 22:56:20 Duplicate |has_video| condition.
whywhat 2017/02/15 17:13:12 Done.
+ background_video_allowed_ = true;
} else {
playing_videos_.erase(player_id);
}
@@ -112,6 +114,10 @@ void RendererWebMediaPlayerDelegate::DidPlay(
void RendererWebMediaPlayerDelegate::DidPause(int player_id) {
DVLOG(2) << __func__ << "(" << player_id << ")";
DCHECK(id_map_.Lookup(player_id));
+
+ if (playing_videos_.count(player_id) && IsFrameHidden() && !IsFrameClosed())
DaleCurtis 2017/02/13 22:44:54 Hmm, is this right? Can you add some comments abou
whywhat 2017/02/14 01:36:28 This is consistent with the user pressing on the p
whywhat 2017/02/15 17:13:12 Added a user gesture check to that so we won't blo
+ background_video_allowed_ = false;
sandersd (OOO until July 31) 2017/02/13 22:56:20 This can leave us in a strange state where there i
whywhat 2017/02/14 01:36:28 Hm, how? This is called when video is being paused
sandersd (OOO until July 31) 2017/02/14 01:39:39 There can be more than one playing video on a page
whywhat 2017/02/15 17:13:12 This is already the case with OnMediaDelegatePause
sandersd (OOO until July 31) 2017/02/15 21:54:08 There is a difference, though; OnMediaDelegatePaus
+
playing_videos_.erase(player_id);
Send(new MediaPlayerDelegateHostMsg_OnMediaPaused(routing_id(), player_id,
false));

Powered by Google App Engine
This is Rietveld 408576698