Commit 533531b6 authored by Dave Schuyler's avatar Dave Schuyler Committed by Commit Bot

[Omnibox] Restore tab switch button

This CL reverts part of CL/952669 until a better fix is found for showing
the tab switch button (which stopped displaying with CL/952669).

Bug: None
Change-Id: Ia5896087c644f6998350a06d783d7dd58c3f919a
Reviewed-on: https://chromium-review.googlesource.com/961734Reviewed-by: default avatarKevin Bailey <krb@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Dave Schuyler <dschuyler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543189}
parent 97b0b8a4
......@@ -155,9 +155,10 @@ OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model,
GetVectorIconColor()));
keyword_icon_view_->SizeToPreferredSize();
tab_switch_button_ = new OmniboxTabSwitchButton(this);
AddChildView(tab_switch_button_);
tab_switch_button_->SetVisible(false);
if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial()) {
tab_switch_button_.reset(new OmniboxTabSwitchButton(this));
tab_switch_button_->set_owned_by_client();
}
}
OmniboxResultView::~OmniboxResultView() {}
......@@ -186,10 +187,17 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) {
image_view_->SetVisible(false); // Until SetAnswerImage is called.
keyword_icon_view_->SetVisible(match_.associated_keyword.get());
if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial()) {
tab_switch_button_->SetVisible(match.type ==
AutocompleteMatchType::TAB_SEARCH);
if (tab_switch_button_) {
if (match.type == AutocompleteMatchType::TAB_SEARCH &&
!keyword_icon_view_->visible()) {
if (!tab_switch_button_->parent()) {
AddChildView(tab_switch_button_.get());
}
} else if (tab_switch_button_->parent()) {
RemoveChildView(tab_switch_button_.get());
}
}
Invalidate();
if (GetWidget())
Layout();
......@@ -300,12 +308,12 @@ bool OmniboxResultView::OnMouseDragged(const ui::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton()) {
if (GetState() != SELECTED)
model_->SetSelectedLine(model_index_);
if (tab_switch_button_->visible()) {
if (tab_switch_button_ && tab_switch_button_->parent()) {
gfx::Point point_in_child_coords(event.location());
View::ConvertPointToTarget(this, tab_switch_button_,
View::ConvertPointToTarget(this, tab_switch_button_.get(),
&point_in_child_coords);
if (tab_switch_button_->HitTestPoint(point_in_child_coords)) {
SetMouseHandler(tab_switch_button_);
SetMouseHandler(tab_switch_button_.get());
return false;
}
}
......@@ -520,8 +528,7 @@ void OmniboxResultView::Layout() {
}
}
if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial() &&
match_.type == AutocompleteMatchType::TAB_SEARCH) {
if (tab_switch_button_ && match_.type == AutocompleteMatchType::TAB_SEARCH) {
const int ts_button_width = tab_switch_button_->GetPreferredSize().width();
const int ts_button_height = height();
tab_switch_button_->SetSize(gfx::Size(ts_button_width, ts_button_height));
......
......@@ -149,7 +149,7 @@ class OmniboxResultView : public views::View,
views::ImageView* icon_view_; // Small icon. e.g. favicon.
views::ImageView* image_view_; // Larger image for rich suggestions.
views::ImageView* keyword_icon_view_; // An icon resembling a '>'.
OmniboxTabSwitchButton* tab_switch_button_;
std::unique_ptr<OmniboxTabSwitchButton> tab_switch_button_;
OmniboxTextView* content_view_;
OmniboxTextView* description_view_;
OmniboxTextView* keyword_content_view_;
......
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