Commit 058e3d26 authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

Allow Auto Picture-in-Picture for Chrome extensions

Change-Id: I81252edcac31490248001c59623b1da220136451
Reviewed-on: https://chromium-review.googlesource.com/c/1480455
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634844}
parent 90ffaeaa
......@@ -249,18 +249,27 @@ HTMLVideoElement* PictureInPictureControllerImpl::AutoPictureInPictureElement()
: auto_picture_in_picture_elements_.back();
}
void PictureInPictureControllerImpl::PageVisibilityChanged() {
DCHECK(GetSupplementable());
bool PictureInPictureControllerImpl::IsAutoPictureInPictureAllowed() const {
// Chrome extensions are allowed to trigger Auto Picture-in-Picture.
if (GetSupplementable()->Url().ProtocolIs("chrome-extension"))
return true;
// Auto Picture-in-Picture is allowed only in a PWA window.
// Otherwise, Auto Picture-in-Picture is allowed only in a PWA window.
if (!GetSupplementable()->GetFrame() ||
GetSupplementable()->GetFrame()->View()->DisplayMode() ==
WebDisplayMode::kWebDisplayModeBrowser) {
return;
return false;
}
// Auto Picture-in-Picture is allowed only in the scope of a PWA.
if (!GetSupplementable()->IsInWebAppScope())
// And if in a PWA window, Auto Picture-in-Picture is allowed only in the
// scope of the PWA.
return (GetSupplementable()->IsInWebAppScope());
}
void PictureInPictureControllerImpl::PageVisibilityChanged() {
DCHECK(GetSupplementable());
if (!IsAutoPictureInPictureAllowed())
return;
// If page becomes visible and Picture-in-Picture element has entered
......
......@@ -62,6 +62,11 @@ class MODULES_EXPORT PictureInPictureControllerImpl
// recently.
HTMLVideoElement* AutoPictureInPictureElement() const;
// Returns whether Auto Picture-in-Picture is allowed. It returns true if
// it's a Chrome extension or if is's a PWA window in its web app scope.
// Otherwise it returns false.
bool IsAutoPictureInPictureAllowed() const;
// Implementation of PictureInPictureController.
void EnterPictureInPicture(HTMLVideoElement*,
ScriptPromiseResolver*) override;
......
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