Commit 5cd9a7e3 authored by Jennifer Apacible's avatar Jennifer Apacible Committed by Commit Bot

[Picture in Picture] Handle ending Picture-in-Picture from user gesture.

This consolidates some of the similar exit-Picture-in-Picture behavior
from both WebMediaPlayerImpl and PictureInPictureWindowController sides.

When exiting from WMPI, we need to run an additional callback to signal
that the window should be closed. From user gesture, the window tear
down has already been handled.

BUG: 823172
Change-Id: I4ee6e03a519a7564f7eb8b195f2dc7ddeacf4a88
Reviewed-on: https://chromium-review.googlesource.com/1012521
Commit-Queue: apacible <apacible@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551224}
parent 2135671f
......@@ -791,24 +791,16 @@ void WebMediaPlayerImpl::EnterPictureInPicture() {
}
void WebMediaPlayerImpl::ExitPictureInPicture() {
// TODO(apacible): Handle ending PiP from a user gesture. This currently
// handles ending Picture-in-Picture mode from the source.
// https://crbug.com/823172.
// Do not clear |pip_surface_id_| in case we enter Picture-in-Picture mode
// again.
if (!pip_surface_id_.is_valid())
return;
// Signals that Picture-in-Picture has ended.
exit_pip_cb_.Run();
// Updates the MediaWebContentsObserver with |delegate_id_| to clear the
// tracked media player that is in Picture-in-Picture mode.
delegate_->DidPictureInPictureModeEnd(delegate_id_);
OnPictureInPictureModeEnded();
if (client_)
client_->PictureInPictureStopped();
// Signals that Picture-in-Picture has ended. This lets the
// PictureInPictureWindowController know the window should be closed.
exit_pip_cb_.Run();
}
void WebMediaPlayerImpl::SetSinkId(
......@@ -2070,9 +2062,18 @@ void WebMediaPlayerImpl::OnBecamePersistentVideo(bool value) {
}
void WebMediaPlayerImpl::OnPictureInPictureModeEnded() {
// TODO(apacible): Converge with exiting Picture-in-Picture mode from
// wmpi side. https://crbug.com/823172.
NOTIMPLEMENTED();
// This should never be called if |pip_surface_id_| is invalid. This is either
// called from the Picture-in-Picture window side by a user gesture to end
// Picture-in-Picture mode, or in ExitPictureInPicture(), which already checks
// for validity.
DCHECK(pip_surface_id_.is_valid());
// Updates the MediaWebContentsObserver with |delegate_id_| to clear the
// tracked media player that is in Picture-in-Picture mode.
delegate_->DidPictureInPictureModeEnd(delegate_id_);
if (client_)
client_->PictureInPictureStopped();
}
void WebMediaPlayerImpl::ScheduleRestart() {
......
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