diff --git a/patches/chromium/chore_grandfather_in_electron_views_and_delegates.patch b/patches/chromium/chore_grandfather_in_electron_views_and_delegates.patch index c19db7f2b7c6..ee30ed47b66a 100644 --- a/patches/chromium/chore_grandfather_in_electron_views_and_delegates.patch +++ b/patches/chromium/chore_grandfather_in_electron_views_and_delegates.patch @@ -49,10 +49,10 @@ index ae7eab37f12ba80ec423d229cf048021e9ba6765..507a75dc7947295db221b01356fa57ba // 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 7c2463cb91d00de2b0fa4f10221ea960be860d9a..0d5c63e7efbe42d5352abdeb594175904af30c41 100644 +index 7c2463cb91d00de2b0fa4f10221ea960be860d9a..e79beefddbd815e1ba7d9be86256e49d3ee7c619 100644 --- a/ui/views/widget/widget_delegate.h +++ b/ui/views/widget/widget_delegate.h -@@ -169,6 +169,13 @@ namespace data_controls { +@@ -169,6 +169,12 @@ namespace data_controls { class DesktopDataControlsDialog; } @@ -60,13 +60,12 @@ index 7c2463cb91d00de2b0fa4f10221ea960be860d9a..0d5c63e7efbe42d5352abdeb59417590 +class AutofillPopupView; +class DevToolsWindowDelegate; +class NativeWindowMac; -+class NativeWindowViews; +} + namespace enterprise_connectors { class ContentAnalysisDialog; class ContentAnalysisDialogBehaviorBrowserTest; -@@ -371,6 +378,7 @@ class VIEWS_EXPORT WidgetDelegate { +@@ -371,6 +377,7 @@ class VIEWS_EXPORT WidgetDelegate { class OwnedByWidgetPassKey { private: @@ -74,16 +73,15 @@ index 7c2463cb91d00de2b0fa4f10221ea960be860d9a..0d5c63e7efbe42d5352abdeb59417590 // DO NOT ADD TO THIS LIST! // These existing cases are "grandfathered in", but there shouldn't be more. // See comments atop `SetOwnedByWidget()`. -@@ -468,6 +476,8 @@ class VIEWS_EXPORT WidgetDelegate { +@@ -468,6 +475,7 @@ class VIEWS_EXPORT WidgetDelegate { }; class RegisterDeleteCallbackPassKey { private: + friend class electron::NativeWindowMac; -+ friend class electron::NativeWindowViews; // DO NOT ADD TO THIS LIST! // These existing cases are "grandfathered in", but there shouldn't be more. // See comments atop `RegisterDeleteDelegateCallback()`. -@@ -918,6 +928,7 @@ class VIEWS_EXPORT WidgetDelegateView : public WidgetDelegate, public View { +@@ -918,6 +926,7 @@ class VIEWS_EXPORT WidgetDelegateView : public WidgetDelegate, public View { View* GetContentsView() override; private: diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 610ecc7ecad8..fead4bf7c7c1 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -435,22 +435,6 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options, // bounds if the bounds are smaller than the current display SetBounds(gfx::Rect(GetPosition(), bounds.size()), false); #endif - - RegisterDeleteDelegateCallback( - RegisterDeleteCallbackPassKey(), - base::BindOnce( - [](NativeWindowViews* window) { - if (window->is_modal() && window->parent()) { - auto* parent = window->parent(); - // Enable parent window after current window gets closed. - static_cast(parent)->DecrementChildModals(); - // Focus on parent window. - parent->Focus(true); - } - - window->NotifyWindowClosed(); - }, - this)); } NativeWindowViews::~NativeWindowViews() { @@ -1725,13 +1709,22 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget, } void NativeWindowViews::OnWidgetDestroying(views::Widget* widget) { - aura::Window* window = GetNativeWindow(); - if (window) + if (aura::Window* window = GetNativeWindow()) window->RemovePreTargetHandler(this); + + if (is_modal()) { + if (NativeWindow* const parent = this->parent()) { + // Enable parent window after current window gets closed. + static_cast(parent)->DecrementChildModals(); + // Focus on parent window. + parent->Focus(true); + } + } } void NativeWindowViews::OnWidgetDestroyed(views::Widget* changed_widget) { widget_destroyed_ = true; + NotifyWindowClosed(); } views::View* NativeWindowViews::GetInitiallyFocusedView() {