Skip to content

Commit

Permalink
Try to avoid crash from SidePanelCoordinator::PopulateSidePanel() (up…
Browse files Browse the repository at this point in the history
…lift to 1.68.x) (#24541)

Uplift of #24499 (squashed) to beta
  • Loading branch information
brave-builds authored Jul 8, 2024
1 parent 1eae2f9 commit 8a89d2d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions browser/ui/views/side_panel/brave_side_panel_coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#include "brave/browser/ui/views/side_panel/brave_side_panel_coordinator.h"

#include <optional>
#include <string>
#include <utility>

#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"
Expand Down Expand Up @@ -146,3 +149,21 @@ void BraveSidePanelCoordinator::UpdateToolbarButtonHighlight(
: IDS_TOOLTIP_SIDEBAR_SHOW));
}
}

void BraveSidePanelCoordinator::PopulateSidePanel(
bool supress_animations,
SidePanelEntry* entry,
std::optional<std::unique_ptr<views::View>> 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));
}
4 changes: 4 additions & 0 deletions browser/ui/views/side_panel/brave_side_panel_coordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<views::View>> content_view) override;

private:
// Returns the last active entry or the default entry if no last active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
virtual std::unique_ptr<views::View> 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

Expand Down

0 comments on commit 8a89d2d

Please sign in to comment.