chromium/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"

#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_bounds_cache.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "content/public/browser/document_picture_in_picture_window_controller.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/picture_in_picture_window_controller.h"
#include "content/public/browser/video_picture_in_picture_window_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/url_constants.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/resize_utils.h"
#include "ui/gfx/geometry/size.h"
#if !BUILDFLAG(IS_ANDROID)
#include "base/metrics/histogram_functions.h"
#include "base/numerics/checked_math.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/picture_in_picture/auto_picture_in_picture_tab_helper.h"
#include "media/base/media_switches.h"
#include "net/base/url_util.h"
#include "third_party/blink/public/common/features.h"
#include "ui/views/view.h"
#endif  // !BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/common/constants.h"
#endif  // BUILDFLAG(ENABLE_EXTENSIONS)

namespace {
// The initial aspect ratio for Document Picture-in-Picture windows. This does
// not apply to video Picture-in-Picture windows.
constexpr double kInitialAspectRatio =;

// The minimum window size for Document Picture-in-Picture windows. This does
// not apply to video Picture-in-Picture windows.
constexpr gfx::Size kMinWindowSize(240, 52);

// The maximum window size for Document Picture-in-Picture windows. This does
// not apply to video Picture-in-Picture windows.
constexpr double kMaxWindowSizeRatio =;

#if !BUILDFLAG(IS_ANDROID)
// Returns true if a document picture-in-picture window should be focused upon
// opening it.
bool ShouldFocusPictureInPictureWindow(const NavigateParams& params) {}
#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace

// This web contents observer is used only for video PiP.
class PictureInPictureWindowManager::VideoWebContentsObserver final
    : public content::WebContentsObserver {};

#if !BUILDFLAG(IS_ANDROID)
// This web contents observer is used only for document PiP.
class PictureInPictureWindowManager::DocumentWebContentsObserver final
    : public content::WebContentsObserver {};
#endif  // !BUILDFLAG(IS_ANDROID)

PictureInPictureWindowManager* PictureInPictureWindowManager::GetInstance() {}

void PictureInPictureWindowManager::EnterPictureInPictureWithController(
    content::PictureInPictureWindowController* pip_window_controller) {}

#if !BUILDFLAG(IS_ANDROID)
void PictureInPictureWindowManager::EnterDocumentPictureInPicture(
    content::WebContents* parent_web_contents,
    content::WebContents* child_web_contents) {}
#endif  // !BUILDFLAG(IS_ANDROID)

content::PictureInPictureResult
PictureInPictureWindowManager::EnterVideoPictureInPicture(
    content::WebContents* web_contents) {}

bool PictureInPictureWindowManager::ExitPictureInPictureViaWindowUi(
    UiBehavior behavior) {}

bool PictureInPictureWindowManager::ExitPictureInPicture() {}

// static
void PictureInPictureWindowManager::ExitPictureInPictureSoon() {}

void PictureInPictureWindowManager::FocusInitiator() {}

content::WebContents* PictureInPictureWindowManager::GetWebContents() const {}

content::WebContents* PictureInPictureWindowManager::GetChildWebContents()
    const {}

// static
bool PictureInPictureWindowManager::IsChildWebContents(
    content::WebContents* wc) {}

std::optional<gfx::Rect>
PictureInPictureWindowManager::GetPictureInPictureWindowBounds() const {}

gfx::Rect PictureInPictureWindowManager::CalculateOuterWindowBounds(
    const blink::mojom::PictureInPictureWindowOptions& pip_options,
    const display::Display& display,
    const gfx::Size& minimum_outer_window_size,
    const gfx::Size& excluded_margin) {}

gfx::Rect
PictureInPictureWindowManager::CalculateInitialPictureInPictureWindowBounds(
    const blink::mojom::PictureInPictureWindowOptions& pip_options,
    const display::Display& display) {}

void PictureInPictureWindowManager::UpdateCachedBounds(
    const gfx::Rect& most_recent_bounds) {}

// static
gfx::Size PictureInPictureWindowManager::GetMinimumInnerWindowSize() {}

// static
gfx::Size PictureInPictureWindowManager::GetMaximumWindowSize(
    const display::Display& display) {}

// static
void PictureInPictureWindowManager::SetWindowParams(NavigateParams& params) {}

// static
bool PictureInPictureWindowManager::IsSupportedForDocumentPictureInPicture(
    const GURL& url) {}

void PictureInPictureWindowManager::CreateWindowInternal(
    content::WebContents* web_contents) {}

void PictureInPictureWindowManager::CloseWindowInternal() {}

#if !BUILDFLAG(IS_ANDROID)
void PictureInPictureWindowManager::DocumentWebContentsDestroyed() {}

std::unique_ptr<AutoPipSettingOverlayView>
PictureInPictureWindowManager::GetOverlayView(
    const gfx::Rect& browser_view_overridden_bounds,
    views::View* anchor_view,
    views::BubbleBorder::Arrow arrow) {}

PictureInPictureOcclusionTracker*
PictureInPictureWindowManager::GetOcclusionTracker() {}

void PictureInPictureWindowManager::CreateOcclusionTrackerIfNecessary() {}

void PictureInPictureWindowManager::OnFileDialogOpened() {}

void PictureInPictureWindowManager::OnFileDialogClosed() {}

void PictureInPictureWindowManager::
    RecordDocumentPictureInPictureRequestedSizeMetrics(
        const blink::mojom::PictureInPictureWindowOptions& pip_options,
        const display::Display& display) {}

void PictureInPictureWindowManager::RecordFileDialogOpenMetric(
    FileDialogOpenState state) {}

#endif  // !BUILDFLAG(IS_ANDROID)

void PictureInPictureWindowManager::NotifyObserversOnEnterPictureInPicture() {}

PictureInPictureWindowManager::PictureInPictureWindowManager() = default;

PictureInPictureWindowManager::~PictureInPictureWindowManager() = default;