Commit b5ec5693 authored by Jennifer Apacible's avatar Jennifer Apacible Committed by Commit Bot

[Picture in Picture] Don't reset PiP ID when media is destroyed.

Currently, we reset the media ID associated with Picture-in-Picture
when OnMediaDestroyed is called, which includes when the video stops
playing. This causes crashes when we attempt to control the video from
the Picture-in-Picture window, such as play/pause and close.

This also means that even if we leave Picture-in-Picture mode, the
video media player will still show the Picture-in-Picture interstitial
because the WebMediaPlayer isn't updated with the fact we've left
Picture-in-Picture mode.

It is okay to keep the id around; when another video is PiP'd, the ID
will be updated.

BUG: 726619
Change-Id: I0e665047b85f20bc7bb9795273a5640460e7612f
Reviewed-on: https://chromium-review.googlesource.com/1026974Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: apacible <apacible@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553723}
parent 9bf035eb
......@@ -188,11 +188,6 @@ void MediaWebContentsObserver::OnMediaDestroyed(
RenderFrameHost* render_frame_host,
int delegate_id) {
OnMediaPaused(render_frame_host, delegate_id, true);
if (pip_player_ &&
pip_player_ == MediaPlayerId(render_frame_host, delegate_id)) {
pip_player_.reset();
}
}
void MediaWebContentsObserver::OnMediaPaused(RenderFrameHost* render_frame_host,
......
......@@ -3525,11 +3525,12 @@ TEST_F(WebContentsImplTest, PictureInPictureMediaPlayerIdWasChanged) {
EXPECT_EQ(kPlayerVideoOnlyId,
observer->GetPictureInPictureVideoMediaPlayerId()->second);
// Picture-in-Picture media player id should be reset when the media is
// destroyed.
// Picture-in-Picture media player id should not be reset when the media is
// destroyed (e.g. video stops playing). This allows the Picture-in-Picture
// window to continue to control the media.
rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaDestroyed(
rfh->GetRoutingID(), kPlayerVideoOnlyId));
EXPECT_FALSE(observer->GetPictureInPictureVideoMediaPlayerId().has_value());
EXPECT_TRUE(observer->GetPictureInPictureVideoMediaPlayerId().has_value());
}
TEST_F(WebContentsImplTest, ParseDownloadHeaders) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment