123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: deepak1556 <[email protected]>
- Date: Wed, 30 Aug 2023 15:56:53 +0900
- Subject: fix: move AutoPipSettingsHelper behind branding buildflag
- The class was added in https://chromium-review.googlesource.com/c/chromium/src/+/4688277
- which is primarily used for providing an overlay view in a PIP window
- to support content settings UI. The support pulls in chrome content settings
- and UI code which are not valid in the scope of Electron.
- diff --git a/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc b/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc
- index 297e37c11cc69025843b225a4ba8ae096e304915..6244f27cacbddeed4881463d07a2279083173a5b 100644
- --- a/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc
- +++ b/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc
- @@ -21,8 +21,10 @@
- #include "ui/gfx/geometry/size.h"
- #if !BUILDFLAG(IS_ANDROID)
- #include "base/task/sequenced_task_runner.h"
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- #include "chrome/browser/picture_in_picture/auto_picture_in_picture_tab_helper.h"
- #include "chrome/browser/picture_in_picture/auto_pip_setting_helper.h"
- +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
- #include "media/base/media_switches.h"
- #include "third_party/blink/public/common/features.h"
- #include "ui/views/view.h"
- @@ -38,7 +40,7 @@ constexpr gfx::Size kMinWindowSize(240, 52);
- // not apply to video Picture-in-Picture windows.
- constexpr double kMaxWindowSizeRatio = 0.8;
-
- -#if !BUILDFLAG(IS_ANDROID)
- +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // Returns true if a document picture-in-picture window should be focused upon
- // opening it.
- bool ShouldFocusPictureInPictureWindow(const NavigateParams& params) {
- @@ -170,7 +172,7 @@ bool PictureInPictureWindowManager::ExitPictureInPictureViaWindowUi(
- return false;
- }
-
- -#if !BUILDFLAG(IS_ANDROID)
- +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- if (auto_pip_setting_helper_) {
- auto_pip_setting_helper_->OnUserClosedWindow();
- }
- @@ -353,7 +355,7 @@ gfx::Size PictureInPictureWindowManager::GetMaximumWindowSize(
-
- // static
- void PictureInPictureWindowManager::SetWindowParams(NavigateParams& params) {
- -#if !BUILDFLAG(IS_ANDROID)
- +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // Always show document picture-in-picture in a new window. When this is
- // not opened via the AutoPictureInPictureTabHelper, focus the window.
- params.window_action = ShouldFocusPictureInPictureWindow(params)
- @@ -376,7 +378,7 @@ void PictureInPictureWindowManager::CloseWindowInternal() {
- video_web_contents_observer_.reset();
- pip_window_controller_->Close(false /* should_pause_video */);
- pip_window_controller_ = nullptr;
- -#if !BUILDFLAG(IS_ANDROID)
- +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- auto_pip_setting_helper_.reset();
- #endif // !BUILDFLAG(IS_ANDROID)
- }
- @@ -387,8 +389,10 @@ void PictureInPictureWindowManager::DocumentWebContentsDestroyed() {
- // contents, so we only need to forget the controller here when user closes
- // the parent web contents with the PiP window open.
- document_web_contents_observer_.reset();
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // `auto_pip_setting_helper_` depends on the opener's WebContents.
- auto_pip_setting_helper_.reset();
- +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
- if (pip_window_controller_)
- pip_window_controller_ = nullptr;
- }
- @@ -410,6 +414,7 @@ PictureInPictureWindowManager::GetOverlayView(
- return nullptr;
- }
-
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // It would be nice to create this in `EnterPictureInPicture*`, but detecting
- // auto-pip while pip is in the process of opening doesn't work.
- //
- @@ -440,6 +445,8 @@ PictureInPictureWindowManager::GetOverlayView(
- }
-
- return overlay_view;
- +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
- + return nullptr;
- }
-
- PictureInPictureOcclusionTracker*
- @@ -450,6 +457,7 @@ PictureInPictureWindowManager::GetOcclusionTracker() {
- #endif // !BUILDFLAG(IS_ANDROID)
-
- #if !BUILDFLAG(IS_ANDROID)
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- void PictureInPictureWindowManager::CreateAutoPipSettingHelperIfNeeded() {
- // Because we have to defer creating this until after the tab helper finds out
- // about pip, we don't care if there's already a helper. Just use it.
- @@ -479,6 +487,7 @@ void PictureInPictureWindowManager::CreateAutoPipSettingHelperIfNeeded() {
- web_contents,
- base::BindOnce(&PictureInPictureWindowManager::ExitPictureInPictureSoon));
- }
- +#endif
-
- void PictureInPictureWindowManager::CreateOcclusionTrackerIfNecessary() {
- if (occlusion_tracker_) {
- diff --git a/chrome/browser/picture_in_picture/picture_in_picture_window_manager.h b/chrome/browser/picture_in_picture/picture_in_picture_window_manager.h
- index 5b3deb74d3e1cceebfd86a8f4bacf81a10967ade..8ca4f8d8fd6353177ae203e3c4c0810a11640b7c 100644
- --- a/chrome/browser/picture_in_picture/picture_in_picture_window_manager.h
- +++ b/chrome/browser/picture_in_picture/picture_in_picture_window_manager.h
- @@ -11,6 +11,7 @@
- #include "base/memory/singleton.h"
- #include "base/observer_list.h"
- #include "base/observer_list_types.h"
- +#include "build/branding_buildflags.h"
- #include "build/build_config.h"
- #include "third_party/abseil-cpp/absl/types/optional.h"
- #include "third_party/blink/public/mojom/picture_in_picture_window_options/picture_in_picture_window_options.mojom.h"
- @@ -32,7 +33,9 @@ class Display;
- } // namespace display
-
- #if !BUILDFLAG(IS_ANDROID)
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- class AutoPipSettingHelper;
- +#endif
- class PictureInPictureOcclusionTracker;
-
- namespace views {
- @@ -179,10 +182,11 @@ class PictureInPictureWindowManager {
- const gfx::Rect& browser_view_overridden_bounds,
- views::View* anchor_view,
- views::BubbleBorder::Arrow arrow);
- -
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- AutoPipSettingHelper* get_setting_helper_for_testing() {
- return auto_pip_setting_helper_.get();
- }
- +#endif
-
- // Returns the PictureInPictureOcclusionTracker, which can inform observers
- // when a widget has been occluded by a video or document picture-in-picture
- @@ -238,8 +242,10 @@ class PictureInPictureWindowManager {
- static void ExitPictureInPictureSoon();
-
- #if !BUILDFLAG(IS_ANDROID)
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // Create the settings helper if this is auto-pip and we don't have one.
- void CreateAutoPipSettingHelperIfNeeded();
- +#endif
-
- // Creates the `occlusion_tracker_` if it does not already exist and should
- // exist.
- @@ -256,7 +262,9 @@ class PictureInPictureWindowManager {
- #if !BUILDFLAG(IS_ANDROID)
- std::unique_ptr<DocumentWebContentsObserver> document_web_contents_observer_;
-
- +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- std::unique_ptr<AutoPipSettingHelper> auto_pip_setting_helper_;
- +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
-
- std::unique_ptr<PictureInPictureOcclusionTracker> occlusion_tracker_;
- #endif //! BUILDFLAG(IS_ANDROID)
- diff --git a/chrome/browser/ui/views/overlay/video_overlay_window_views.cc b/chrome/browser/ui/views/overlay/video_overlay_window_views.cc
- index b3419d2bb60ab0488fc0413843c33b5a926fee09..059754d92621ada9100e739ee6b5db01ae9ea75f 100644
- --- a/chrome/browser/ui/views/overlay/video_overlay_window_views.cc
- +++ b/chrome/browser/ui/views/overlay/video_overlay_window_views.cc
- @@ -314,11 +314,13 @@ std::unique_ptr<VideoOverlayWindowViews> VideoOverlayWindowViews::Create(
- }
- #endif // BUILDFLAG(IS_WIN)
-
- +#if 0
- PictureInPictureOcclusionTracker* tracker =
- PictureInPictureWindowManager::GetInstance()->GetOcclusionTracker();
- if (tracker) {
- tracker->OnPictureInPictureWidgetOpened(overlay_window.get());
- }
- +#endif
-
- return overlay_window;
- }
|