[cr149] SidePanelEntry::PanelType entries now in SidePanelType
Chromium changes: https://chromium.googlesource.com/chromium/src/+/78425c46e1229419e65b0b8485e0e5b4e405bb85 commit 78425c46e1229419e65b0b8485e0e5b4e405bb85 Author: Mohamed Adel <adelm@google.com> Date: Wed Apr 8 10:21:20 2026 -0700 [Side Panel Infra] Move SidePanelEntry::PanelType into side_panel_enums Bug: 499977101 Change-Id: I04e7d9559c496d59fb84731bb0f26d99fbc5afe6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7731922 Reviewed-by: Theresa Sullivan <twellington@chromium.org> Auto-Submit: Moe Adel <adelm@google.com> Commit-Queue: Moe Adel <adelm@google.com> Cr-Commit-Position: refs/heads/main@{#1611625}
This commit is contained in:
@@ -83,9 +83,8 @@ class AIChatGlobalSidePanelBrowserTest
|
||||
}
|
||||
|
||||
return side_panel_coordinator->IsSidePanelShowing(
|
||||
SidePanelEntry::PanelType::kContent) &&
|
||||
side_panel_coordinator->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent) ==
|
||||
SidePanelType::kContent) &&
|
||||
side_panel_coordinator->GetCurrentEntryId(SidePanelType::kContent) ==
|
||||
SidePanelEntry::Id::kChatUI;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,13 +115,13 @@ class PlaylistServiceDelegateImpl : public PlaylistService::Delegate {
|
||||
}
|
||||
|
||||
auto* side_panel_ui = browser->GetFeatures().side_panel_ui();
|
||||
if (!side_panel_ui || side_panel_ui->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent) !=
|
||||
SidePanelEntryId::kPlaylist) {
|
||||
if (!side_panel_ui ||
|
||||
side_panel_ui->GetCurrentEntryId(SidePanelType::kContent) !=
|
||||
SidePanelEntryId::kPlaylist) {
|
||||
return true;
|
||||
}
|
||||
|
||||
side_panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
side_panel_ui->Close(SidePanelType::kContent);
|
||||
return true;
|
||||
});
|
||||
#endif // !BUILDFLAG(IS_ANDROID)
|
||||
|
||||
@@ -182,12 +182,10 @@ IN_PROC_BROWSER_TEST_F(PlaylistBrowserTest, PanelToggleTestWhilePlaying) {
|
||||
|
||||
// Open playlist panel.
|
||||
panel_ui->Show(SidePanelEntryId::kPlaylist);
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent);
|
||||
}));
|
||||
ASSERT_TRUE(base::test::RunUntil([&]() {
|
||||
return panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent);
|
||||
}));
|
||||
WaitUntil(base::BindLambdaForTesting(
|
||||
[&]() { return panel_ui->IsSidePanelShowing(SidePanelType::kContent); }));
|
||||
ASSERT_TRUE(base::test::RunUntil(
|
||||
[&]() { return panel_ui->IsSidePanelShowing(SidePanelType::kContent); }));
|
||||
|
||||
auto* coordinator =
|
||||
browser()->GetFeatures().playlist_side_panel_coordinator();
|
||||
@@ -195,26 +193,25 @@ IN_PROC_BROWSER_TEST_F(PlaylistBrowserTest, PanelToggleTestWhilePlaying) {
|
||||
coordinator->is_audible_for_testing_ = true;
|
||||
|
||||
// Close playlist panel check cached instances are still live.
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
EXPECT_TRUE(coordinator->contents_wrapper_);
|
||||
ASSERT_TRUE(base::test::RunUntil([&]() {
|
||||
return !panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent);
|
||||
return !panel_ui->IsSidePanelShowing(SidePanelType::kContent);
|
||||
}));
|
||||
|
||||
// Re-open playlist panel.
|
||||
panel_ui->Show(SidePanelEntryId::kPlaylist);
|
||||
ASSERT_TRUE(base::test::RunUntil([&]() {
|
||||
return panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent);
|
||||
}));
|
||||
ASSERT_TRUE(base::test::RunUntil(
|
||||
[&]() { return panel_ui->IsSidePanelShowing(SidePanelType::kContent); }));
|
||||
|
||||
// Not audible. Check cached webview/contents are destroyed.
|
||||
coordinator->is_audible_for_testing_ = false;
|
||||
|
||||
// Close playlist panel. Check cached instances are all freed.
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
EXPECT_FALSE(coordinator->contents_wrapper_);
|
||||
ASSERT_TRUE(base::test::RunUntil([&]() {
|
||||
return !panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent);
|
||||
return !panel_ui->IsSidePanelShowing(SidePanelType::kContent);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -876,20 +876,18 @@ IN_PROC_BROWSER_TEST_F(SpeedReaderBrowserTest, Toolbar) {
|
||||
#if BUILDFLAG(ENABLE_AI_CHAT)
|
||||
Click(toolbar, "ai");
|
||||
auto* side_panel = browser()->GetFeatures().side_panel_ui();
|
||||
while (side_panel->GetCurrentEntryId(SidePanelEntry::PanelType::kContent) !=
|
||||
while (side_panel->GetCurrentEntryId(SidePanelType::kContent) !=
|
||||
SidePanelEntryId::kChatUI) {
|
||||
NonBlockingDelay(base::Milliseconds(10));
|
||||
}
|
||||
EXPECT_EQ(SidePanelEntryId::kChatUI,
|
||||
side_panel->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
side_panel->GetCurrentEntryId(SidePanelType::kContent));
|
||||
Click(toolbar, "ai");
|
||||
while (side_panel->GetCurrentEntryId(SidePanelEntry::PanelType::kContent)
|
||||
.has_value()) {
|
||||
while (side_panel->GetCurrentEntryId(SidePanelType::kContent).has_value()) {
|
||||
NonBlockingDelay(base::Milliseconds(10));
|
||||
}
|
||||
EXPECT_FALSE(
|
||||
side_panel->GetCurrentEntryId(SidePanelEntry::PanelType::kContent)
|
||||
.has_value());
|
||||
side_panel->GetCurrentEntryId(SidePanelType::kContent).has_value());
|
||||
#endif
|
||||
|
||||
Click(toolbar, "appearance");
|
||||
|
||||
@@ -706,10 +706,9 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestV1AndV2, DefaultEntryTest) {
|
||||
WaitUntil(base::BindLambdaForTesting(
|
||||
[&]() { return controller()->IsActiveIndex(bookmark_item_index); }));
|
||||
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return !panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent)
|
||||
.has_value();
|
||||
return !panel_ui->GetCurrentEntryId(SidePanelType::kContent).has_value();
|
||||
}));
|
||||
|
||||
// Remove bookmarks and check it's gone.
|
||||
@@ -720,12 +719,11 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestV1AndV2, DefaultEntryTest) {
|
||||
// Open panel w/o entry id.
|
||||
panel_ui->Toggle();
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent)
|
||||
.has_value();
|
||||
return panel_ui->GetCurrentEntryId(SidePanelType::kContent).has_value();
|
||||
}));
|
||||
// Check bookmark panel is not opened again as it's deleted item.
|
||||
EXPECT_NE(SidePanelEntryId::kBookmarks,
|
||||
panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
}
|
||||
|
||||
// Category A:
|
||||
@@ -975,7 +973,7 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserWithWebPanelTest, WebPanelTest) {
|
||||
panel_ui->Show(SidePanelEntryId::kCustomizeChrome);
|
||||
ASSERT_TRUE(
|
||||
base::test::RunUntil([&]() { return GetSidePanel()->GetVisible(); }));
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
ASSERT_TRUE(
|
||||
base::test::RunUntil([&]() { return !GetSidePanel()->GetVisible(); }));
|
||||
return;
|
||||
@@ -1373,11 +1371,10 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestV1AndV2, UnManagedPanelEntryTest) {
|
||||
|
||||
// Close panel and wait till panel closing animation ends. Panel is hidden
|
||||
// when closing completes.
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
WaitUntil(base::BindLambdaForTesting(
|
||||
[&]() { return !GetSidePanel()->GetVisible(); }));
|
||||
EXPECT_FALSE(
|
||||
!!panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
EXPECT_FALSE(!!panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
|
||||
// Remove bookmarks and check it's gone.
|
||||
SidebarServiceFactory::GetForProfile(browser()->profile())
|
||||
@@ -1389,7 +1386,7 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestV1AndV2, UnManagedPanelEntryTest) {
|
||||
WaitUntil(base::BindLambdaForTesting(
|
||||
[&]() { return GetSidePanel()->GetVisible(); }));
|
||||
EXPECT_EQ(SidePanelEntryId::kBookmarks,
|
||||
panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BRAVE_WALLET)
|
||||
@@ -1446,27 +1443,26 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestV1AndV2,
|
||||
|
||||
// No panel when activated tab at 1 because we don't open any global panel.
|
||||
tab_model()->ActivateTabAt(1);
|
||||
EXPECT_FALSE(
|
||||
panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent));
|
||||
EXPECT_FALSE(panel_ui->IsSidePanelShowing(SidePanelType::kContent));
|
||||
|
||||
// Open global panel when active tab index is 1.
|
||||
panel_ui->Show(SidePanelEntryId::kBookmarks);
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent) ==
|
||||
return panel_ui->GetCurrentEntryId(SidePanelType::kContent) ==
|
||||
SidePanelEntryId::kBookmarks;
|
||||
}));
|
||||
|
||||
// Contextual panel should be set when activate tab at 0.
|
||||
tab_model()->ActivateTabAt(0);
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent) ==
|
||||
return panel_ui->GetCurrentEntryId(SidePanelType::kContent) ==
|
||||
SidePanelEntryId::kCustomizeChrome;
|
||||
}));
|
||||
|
||||
// Global panel should be set when activate tab at 1.
|
||||
tab_model()->ActivateTabAt(1);
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent) ==
|
||||
return panel_ui->GetCurrentEntryId(SidePanelType::kContent) ==
|
||||
SidePanelEntryId::kBookmarks;
|
||||
}));
|
||||
}
|
||||
@@ -1602,17 +1598,16 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestWithkSidebarShowAlwaysOnStable,
|
||||
if (GetParam()) {
|
||||
// Wait till browser has active panel.
|
||||
WaitUntil(base::BindLambdaForTesting([&]() {
|
||||
return !!panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent);
|
||||
return !!panel_ui->GetCurrentEntryId(SidePanelType::kContent);
|
||||
}));
|
||||
|
||||
EXPECT_EQ(SidePanelEntryId::kChatUI,
|
||||
panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
}
|
||||
testing::Mock::VerifyAndClearExpectations(&observer_);
|
||||
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
EXPECT_FALSE(
|
||||
panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
EXPECT_FALSE(panel_ui->IsSidePanelShowing(SidePanelType::kContent));
|
||||
|
||||
// Check one shot panel is not opened anymore.
|
||||
EXPECT_CALL(observer_, OnActiveIndexChanged(testing::_, testing::_)).Times(0);
|
||||
@@ -1620,8 +1615,7 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestWithkSidebarShowAlwaysOnStable,
|
||||
browser(), GURL("https://www.brave.com/"),
|
||||
WindowOpenDisposition::NEW_FOREGROUND_TAB,
|
||||
ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP));
|
||||
EXPECT_FALSE(
|
||||
panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent));
|
||||
EXPECT_FALSE(panel_ui->IsSidePanelShowing(SidePanelType::kContent));
|
||||
testing::Mock::VerifyAndClearExpectations(&observer_);
|
||||
|
||||
observation_.Reset();
|
||||
@@ -1780,7 +1774,7 @@ IN_PROC_BROWSER_TEST_F(SidebarBrowserTestWithAIChat,
|
||||
tab_model()->ActivateTabAt(1);
|
||||
SimulateSidebarItemClickAt(tab_specific_item_index.value());
|
||||
EXPECT_EQ(SidePanelEntryId::kChatUI,
|
||||
panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
EXPECT_TRUE(GetSidePanel()->GetVisible());
|
||||
// Tab Specific panel should be open when Tab 1 is active
|
||||
EXPECT_EQ(model()->active_index(), tab_specific_item_index);
|
||||
@@ -1788,7 +1782,7 @@ IN_PROC_BROWSER_TEST_F(SidebarBrowserTestWithAIChat,
|
||||
// Global panel should be open when Tab 0 is active
|
||||
tab_model()->ActivateTabAt(0);
|
||||
EXPECT_EQ(SidePanelEntryId::kBookmarks,
|
||||
panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
EXPECT_TRUE(model()->active_index().has_value());
|
||||
EXPECT_EQ(model()->active_index(),
|
||||
model()->GetIndexOf(SidebarItem::BuiltInItemType::kBookmarks));
|
||||
@@ -1796,7 +1790,7 @@ IN_PROC_BROWSER_TEST_F(SidebarBrowserTestWithAIChat,
|
||||
// Global panel should be open when Tab 2 is active
|
||||
tab_model()->ActivateTabAt(2);
|
||||
EXPECT_EQ(SidePanelEntryId::kBookmarks,
|
||||
panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent));
|
||||
panel_ui->GetCurrentEntryId(SidePanelType::kContent));
|
||||
EXPECT_TRUE(model()->active_index().has_value());
|
||||
EXPECT_EQ(model()->active_index(),
|
||||
model()->GetIndexOf(SidebarItem::BuiltInItemType::kBookmarks));
|
||||
@@ -1917,7 +1911,7 @@ IN_PROC_BROWSER_TEST_P(SidebarBrowserTestV1AndV2,
|
||||
// Create a kToolbar type SidePanelEntry
|
||||
std::unique_ptr<SidePanelEntry> toolbar_entry =
|
||||
std::make_unique<SidePanelEntry>(
|
||||
SidePanelEntry::PanelType::kToolbar,
|
||||
SidePanelType::kToolbar,
|
||||
SidePanelEntry::Key(SidePanelEntry::Id::kAboutThisSite),
|
||||
base::BindRepeating([](SidePanelEntryScope&) {
|
||||
return std::make_unique<views::View>();
|
||||
@@ -2117,7 +2111,7 @@ IN_PROC_BROWSER_TEST_F(SidebarBrowserTest, SidebarV2ActiveItemStateSync) {
|
||||
EXPECT_EQ(model()->active_index(), bookmark_item_index);
|
||||
|
||||
// Deactivate by closing the panel.
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
ASSERT_TRUE(base::test::RunUntil(
|
||||
[&]() { return !model()->active_index().has_value(); }));
|
||||
|
||||
@@ -2128,7 +2122,7 @@ IN_PROC_BROWSER_TEST_F(SidebarBrowserTest, SidebarV2ActiveItemStateSync) {
|
||||
[&]() { return controller()->IsActiveIndex(bookmark_item_index); }));
|
||||
|
||||
// Closing the side panel via the panel UI deactivates the item in the model.
|
||||
panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
panel_ui->Close(SidePanelType::kContent);
|
||||
ASSERT_TRUE(base::test::RunUntil(
|
||||
[&]() { return !model()->active_index().has_value(); }));
|
||||
|
||||
@@ -2141,9 +2135,8 @@ IN_PROC_BROWSER_TEST_F(SidebarBrowserTest, SidebarV2ActiveItemStateSync) {
|
||||
// Wait for the panel to be fully shown before toggling closed, so that
|
||||
// BraveSidePanelCoordinator::Toggle() sees IsSidePanelShowing() == true
|
||||
// and takes the close branch instead of the show branch.
|
||||
ASSERT_TRUE(base::test::RunUntil([&]() {
|
||||
return panel_ui->IsSidePanelShowing(SidePanelEntry::PanelType::kContent);
|
||||
}));
|
||||
ASSERT_TRUE(base::test::RunUntil(
|
||||
[&]() { return panel_ui->IsSidePanelShowing(SidePanelType::kContent); }));
|
||||
|
||||
// Toggling the panel closed deactivates the item in the model.
|
||||
panel_ui->Toggle();
|
||||
|
||||
@@ -156,7 +156,7 @@ void SidebarController::ActivatePanelItem(
|
||||
: browser_->GetFeatures().side_panel_ui();
|
||||
CHECK(side_panel_ui);
|
||||
if (panel_item == SidebarItem::BuiltInItemType::kNone) {
|
||||
side_panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
side_panel_ui->Close(SidePanelType::kContent);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ void SidebarTabHelper::PrimaryPageChanged(content::Page& page) {
|
||||
}
|
||||
|
||||
// If side panel is already opened, don't open Leo panel now.
|
||||
if (side_panel_ui->GetCurrentEntryId(SidePanelEntry::PanelType::kContent)) {
|
||||
if (side_panel_ui->GetCurrentEntryId(SidePanelType::kContent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ void ClosePanel(content::WebContents* contents) {
|
||||
// closing the tab.
|
||||
if (SidePanelUI* ui =
|
||||
browser_view->browser()->GetFeatures().side_panel_ui()) {
|
||||
ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
ui->Close(SidePanelType::kContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ void ClosePanel(content::WebContents* web_contents) {
|
||||
}
|
||||
|
||||
if (SidePanelUI* ui = browser->GetFeatures().side_panel_ui()) {
|
||||
ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
ui->Close(SidePanelType::kContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ content::WebContents* AIChatSidePanelWebView::AddNewContents(
|
||||
|
||||
// If AI Chat is not open in the side panel, don't open the tab.
|
||||
if (browser->browser_window_features()->side_panel_ui()->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent) != SidePanelEntryId::kChatUI) {
|
||||
SidePanelType::kContent) != SidePanelEntryId::kChatUI) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class BookmarksSidePanelHeaderView : public views::View {
|
||||
AddChildView(std::make_unique<views::ImageButton>(base::BindRepeating(
|
||||
[](SidePanelUI* side_panel_ui) {
|
||||
if (side_panel_ui) {
|
||||
side_panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
side_panel_ui->Close(SidePanelType::kContent);
|
||||
}
|
||||
},
|
||||
scope.GetBrowserWindowInterface().GetFeatures().side_panel_ui())));
|
||||
|
||||
@@ -70,7 +70,7 @@ class ReadLaterSidePanelHeaderView : public views::View {
|
||||
AddChildView(std::make_unique<views::ImageButton>(base::BindRepeating(
|
||||
[](SidePanelUI* side_panel_ui) {
|
||||
if (side_panel_ui) {
|
||||
side_panel_ui->Close(SidePanelEntry::PanelType::kContent);
|
||||
side_panel_ui->Close(SidePanelType::kContent);
|
||||
}
|
||||
},
|
||||
scope.GetBrowserWindowInterface().GetFeatures().side_panel_ui())));
|
||||
|
||||
@@ -71,14 +71,14 @@ void BraveSidePanelCoordinator::Show(
|
||||
#endif
|
||||
}
|
||||
|
||||
void BraveSidePanelCoordinator::Close(SidePanelEntry::PanelType panel_type,
|
||||
void BraveSidePanelCoordinator::Close(SidePanelType panel_type,
|
||||
SidePanelEntryHideReason hide_reason,
|
||||
bool suppress_animations) {
|
||||
#if BUILDFLAG(ENABLE_SIDEBAR_V2)
|
||||
// Same as Show(): sidebar v2 does not rely on SidebarContainerView to
|
||||
// propagate panel close events, so clear the active item state here.
|
||||
CHECK(browser_view_->browser()->GetFeatures().sidebar_controller());
|
||||
if (panel_type == SidePanelEntry::PanelType::kContent) {
|
||||
if (panel_type == SidePanelType::kContent) {
|
||||
browser_view_->browser()
|
||||
->GetFeatures()
|
||||
.sidebar_controller()
|
||||
@@ -105,9 +105,9 @@ void BraveSidePanelCoordinator::OnActiveTabChanged(
|
||||
}
|
||||
|
||||
void BraveSidePanelCoordinator::Toggle() {
|
||||
if (IsSidePanelShowing(SidePanelEntry::PanelType::kContent) &&
|
||||
if (IsSidePanelShowing(SidePanelType::kContent) &&
|
||||
!browser_view_->contents_height_side_panel()->IsClosing()) {
|
||||
SidePanelCoordinator::Close(SidePanelEntry::PanelType::kContent);
|
||||
SidePanelCoordinator::Close(SidePanelType::kContent);
|
||||
} else if (const auto key = GetLastActiveEntryKey()) {
|
||||
SidePanelUIBase::Show(*key, SidePanelOpenTrigger::kToolbarButton);
|
||||
}
|
||||
@@ -127,8 +127,7 @@ void BraveSidePanelCoordinator::OnViewVisibilityChanged(
|
||||
// See the comment of SidePanelCoordinator::OnViewVisibilityChanged()
|
||||
// about this condition.
|
||||
bool update_items_state = true;
|
||||
if (observed_view->GetVisible() ||
|
||||
!current_key(SidePanelEntry::PanelType::kContent)) {
|
||||
if (observed_view->GetVisible() || !current_key(SidePanelType::kContent)) {
|
||||
update_items_state = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class BraveSidePanelCoordinator : public SidePanelCoordinator {
|
||||
void Show(const UniqueKey& entry,
|
||||
std::optional<SidePanelOpenTrigger> open_trigger,
|
||||
bool suppress_animations) override;
|
||||
void Close(SidePanelEntry::PanelType panel_type,
|
||||
void Close(SidePanelType panel_type,
|
||||
SidePanelEntryHideReason hide_reason,
|
||||
bool suppress_animations) override;
|
||||
void OnActiveTabChanged(content::WebContents* old_contents,
|
||||
|
||||
@@ -40,14 +40,12 @@ using views::ShapeContextTokensOverride::kRoundedCornersBorderRadius;
|
||||
|
||||
namespace {
|
||||
|
||||
SidePanel::HorizontalAlignment GetHorizontalAlignment(
|
||||
PrefService* pref_service,
|
||||
SidePanelEntry::PanelType type) {
|
||||
SidePanel::HorizontalAlignment GetHorizontalAlignment(PrefService* pref_service,
|
||||
SidePanelType type) {
|
||||
bool is_right_aligned =
|
||||
pref_service->GetBoolean(prefs::kSidePanelHorizontalAlignment);
|
||||
is_right_aligned = type == SidePanelEntry::PanelType::kToolbar
|
||||
? !is_right_aligned
|
||||
: is_right_aligned;
|
||||
is_right_aligned =
|
||||
type == SidePanelType::kToolbar ? !is_right_aligned : is_right_aligned;
|
||||
return is_right_aligned ? SidePanel::HorizontalAlignment::kRight
|
||||
: SidePanel::HorizontalAlignment::kLeft;
|
||||
}
|
||||
@@ -76,7 +74,7 @@ END_METADATA
|
||||
} // namespace
|
||||
|
||||
SidePanel::SidePanel(BrowserView* browser_view,
|
||||
SidePanelEntry::PanelType type,
|
||||
SidePanelType type,
|
||||
bool has_border)
|
||||
: horizontal_alignment_(
|
||||
GetHorizontalAlignment(browser_view->GetProfile()->GetPrefs(), type)),
|
||||
@@ -112,7 +110,6 @@ SidePanel::SidePanel(BrowserView* browser_view,
|
||||
prefs::kSidePanelHorizontalAlignment,
|
||||
base::BindRepeating(&SidePanel::UpdateHorizontalAlignment,
|
||||
base::Unretained(this)));
|
||||
|
||||
}
|
||||
|
||||
SidePanel::~SidePanel() {
|
||||
@@ -186,7 +183,7 @@ gfx::Size SidePanel::GetMinimumSize() const {
|
||||
// fits in the remaining space beside the toolbar. Use the upstream-compatible
|
||||
// minimum for toolbar panels so that clamping logic works correctly.
|
||||
// The content-height panel (inside the sidebar) keeps kDefaultSidePanelWidth.
|
||||
if (type_ == SidePanelEntry::PanelType::kToolbar) {
|
||||
if (type_ == SidePanelType::kToolbar) {
|
||||
return gfx::Size(SidePanelEntry::kSidePanelDefaultContentWidth, 0);
|
||||
}
|
||||
return gfx::Size(sidebar::kDefaultSidePanelWidth, 0);
|
||||
|
||||
@@ -45,7 +45,7 @@ class SidePanel : public views::View,
|
||||
|
||||
// Same signature as chromium SidePanel
|
||||
explicit SidePanel(BrowserView* browser_view,
|
||||
SidePanelEntry::PanelType type,
|
||||
SidePanelType type,
|
||||
bool has_border);
|
||||
SidePanel(const SidePanel&) = delete;
|
||||
SidePanel& operator=(const SidePanel&) = delete;
|
||||
@@ -99,7 +99,7 @@ class SidePanel : public views::View,
|
||||
void AddedToWidget() override;
|
||||
void Layout(PassKey) override;
|
||||
|
||||
SidePanelEntry::PanelType type() const { return type_; }
|
||||
SidePanelType type() const { return type_; }
|
||||
|
||||
// Reflects the current state of the visibility of the side panel.
|
||||
enum class State { kClosed, kOpening, kOpen, kClosing };
|
||||
@@ -152,7 +152,7 @@ class SidePanel : public views::View,
|
||||
// contents layout while sidebar show/hide animation is in-progress.
|
||||
std::optional<int> fixed_contents_width_;
|
||||
raw_ptr<BrowserView> browser_view_ = nullptr;
|
||||
const SidePanelEntry::PanelType type_;
|
||||
const SidePanelType type_;
|
||||
IntegerPrefMember side_panel_width_;
|
||||
std::unique_ptr<SidePanelResizeWidget> resize_widget_;
|
||||
std::unique_ptr<ViewShadow> shadow_;
|
||||
|
||||
@@ -258,8 +258,8 @@ bool SidebarContainerView::IsFullscreenForCurrentEntry() const {
|
||||
return false;
|
||||
#else
|
||||
// For now, we only supports fullscreen from playlist.
|
||||
if (side_panel_coordinator_->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent) != SidePanelEntryId::kPlaylist) {
|
||||
if (side_panel_coordinator_->GetCurrentEntryId(SidePanelType::kContent) !=
|
||||
SidePanelEntryId::kPlaylist) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -507,8 +507,7 @@ bool SidebarContainerView::IsFullscreenByTab() const {
|
||||
}
|
||||
|
||||
bool SidebarContainerView::IsSidePanelShowing() const {
|
||||
return side_panel_coordinator_->IsSidePanelShowing(
|
||||
SidePanelEntry::PanelType::kContent);
|
||||
return side_panel_coordinator_->IsSidePanelShowing(SidePanelType::kContent);
|
||||
}
|
||||
|
||||
bool SidebarContainerView::ShouldForceShowSidebar() const {
|
||||
@@ -518,8 +517,7 @@ bool SidebarContainerView::ShouldForceShowSidebar() const {
|
||||
#else
|
||||
// It is more reliable to check whether coordinator has current entry rather
|
||||
// than checking if side_panel_ is visible.
|
||||
return side_panel_coordinator_->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent) ||
|
||||
return side_panel_coordinator_->GetCurrentEntryId(SidePanelType::kContent) ||
|
||||
#endif
|
||||
sidebar_control_view_->IsItemReorderingInProgress() ||
|
||||
sidebar_control_view_->IsBubbleWidgetVisible();
|
||||
@@ -624,8 +622,7 @@ void SidebarContainerView::OnActiveIndexChanged(
|
||||
// arrived first and then OnEntryHidden() for managed is called.
|
||||
// And this method is called by last OnEntryHidden(). So, coordinator
|
||||
// already has non-managed entry.
|
||||
if (side_panel_coordinator_->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent)) {
|
||||
if (side_panel_coordinator_->GetCurrentEntryId(SidePanelType::kContent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1014,8 +1011,8 @@ void SidebarContainerView::OnEntryHidden(SidePanelEntry* entry) {
|
||||
// different tab uses ai-chat). In this case, don't need to deactivate
|
||||
// item because same item should be activated.
|
||||
if (controller->IsActiveIndex(sidebar_index) &&
|
||||
side_panel_coordinator_->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent) != entry->key().id()) {
|
||||
side_panel_coordinator_->GetCurrentEntryId(SidePanelType::kContent) !=
|
||||
entry->key().id()) {
|
||||
controller->ActivateItemAt(std::nullopt);
|
||||
return;
|
||||
}
|
||||
@@ -1025,8 +1022,7 @@ void SidebarContainerView::OnEntryHidden(SidePanelEntry* entry) {
|
||||
// Handling non-managed entry.
|
||||
// If non-managed entry is hidden and there is no active entry,
|
||||
// panel should be hidden here.
|
||||
if (!side_panel_coordinator_->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent)) {
|
||||
if (!side_panel_coordinator_->GetCurrentEntryId(SidePanelType::kContent)) {
|
||||
HideSidebarForShowOption();
|
||||
}
|
||||
}
|
||||
@@ -1050,8 +1046,8 @@ void SidebarContainerView::UpdateActiveItemState() {
|
||||
|
||||
auto* controller = browser_->GetFeatures().sidebar_controller();
|
||||
std::optional<sidebar::SidebarItem::BuiltInItemType> current_type;
|
||||
if (auto entry_id = side_panel_coordinator_->GetCurrentEntryId(
|
||||
SidePanelEntry::PanelType::kContent)) {
|
||||
if (auto entry_id =
|
||||
side_panel_coordinator_->GetCurrentEntryId(SidePanelType::kContent)) {
|
||||
current_type = sidebar::BuiltInItemTypeFromSidePanelId(*entry_id);
|
||||
}
|
||||
controller->UpdateActiveItemState(current_type);
|
||||
@@ -1083,7 +1079,7 @@ void SidebarContainerView::OnTabStripModelChanged(
|
||||
if (auto* entry = registry->GetEntryForKey(
|
||||
SidePanelEntry::Key(SidePanelEntryId::kChatUI))) {
|
||||
if (side_panel_coordinator_->IsSidePanelEntryShowing(entry->key())) {
|
||||
side_panel_coordinator_->Close(SidePanelEntry::PanelType::kContent);
|
||||
side_panel_coordinator_->Close(SidePanelType::kContent);
|
||||
} else {
|
||||
entry->ClearCachedView();
|
||||
}
|
||||
@@ -1123,7 +1119,7 @@ void SidebarContainerView::StartObservingContextualSidePanelEntry(
|
||||
if (shared_pinned_tab_service &&
|
||||
shared_pinned_tab_service->IsSharedContents(contents)) {
|
||||
if (auto active_entry =
|
||||
registry->GetActiveEntryFor(SidePanelEntry::PanelType::kContent)) {
|
||||
registry->GetActiveEntryFor(SidePanelType::kContent)) {
|
||||
OnEntryShown(*active_entry);
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1137,7 @@ void SidebarContainerView::AddSidePanelEntryObservation(SidePanelEntry* entry) {
|
||||
}
|
||||
|
||||
// Brave sidebar can handle only kContent type.
|
||||
if (entry->type() != SidePanelEntry::PanelType::kContent) {
|
||||
if (entry->type() != SidePanelType::kContent) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,8 +284,8 @@ IN_PROC_BROWSER_TEST_F(BraveToolbarViewTest_AIChatEnabled,
|
||||
SidePanelEntryKey ai_chat_key =
|
||||
SidePanelEntry::Key(SidePanelEntryId::kChatUI);
|
||||
auto* side_panel_coordinator = SidePanelCoordinator::From(browser());
|
||||
EXPECT_FALSE(side_panel_coordinator->IsSidePanelShowing(
|
||||
SidePanelEntry::PanelType::kContent));
|
||||
EXPECT_FALSE(
|
||||
side_panel_coordinator->IsSidePanelShowing(SidePanelType::kContent));
|
||||
button->ButtonPressed();
|
||||
EXPECT_TRUE(side_panel_coordinator->IsSidePanelEntryShowing(ai_chat_key));
|
||||
|
||||
|
||||
@@ -157,10 +157,9 @@ void SpeedreaderToolbarDataHandlerImpl::AiChat() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto entry =
|
||||
side_panel->GetCurrentEntryId(SidePanelEntry::PanelType::kContent);
|
||||
if (auto entry = side_panel->GetCurrentEntryId(SidePanelType::kContent);
|
||||
entry == SidePanelEntryId::kChatUI) {
|
||||
side_panel->Close(SidePanelEntry::PanelType::kContent);
|
||||
side_panel->Close(SidePanelType::kContent);
|
||||
} else {
|
||||
side_panel->Show(SidePanelEntryId::kChatUI);
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ bool BrowserViewLayoutDelegateImpl::IsContentTypeSidePanelVisible() const {
|
||||
.browser()
|
||||
->GetFeatures()
|
||||
.side_panel_ui()
|
||||
->GetCurrentEntryId(SidePanelEntry::PanelType::kContent)
|
||||
->GetCurrentEntryId(SidePanelType::kContent)
|
||||
.has_value();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user