Commit 5efb86e6 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Views: Fix Tab Search UI keyboard shortcut invocation

This CL updates the Tab Search keyboard shortcut to use the same code
path as the TabSearchButton.

This is necessary to ensure that the button is triggered correctly
when the UI is invoked and prevents multiple instances of the UI from
being created per browser window.

Bug: 1099917
Change-Id: I3f31b0c6ba1620ca77a2197bd71a1241b904bb36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387199Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803599}
parent 01bbf565
...@@ -2622,12 +2622,12 @@ const views::Widget* BrowserView::GetWidget() const { ...@@ -2622,12 +2622,12 @@ const views::Widget* BrowserView::GetWidget() const {
} }
void BrowserView::CreateTabSearchBubble() { void BrowserView::CreateTabSearchBubble() {
// TODO(tluk): This should be triggering the TabSearchButton in the tab strip // Only log the open action if it resulted in creating a new instance of the
// rather than creating the Tab Search bubble directly. // Tab Search bubble.
TabSearchBubbleView::CreateTabSearchBubble(browser_->profile(), if (tabstrip_->tab_search_button()->ShowTabSearchBubble()) {
tabstrip_->tab_search_button());
base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction", base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction",
TabSearchOpenAction::kKeyboardShortcut); TabSearchOpenAction::kKeyboardShortcut);
}
} }
void BrowserView::RevealTabStripIfNeeded() { void BrowserView::RevealTabStripIfNeeded() {
......
...@@ -53,17 +53,12 @@ void TabSearchButton::FrameColorsChanged() { ...@@ -53,17 +53,12 @@ void TabSearchButton::FrameColorsChanged() {
void TabSearchButton::ButtonPressed(views::Button* sender, void TabSearchButton::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (bubble_) // Only log the open action if it resulted in creating a new instance of the
return; // Tab Search bubble.
bubble_ = TabSearchBubbleView::CreateTabSearchBubble( if (ShowTabSearchBubble()) {
tab_strip()->controller()->GetProfile(), this);
observed_bubble_widget_.Add(bubble_);
// Hold the pressed lock while the |bubble_| is active.
pressed_lock_ = menu_button_controller_->TakeLock();
base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction", base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction",
GetActionForEvent(event)); GetActionForEvent(event));
}
} }
void TabSearchButton::OnWidgetClosing(views::Widget* widget) { void TabSearchButton::OnWidgetClosing(views::Widget* widget) {
...@@ -74,6 +69,18 @@ void TabSearchButton::OnWidgetClosing(views::Widget* widget) { ...@@ -74,6 +69,18 @@ void TabSearchButton::OnWidgetClosing(views::Widget* widget) {
tab_strip()->OnTabSearchBubbleClosed(); tab_strip()->OnTabSearchBubbleClosed();
} }
bool TabSearchButton::ShowTabSearchBubble() {
if (bubble_)
return false;
bubble_ = TabSearchBubbleView::CreateTabSearchBubble(
tab_strip()->controller()->GetProfile(), this);
observed_bubble_widget_.Add(bubble_);
// Hold the pressed lock while the |bubble_| is active.
pressed_lock_ = menu_button_controller_->TakeLock();
return true;
}
bool TabSearchButton::IsBubbleVisible() const { bool TabSearchButton::IsBubbleVisible() const {
return bubble_ && bubble_->IsVisible(); return bubble_ && bubble_->IsVisible();
} }
......
...@@ -45,6 +45,11 @@ class TabSearchButton : public NewTabButton, ...@@ -45,6 +45,11 @@ class TabSearchButton : public NewTabButton,
// views::WidgetObserver: // views::WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override; void OnWidgetClosing(views::Widget* widget) override;
// When this is called the bubble may already be showing or be loading in.
// This returns true if the method call results in the creation of a new Tab
// Search bubble.
bool ShowTabSearchBubble();
bool IsBubbleVisible() const; bool IsBubbleVisible() const;
views::Widget* bubble_for_testing() { return bubble_; } views::Widget* bubble_for_testing() { return bubble_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment