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 {
}
void BrowserView::CreateTabSearchBubble() {
// TODO(tluk): This should be triggering the TabSearchButton in the tab strip
// rather than creating the Tab Search bubble directly.
TabSearchBubbleView::CreateTabSearchBubble(browser_->profile(),
tabstrip_->tab_search_button());
base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction",
TabSearchOpenAction::kKeyboardShortcut);
// Only log the open action if it resulted in creating a new instance of the
// Tab Search bubble.
if (tabstrip_->tab_search_button()->ShowTabSearchBubble()) {
base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction",
TabSearchOpenAction::kKeyboardShortcut);
}
}
void BrowserView::RevealTabStripIfNeeded() {
......
......@@ -53,17 +53,12 @@ void TabSearchButton::FrameColorsChanged() {
void TabSearchButton::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (bubble_)
return;
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();
base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction",
GetActionForEvent(event));
// Only log the open action if it resulted in creating a new instance of the
// Tab Search bubble.
if (ShowTabSearchBubble()) {
base::UmaHistogramEnumeration("Tabs.TabSearch.OpenAction",
GetActionForEvent(event));
}
}
void TabSearchButton::OnWidgetClosing(views::Widget* widget) {
......@@ -74,6 +69,18 @@ void TabSearchButton::OnWidgetClosing(views::Widget* widget) {
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 {
return bubble_ && bubble_->IsVisible();
}
......
......@@ -45,6 +45,11 @@ class TabSearchButton : public NewTabButton,
// views::WidgetObserver:
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;
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