fix_move_autopipsettingshelper_behind_branding_buildflag.patch 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: deepak1556 <[email protected]>
  3. Date: Wed, 30 Aug 2023 15:56:53 +0900
  4. Subject: fix: move AutoPipSettingsHelper behind branding buildflag
  5. The class was added in https://chromium-review.googlesource.com/c/chromium/src/+/4688277
  6. which is primarily used for providing an overlay view in a PIP window
  7. to support content settings UI. The support pulls in chrome content settings
  8. and UI code which are not valid in the scope of Electron.
  9. 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
  10. index ea4646388c4747438ddd7a9164a9e61091679c28..5aded14b616e70ac98e0daa7ff94ec4294409950 100644
  11. --- a/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc
  12. +++ b/chrome/browser/picture_in_picture/picture_in_picture_window_manager.cc
  13. @@ -6,6 +6,7 @@
  14. #include "base/memory/raw_ptr.h"
  15. #include "base/numerics/safe_conversions.h"
  16. +#include "build/branding_buildflags.h"
  17. #include "chrome/browser/picture_in_picture/picture_in_picture_bounds_cache.h"
  18. #include "chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker.h"
  19. #include "chrome/browser/ui/browser_navigator_params.h"
  20. @@ -25,7 +26,9 @@
  21. #include "base/metrics/histogram_functions.h"
  22. #include "base/numerics/checked_math.h"
  23. #include "base/task/sequenced_task_runner.h"
  24. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  25. #include "chrome/browser/picture_in_picture/auto_picture_in_picture_tab_helper.h"
  26. +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
  27. #include "media/base/media_switches.h"
  28. #include "net/base/url_util.h"
  29. #include "third_party/blink/public/common/features.h"
  30. @@ -49,7 +52,7 @@ constexpr gfx::Size kMinWindowSize(240, 52);
  31. // not apply to video Picture-in-Picture windows.
  32. constexpr double kMaxWindowSizeRatio = 0.8;
  33. -#if !BUILDFLAG(IS_ANDROID)
  34. +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
  35. // Returns true if a document picture-in-picture window should be focused upon
  36. // opening it.
  37. bool ShouldFocusPictureInPictureWindow(const NavigateParams& params) {
  38. @@ -196,7 +199,7 @@ bool PictureInPictureWindowManager::ExitPictureInPictureViaWindowUi(
  39. return false;
  40. }
  41. -#if !BUILDFLAG(IS_ANDROID)
  42. +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
  43. // The user manually closed the pip window, so let the tab helper know in case
  44. // the auto-pip permission dialog was visible.
  45. if (auto* tab_helper = AutoPictureInPictureTabHelper::FromWebContents(
  46. @@ -401,7 +404,7 @@ gfx::Size PictureInPictureWindowManager::GetMaximumWindowSize(
  47. // static
  48. void PictureInPictureWindowManager::SetWindowParams(NavigateParams& params) {
  49. -#if !BUILDFLAG(IS_ANDROID)
  50. +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
  51. // Always show document picture-in-picture in a new window. When this is
  52. // not opened via the AutoPictureInPictureTabHelper, focus the window.
  53. params.window_action = ShouldFocusPictureInPictureWindow(params)
  54. @@ -493,6 +496,7 @@ PictureInPictureWindowManager::GetOverlayView(
  55. return nullptr;
  56. }
  57. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  58. // It would be nice to create this in `EnterPictureInPicture*`, but detecting
  59. // auto-pip while pip is in the process of opening doesn't work.
  60. //
  61. @@ -531,6 +535,8 @@ PictureInPictureWindowManager::GetOverlayView(
  62. }
  63. return overlay_view;
  64. +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
  65. + return nullptr;
  66. }
  67. PictureInPictureOcclusionTracker*
  68. diff --git a/chrome/browser/ui/views/overlay/video_overlay_window_views.cc b/chrome/browser/ui/views/overlay/video_overlay_window_views.cc
  69. index 996f6f99f722683428ea4ff5aef9cdc5d396af2c..f35c07ec123f4e3a5883999f7e0d81cd9d88e1c0 100644
  70. --- a/chrome/browser/ui/views/overlay/video_overlay_window_views.cc
  71. +++ b/chrome/browser/ui/views/overlay/video_overlay_window_views.cc
  72. @@ -430,11 +430,13 @@ std::unique_ptr<VideoOverlayWindowViews> VideoOverlayWindowViews::Create(
  73. #endif // BUILDFLAG(IS_WIN)
  74. +#if 0
  75. PictureInPictureOcclusionTracker* tracker =
  76. PictureInPictureWindowManager::GetInstance()->GetOcclusionTracker();
  77. if (tracker) {
  78. tracker->OnPictureInPictureWidgetOpened(overlay_window.get());
  79. }
  80. +#endif
  81. return overlay_window;
  82. }