#include "third_party/blink/renderer/modules/document_picture_in_picture/picture_in_picture_controller_impl.h"
#include <limits>
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/task/single_thread_task_runner.h"
#include "media/mojo/mojom/media_player.mojom-blink.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/blink/public/common/media/display_type.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/layout/layout_video.h"
#include "third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_event.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#if !BUILDFLAG(TARGET_OS_IS_ANDROID)
#include "third_party/blink/public/web/web_picture_in_picture_window_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_document_picture_in_picture_options.h"
#include "third_party/blink/renderer/modules/document_picture_in_picture/document_picture_in_picture.h"
#include "third_party/blink/renderer/modules/document_picture_in_picture/document_picture_in_picture_event.h"
#endif
namespace blink {
namespace {
bool ShouldShowPlayPauseButton(const HTMLVideoElement& element) { … }
}
PictureInPictureControllerImpl& PictureInPictureControllerImpl::From(
Document& document) { … }
bool PictureInPictureControllerImpl::PictureInPictureEnabled() const { … }
PictureInPictureController::Status
PictureInPictureControllerImpl::IsDocumentAllowed(bool report_failure) const { … }
PictureInPictureController::Status
PictureInPictureControllerImpl::IsElementAllowed(
const HTMLVideoElement& video_element,
bool report_failure) const { … }
void PictureInPictureControllerImpl::EnterPictureInPicture(
HTMLVideoElement* video_element,
ScriptPromiseResolver<PictureInPictureWindow>* resolver) { … }
void PictureInPictureControllerImpl::OnEnteredPictureInPicture(
HTMLVideoElement* element,
ScriptPromiseResolver<PictureInPictureWindow>* resolver,
mojo::PendingRemote<mojom::blink::PictureInPictureSession> session_remote,
const gfx::Size& picture_in_picture_window_size) { … }
void PictureInPictureControllerImpl::ExitPictureInPicture(
HTMLVideoElement* element,
ScriptPromiseResolver<IDLUndefined>* resolver) { … }
void PictureInPictureControllerImpl::OnExitedPictureInPicture(
ScriptPromiseResolver<IDLUndefined>* resolver) { … }
PictureInPictureWindow* PictureInPictureControllerImpl::pictureInPictureWindow()
const { … }
Element* PictureInPictureControllerImpl::PictureInPictureElement() const { … }
Element* PictureInPictureControllerImpl::PictureInPictureElement(
TreeScope& scope) const { … }
bool PictureInPictureControllerImpl::IsPictureInPictureElement(
const Element* element) const { … }
#if !BUILDFLAG(TARGET_OS_IS_ANDROID)
LocalDOMWindow* PictureInPictureControllerImpl::documentPictureInPictureWindow()
const { … }
LocalDOMWindow*
PictureInPictureControllerImpl::GetDocumentPictureInPictureWindow() const { … }
LocalDOMWindow*
PictureInPictureControllerImpl::GetDocumentPictureInPictureOwner() const { … }
void PictureInPictureControllerImpl::SetDocumentPictureInPictureOwner(
LocalDOMWindow* owner) { … }
void PictureInPictureControllerImpl::CreateDocumentPictureInPictureWindow(
ScriptState* script_state,
LocalDOMWindow& opener,
DocumentPictureInPictureOptions* options,
ScriptPromiseResolver<DOMWindow>* resolver) { … }
void PictureInPictureControllerImpl::ResolveOpenDocumentPictureInPicture() { … }
PictureInPictureControllerImpl::DocumentPictureInPictureObserver::
DocumentPictureInPictureObserver(PictureInPictureControllerImpl* controller)
: … { … }
PictureInPictureControllerImpl::DocumentPictureInPictureObserver::
~DocumentPictureInPictureObserver() = default;
void PictureInPictureControllerImpl::DocumentPictureInPictureObserver::
ContextDestroyed() { … }
void PictureInPictureControllerImpl::DocumentPictureInPictureObserver::Trace(
Visitor* visitor) const { … }
void PictureInPictureControllerImpl::
OnDocumentPictureInPictureContextDestroyed() { … }
void PictureInPictureControllerImpl::
OnOwnedDocumentPictureInPictureWindowContextDestroyed() { … }
void PictureInPictureControllerImpl::
OnDocumentPictureInPictureOwnerWindowContextDestroyed() { … }
#endif
void PictureInPictureControllerImpl::OnPictureInPictureStateChange() { … }
void PictureInPictureControllerImpl::OnWindowSizeChanged(
const gfx::Size& size) { … }
void PictureInPictureControllerImpl::OnStopped() { … }
void PictureInPictureControllerImpl::SetMayThrottleIfUndrawnFrames(
bool may_throttle) { … }
void PictureInPictureControllerImpl::Trace(Visitor* visitor) const { … }
PictureInPictureControllerImpl::PictureInPictureControllerImpl(
Document& document)
: … { … }
bool PictureInPictureControllerImpl::EnsureService() { … }
}