From 8a89d2d695d242236917eaa3c3c798d55b13c5fb Mon Sep 17 00:00:00 2001 From: brave-builds <45370463+brave-builds@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:10:52 +0200 Subject: [PATCH] Try to avoid crash from SidePanelCoordinator::PopulateSidePanel() (uplift to 1.68.x) (#24541) Uplift of #24499 (squashed) to beta --- .../brave_side_panel_coordinator.cc | 21 +++++++++++++++++++ .../side_panel/brave_side_panel_coordinator.h | 4 ++++ .../views/side_panel/side_panel_coordinator.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/browser/ui/views/side_panel/brave_side_panel_coordinator.cc b/browser/ui/views/side_panel/brave_side_panel_coordinator.cc index bbb84b0aa2a7..94f887cee965 100644 --- a/browser/ui/views/side_panel/brave_side_panel_coordinator.cc +++ b/browser/ui/views/side_panel/brave_side_panel_coordinator.cc @@ -6,7 +6,10 @@ #include "brave/browser/ui/views/side_panel/brave_side_panel_coordinator.h" #include +#include +#include +#include "base/debug/crash_logging.h" #include "base/debug/dump_without_crashing.h" #include "brave/browser/ui/sidebar/sidebar_service_factory.h" #include "brave/browser/ui/sidebar/sidebar_utils.h" @@ -146,3 +149,21 @@ void BraveSidePanelCoordinator::UpdateToolbarButtonHighlight( : IDS_TOOLTIP_SIDEBAR_SHOW)); } } + +void BraveSidePanelCoordinator::PopulateSidePanel( + bool supress_animations, + SidePanelEntry* entry, + std::optional> content_view) { + CHECK(entry); + actions::ActionItem* const action_item = GetActionItem(entry->key()); + if (!action_item) { + const std::string entry_id = SidePanelEntryIdToString(entry->key().id()); + LOG(ERROR) << __func__ << " no side panel action item for " << entry_id; + SCOPED_CRASH_KEY_STRING64("SidePanel", "entry_id", entry_id); + base::debug::DumpWithoutCrashing(); + return; + } + + SidePanelCoordinator::PopulateSidePanel(supress_animations, entry, + std::move(content_view)); +} diff --git a/browser/ui/views/side_panel/brave_side_panel_coordinator.h b/browser/ui/views/side_panel/brave_side_panel_coordinator.h index a3c6519a4c04..a5b31c768e8f 100644 --- a/browser/ui/views/side_panel/brave_side_panel_coordinator.h +++ b/browser/ui/views/side_panel/brave_side_panel_coordinator.h @@ -30,6 +30,10 @@ class BraveSidePanelCoordinator : public SidePanelCoordinator { SidePanelUtil::SidePanelOpenTrigger open_trigger) override; void OnViewVisibilityChanged(views::View* observed_view, views::View* starting_from) override; + void PopulateSidePanel( + bool supress_animations, + SidePanelEntry* entry, + std::optional> content_view) override; private: // Returns the last active entry or the default entry if no last active diff --git a/chromium_src/chrome/browser/ui/views/side_panel/side_panel_coordinator.h b/chromium_src/chrome/browser/ui/views/side_panel/side_panel_coordinator.h index 67b78223add2..7cbd84354a65 100644 --- a/chromium_src/chrome/browser/ui/views/side_panel/side_panel_coordinator.h +++ b/chromium_src/chrome/browser/ui/views/side_panel/side_panel_coordinator.h @@ -32,9 +32,11 @@ virtual std::unique_ptr CreateHeader #define UpdateToolbarButtonHighlight virtual UpdateToolbarButtonHighlight +#define PopulateSidePanel virtual PopulateSidePanel #include "src/chrome/browser/ui/views/side_panel/side_panel_coordinator.h" // IWYU pragma: export +#undef PopulateSidePanel #undef UpdateToolbarButtonHighlight #undef CreateHeader