Skip to content

Commit 88882cb

Browse files
kunaldaftari-googleChromium LUCI CQ
authored andcommitted
[Vertical Tabs] Update WebUI Tab Strip Tab Search Handling Logic
This CL builds upon the changes to the pinnable property. It extends the logic to the WebUITabStrip, so that we consider the tab search action item as "not pinnable" when the WebUITabStrip is present. Change-Id: Ia3072475f82fecb4183d8f07ec8237fa4ef78210 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7006660 Reviewed-by: Eshwar Stalin <[email protected]> Reviewed-by: David Pennington <[email protected]> Commit-Queue: Kunal Daftari <[email protected]> Cr-Commit-Position: refs/heads/main@{#1532396}
1 parent f29c2a9 commit 88882cb

File tree

6 files changed

+52
-42
lines changed

6 files changed

+52
-42
lines changed

chrome/browser/ui/browser_window/internal/browser_window_features.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,7 @@ void BrowserWindowFeatures::InitPostWindowConstruction(Browser* browser) {
511511
// BrowserWithTestWindowTest; these should eventually be refactored.
512512
if (browser_view) {
513513
tab_search_toolbar_button_controller_ =
514-
std::make_unique<TabSearchToolbarButtonController>(
515-
browser_view, browser_view->GetTabSearchBubbleHost());
514+
std::make_unique<TabSearchToolbarButtonController>(browser_view);
516515
}
517516
}
518517

chrome/browser/ui/toolbar/pinned_toolbar/tab_search_toolbar_button_controller.cc

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@
1414
#include "chrome/common/chrome_features.h"
1515

1616
TabSearchToolbarButtonController::TabSearchToolbarButtonController(
17-
BrowserView* browser_view,
18-
TabSearchBubbleHost* tab_search_bubble_host)
19-
: browser_view_(browser_view) {
20-
tab_search_bubble_host_observation_.Observe(tab_search_bubble_host);
21-
// https://crbug.com/435137909: This class is created post window
22-
// construction. Need to call this again because this class does not exist
23-
// when ToolbarView tries to call it from init.
24-
UpdateForWebUITabStrip();
25-
}
17+
BrowserView* browser_view)
18+
: browser_view_(browser_view) {}
2619

2720
TabSearchToolbarButtonController::~TabSearchToolbarButtonController() = default;
2821

@@ -59,16 +52,22 @@ void TabSearchToolbarButtonController::OnBubbleDestroying() {
5952
base::Seconds(1));
6053
}
6154

62-
void TabSearchToolbarButtonController::UpdateForWebUITabStrip() {
63-
PinnedToolbarActionsContainer* pinned_toolbar_actions_container =
64-
browser_view_->toolbar()->pinned_toolbar_actions_container();
65-
if (pinned_toolbar_actions_container) {
66-
actions::ActionItem* tab_search_action =
67-
pinned_toolbar_actions_container->GetActionItemFor(kActionTabSearch);
68-
if (tab_search_action) {
69-
// Do not make tab search button available if webui tab strip is enabled.
70-
tab_search_action->SetVisible(!browser_view_->webui_tab_strip());
71-
}
55+
void TabSearchToolbarButtonController::UpdateBubbleHost(
56+
TabSearchBubbleHost* new_tab_search_bubble_host) {
57+
tab_search_bubble_host_observation_.Reset();
58+
59+
actions::ActionItem* action_item = GetTabSearchActionItem();
60+
CHECK(action_item);
61+
62+
if (new_tab_search_bubble_host) {
63+
action_item->SetProperty(
64+
actions::kActionItemPinnableKey,
65+
static_cast<int>(actions::ActionPinnableState::kPinnable));
66+
tab_search_bubble_host_observation_.Observe(new_tab_search_bubble_host);
67+
} else {
68+
action_item->SetProperty(
69+
actions::kActionItemPinnableKey,
70+
static_cast<int>(actions::ActionPinnableState::kNotPinnable));
7271
}
7372
}
7473

chrome/browser/ui/toolbar/pinned_toolbar/tab_search_toolbar_button_controller.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class TabSearchBubbleHost;
1919

2020
class TabSearchToolbarButtonController : public TabSearchBubbleHostObserver {
2121
public:
22-
TabSearchToolbarButtonController(BrowserView* browser_view,
23-
TabSearchBubbleHost* tab_search_bubble_host);
22+
explicit TabSearchToolbarButtonController(BrowserView* browser_view);
2423
~TabSearchToolbarButtonController() override;
2524

2625
TabSearchToolbarButtonController(const TabSearchToolbarButtonController&) =
@@ -32,7 +31,7 @@ class TabSearchToolbarButtonController : public TabSearchBubbleHostObserver {
3231
void OnBubbleInitializing() override;
3332
void OnBubbleDestroying() override;
3433

35-
void UpdateForWebUITabStrip();
34+
void UpdateBubbleHost(TabSearchBubbleHost* new_tab_search_bubble_host);
3635

3736
private:
3837
void MaybeHideActionEphemerallyInToolbar();

chrome/browser/ui/views/frame/browser_view.cc

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,6 +4354,26 @@ BookmarkBar::State BrowserView::bookmark_bar_state() const {
43544354
return BookmarkBarController::From(browser_.get())->bookmark_bar_state();
43554355
}
43564356

4357+
void BrowserView::UpdateTabSearchBubbleHost() {
4358+
if (!GetIsNormalType()) {
4359+
return;
4360+
}
4361+
4362+
if (features::HasTabSearchToolbarButton()) {
4363+
tab_search_bubble_host_ = std::make_unique<TabSearchBubbleHost>(
4364+
toolbar_->tab_search_button(), browser_.get());
4365+
if (auto* controller = browser_->browser_window_features()
4366+
->tab_search_toolbar_button_controller()) {
4367+
controller->UpdateBubbleHost(tab_search_bubble_host_.get());
4368+
}
4369+
} else {
4370+
tab_search_bubble_host_ = std::make_unique<TabSearchBubbleHost>(
4371+
BrowserElementsViews::From(browser_.get())
4372+
->GetViewAs<TabSearchButton>(kTabSearchButtonElementId),
4373+
browser_.get());
4374+
}
4375+
}
4376+
43574377
void BrowserView::ShowSplitView(bool focus_active_view) {
43584378
CHECK(multi_contents_view_);
43594379
const int active_index = browser_->tab_strip_model()->active_index();
@@ -4932,17 +4952,7 @@ void BrowserView::AddedToWidget() {
49324952

49334953
toolbar_->Init();
49344954

4935-
if (GetIsNormalType()) {
4936-
if (features::HasTabSearchToolbarButton()) {
4937-
tab_search_bubble_host_ = std::make_unique<TabSearchBubbleHost>(
4938-
toolbar_->tab_search_button(), browser_.get());
4939-
} else {
4940-
tab_search_bubble_host_ = std::make_unique<TabSearchBubbleHost>(
4941-
BrowserElementsViews::From(browser_.get())
4942-
->GetViewAs<TabSearchButton>(kTabSearchButtonElementId),
4943-
browser_.get());
4944-
}
4945-
}
4955+
UpdateTabSearchBubbleHost();
49464956

49474957
// TODO(pbos): Investigate whether the side panels should be creatable when
49484958
// the ToolbarView does not create a button for them. This specifically seems
@@ -5181,6 +5191,13 @@ void BrowserView::MaybeInitializeWebUITabStrip() {
51815191
GetBrowserViewLayout()->set_loading_bar(loading_bar_);
51825192
if (toolbar_) {
51835193
toolbar_->UpdateForWebUITabStrip();
5194+
5195+
// Do not show Tab Search bubble host when web ui tab strip is enabled.
5196+
if (auto* tab_search_toolbar_button_controller =
5197+
browser_->browser_window_features()
5198+
->tab_search_toolbar_button_controller()) {
5199+
tab_search_toolbar_button_controller->UpdateBubbleHost(nullptr);
5200+
}
51845201
}
51855202
#endif // BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
51865203
}

chrome/browser/ui/views/frame/browser_view.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,9 @@ class BrowserView : public BrowserWindow,
901901
// Returns the state of the bookmark bar.
902902
BookmarkBar::State bookmark_bar_state() const;
903903

904+
// Setter for the BrowserView's TabSearchBubbleHost instance.
905+
void UpdateTabSearchBubbleHost();
906+
904907
// Display the current active split view as a series of multiple side-by-side
905908
// web contents.
906909
void ShowSplitView(bool focus_active_view);

chrome/browser/ui/views/toolbar/toolbar_view.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,6 @@ void ToolbarView::UpdateCustomTabBarVisibility(bool visible, bool animate) {
610610

611611
void ToolbarView::UpdateForWebUITabStrip() {
612612
#if BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
613-
TabSearchToolbarButtonController* tab_search_toolbar_button_controller =
614-
browser_->browser_window_features()
615-
->tab_search_toolbar_button_controller();
616-
if (tab_search_toolbar_button_controller) {
617-
tab_search_toolbar_button_controller->UpdateForWebUITabStrip();
618-
}
619-
620613
if (!new_tab_button_) {
621614
return;
622615
}

0 commit comments

Comments
 (0)