fix_move_autopipsettingshelper_behind_branding_buildflag.patch 4.1 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 0a58771f77f9fab4bd660191a1b2c612f7951858..a25feb97dfa1f7f5c0378cdac256a8de542f3b7d 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. @@ -18,8 +18,10 @@
  14. #include "ui/gfx/geometry/size.h"
  15. #if !BUILDFLAG(IS_ANDROID)
  16. #include "base/task/sequenced_task_runner.h"
  17. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  18. #include "chrome/browser/picture_in_picture/auto_picture_in_picture_tab_helper.h"
  19. #include "chrome/browser/picture_in_picture/auto_pip_setting_helper.h"
  20. +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
  21. #include "third_party/blink/public/common/features.h"
  22. #include "ui/views/view.h"
  23. #endif // !BUILDFLAG(IS_ANDROID)
  24. @@ -288,7 +290,7 @@ void PictureInPictureWindowManager::CloseWindowInternal() {
  25. video_web_contents_observer_.reset();
  26. pip_window_controller_->Close(false /* should_pause_video */);
  27. pip_window_controller_ = nullptr;
  28. -#if !BUILDFLAG(IS_ANDROID)
  29. +#if !BUILDFLAG(IS_ANDROID) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
  30. auto_pip_setting_helper_.reset();
  31. #endif // !BUILDFLAG(IS_ANDROID)
  32. }
  33. @@ -299,8 +301,10 @@ void PictureInPictureWindowManager::DocumentWebContentsDestroyed() {
  34. // contents, so we only need to forget the controller here when user closes
  35. // the parent web contents with the PiP window open.
  36. document_web_contents_observer_.reset();
  37. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  38. // `setting_helper_` depends on the opener's WebContents.
  39. auto_pip_setting_helper_.reset();
  40. +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
  41. if (pip_window_controller_)
  42. pip_window_controller_ = nullptr;
  43. }
  44. @@ -318,6 +322,7 @@ std::unique_ptr<views::View> PictureInPictureWindowManager::GetOverlayView() {
  45. return nullptr;
  46. }
  47. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  48. auto* const web_contents = pip_window_controller_->GetWebContents();
  49. auto* auto_pip_tab_helper =
  50. @@ -339,6 +344,8 @@ std::unique_ptr<views::View> PictureInPictureWindowManager::GetOverlayView() {
  51. }
  52. return overlay_view;
  53. +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
  54. + return nullptr;
  55. }
  56. #endif // !BUILDFLAG(IS_ANDROID)
  57. 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
  58. index 560f2901ef6860811c783c1eed9277223072aabf..f5a5e3d883e0186961bd5560b4429e19abf0df49 100644
  59. --- a/chrome/browser/picture_in_picture/picture_in_picture_window_manager.h
  60. +++ b/chrome/browser/picture_in_picture/picture_in_picture_window_manager.h
  61. @@ -9,6 +9,7 @@
  62. #include "base/memory/singleton.h"
  63. #include "base/observer_list.h"
  64. #include "base/observer_list_types.h"
  65. +#include "build/branding_buildflags.h"
  66. #include "build/build_config.h"
  67. #include "third_party/abseil-cpp/absl/types/optional.h"
  68. #include "third_party/blink/public/mojom/picture_in_picture_window_options/picture_in_picture_window_options.mojom.h"
  69. @@ -25,7 +26,9 @@ class Display;
  70. } // namespace display
  71. #if !BUILDFLAG(IS_ANDROID)
  72. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  73. class AutoPipSettingHelper;
  74. +#endif
  75. namespace views {
  76. class View;
  77. @@ -193,7 +196,9 @@ class PictureInPictureWindowManager {
  78. #if !BUILDFLAG(IS_ANDROID)
  79. std::unique_ptr<DocumentWebContentsObserver> document_web_contents_observer_;
  80. +#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
  81. std::unique_ptr<AutoPipSettingHelper> auto_pip_setting_helper_;
  82. +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
  83. #endif //! BUILDFLAG(IS_ANDROID)
  84. raw_ptr<content::PictureInPictureWindowController, DanglingUntriaged>