From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Mon, 14 Apr 2025 11:34:25 -0500
Subject: chore: "grandfather in" Electron Views and Delegates

6441736: Block further usage of WidgetDelegateView. | https://chromium-review.googlesource.com/c/chromium/src/+/6441736

6442265: Add a PassKey for std::make_unique<WidgetDelegateView>(). | https://chromium-review.googlesource.com/c/chromium/src/+/6442265

6448510: Lock further access to View::set_owned_by_client(). | https://chromium-review.googlesource.com/c/chromium/src/+/6448510

diff --git a/ui/views/view.h b/ui/views/view.h
index 6e3002f54434f4b09b91e7892fc5e0bf35f8ad9a..da39036cdb0a78190fa9dbdd6d7995e40347d37c 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -78,6 +78,19 @@ class ArcNotificationContentView;
 class WideFrameView;
 }  // namespace ash
 
+namespace electron {
+class DevToolsWindowDelegate;
+class InspectableWebContentsView;
+class MenuBar;
+class RootView;
+class RootViewMac;
+}
+
+namespace electron::api {
+class ImageView;
+class View;
+}
+
 namespace exo {
 class ShellSurfaceBase;
 }
@@ -309,6 +322,14 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
  public:
   class OwnedByClientPassKey {
    private:
+    // TODO(ckerr) can this list be shortened?
+    friend class electron::DevToolsWindowDelegate;
+    friend class electron::InspectableWebContentsView;
+    friend class electron::MenuBar;
+    friend class electron::RootView;
+    friend class electron::RootViewMac;
+    friend class electron::api::ImageView;
+    friend class electron::api::View;
     // DO NOT ADD TO THIS LIST!
     // These existing cases are "grandfathered in", but there shouldn't be more.
     // See comments atop class.
diff --git a/ui/views/widget/widget_delegate.h b/ui/views/widget/widget_delegate.h
index 8060008a22ed6aabb1821cf725caec500d80425c..f5685b0275793219f84bd1891195a29dab6fcb4a 100644
--- a/ui/views/widget/widget_delegate.h
+++ b/ui/views/widget/widget_delegate.h
@@ -168,6 +168,12 @@ namespace crostini {
 class AppRestartDialog;
 }
 
+namespace electron {
+class AutofillPopupView;
+class DevToolsWindowDelegate;
+class NativeWindowMac;
+}
+
 namespace exo {
 class ShellSurfaceBase;
 }
@@ -364,6 +370,7 @@ class VIEWS_EXPORT WidgetDelegate {
 
   class OwnedByWidgetPassKey {
    private:
+    friend class electron::DevToolsWindowDelegate;
     // DO NOT ADD TO THIS LIST!
     // These existing cases are "grandfathered in", but there shouldn't be more.
     // See comments atop `SetOwnedByWidget()`.
@@ -457,6 +464,7 @@ class VIEWS_EXPORT WidgetDelegate {
   };
   class RegisterDeleteCallbackPassKey {
    private:
+    friend class electron::NativeWindowMac;
     // DO NOT ADD TO THIS LIST!
     // These existing cases are "grandfathered in", but there shouldn't be more.
     // See comments atop `RegisterDeleteDelegateCallback()`.
@@ -912,6 +920,7 @@ class VIEWS_EXPORT WidgetDelegateView : public WidgetDelegate, public View {
   View* GetContentsView() override;
 
  private:
+  friend class electron::AutofillPopupView;
   // DO NOT ADD TO THIS LIST!
   // These existing cases are "grandfathered in", but there shouldn't be more.
   // See comments atop class.
