diff --git a/browser/ui/views/frame/brave_browser_view.cc b/browser/ui/views/frame/brave_browser_view.cc index 410cbf7a78cc..4b33bf79e78d 100644 --- a/browser/ui/views/frame/brave_browser_view.cc +++ b/browser/ui/views/frame/brave_browser_view.cc @@ -587,6 +587,18 @@ void BraveBrowserView::UpdateSearchTabsButtonState() { BraveBrowserView::~BraveBrowserView() { tab_cycling_event_handler_.reset(); + // Removes the bubble from the browser, as it uses the `ToolbarView` as an + // archor, and that leaves a dangling reference once the `TopContainerView` is + // destroyed before all `SupportsUserData` is cleared. + if (brave_shields::CookieListOptInBubbleHost::FromBrowser(browser_.get())) { + brave_shields::CookieListOptInBubbleHost::RemoveFromBrowser(browser_.get()); + } + + // Same as above. + if (brave_rewards::TipPanelBubbleHost::FromBrowser(browser_.get())) { + brave_rewards::TipPanelBubbleHost::RemoveFromBrowser(browser_.get()); + } + DCHECK(!tab_cycling_event_handler_); } diff --git a/patches/chrome-browser-ui-views-bubble-webui_bubble_manager.h.patch b/patches/chrome-browser-ui-views-bubble-webui_bubble_manager.h.patch index 37d93a862e57..8556d2313b6c 100644 --- a/patches/chrome-browser-ui-views-bubble-webui_bubble_manager.h.patch +++ b/patches/chrome-browser-ui-views-bubble-webui_bubble_manager.h.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/ui/views/bubble/webui_bubble_manager.h b/chrome/browser/ui/views/bubble/webui_bubble_manager.h -index edd7d37a12e182cc663db4e565b8a9edb12e0c70..043ec6578181c02b4bad4d59769287cee6f91907 100644 +index edd7d37a12e182cc663db4e565b8a9edb12e0c70..e90187359fc82f33135212fb627ac07d495076d0 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_manager.h +++ b/chrome/browser/ui/views/bubble/webui_bubble_manager.h -@@ -165,11 +165,13 @@ class WebUIBubbleManagerImpl : public WebUIBubbleManager { +@@ -165,9 +165,11 @@ class WebUIBubbleManagerImpl : public WebUIBubbleManager { private: // WebUIBubbleManager: @@ -12,8 +12,5 @@ index edd7d37a12e182cc663db4e565b8a9edb12e0c70..043ec6578181c02b4bad4d59769287ce views::BubbleBorder::Arrow arrow) override; + private: -- const raw_ptr anchor_view_; -+ const raw_ptr anchor_view_; + const raw_ptr anchor_view_; const raw_ptr profile_; - const GURL webui_url_; - const int task_manager_string_id_;