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 865bb4928694b9476f875045a9de8daf3b9c367f..9d42736d53a21b7e1895f9e4e974a8d1a820ea41 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. @@ -23,7 +24,9 @@
  21. #include "ui/gfx/geometry/size.h"
  22. #if !BUILDFLAG(IS_ANDROID)
  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. @@ -44,7 +47,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. @@ -176,7 +179,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. @@ -368,7 +371,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. @@ -440,6 +443,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. @@ -478,6 +482,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 b3419d2bb60ab0488fc0413843c33b5a926fee09..059754d92621ada9100e739ee6b5db01ae9ea75f 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. @@ -314,11 +314,13 @@ std::unique_ptr<VideoOverlayWindowViews> VideoOverlayWindowViews::Create(
  73. }
  74. #endif // BUILDFLAG(IS_WIN)
  75. +#if 0
  76. PictureInPictureOcclusionTracker* tracker =
  77. PictureInPictureWindowManager::GetInstance()->GetOcclusionTracker();
  78. if (tracker) {
  79. tracker->OnPictureInPictureWidgetOpened(overlay_window.get());
  80. }
  81. +#endif
  82. return overlay_window;
  83. }