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, ...@@ -155,9 +155,10 @@ OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model,
GetVectorIconColor())); GetVectorIconColor()));
keyword_icon_view_->SizeToPreferredSize(); keyword_icon_view_->SizeToPreferredSize();
tab_switch_button_ = new OmniboxTabSwitchButton(this); if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial()) {
AddChildView(tab_switch_button_); tab_switch_button_.reset(new OmniboxTabSwitchButton(this));
tab_switch_button_->SetVisible(false); tab_switch_button_->set_owned_by_client();
}
} }
OmniboxResultView::~OmniboxResultView() {} OmniboxResultView::~OmniboxResultView() {}
...@@ -186,10 +187,17 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) { ...@@ -186,10 +187,17 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) {
image_view_->SetVisible(false); // Until SetAnswerImage is called. image_view_->SetVisible(false); // Until SetAnswerImage is called.
keyword_icon_view_->SetVisible(match_.associated_keyword.get()); keyword_icon_view_->SetVisible(match_.associated_keyword.get());
if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial()) { if (tab_switch_button_) {
tab_switch_button_->SetVisible(match.type == if (match.type == AutocompleteMatchType::TAB_SEARCH &&
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(); Invalidate();
if (GetWidget()) if (GetWidget())
Layout(); Layout();
...@@ -300,12 +308,12 @@ bool OmniboxResultView::OnMouseDragged(const ui::MouseEvent& event) { ...@@ -300,12 +308,12 @@ bool OmniboxResultView::OnMouseDragged(const ui::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton()) { if (event.IsOnlyLeftMouseButton()) {
if (GetState() != SELECTED) if (GetState() != SELECTED)
model_->SetSelectedLine(model_index_); 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()); 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); &point_in_child_coords);
if (tab_switch_button_->HitTestPoint(point_in_child_coords)) { if (tab_switch_button_->HitTestPoint(point_in_child_coords)) {
SetMouseHandler(tab_switch_button_); SetMouseHandler(tab_switch_button_.get());
return false; return false;
} }
} }
...@@ -520,8 +528,7 @@ void OmniboxResultView::Layout() { ...@@ -520,8 +528,7 @@ void OmniboxResultView::Layout() {
} }
} }
if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial() && if (tab_switch_button_ && match_.type == AutocompleteMatchType::TAB_SEARCH) {
match_.type == AutocompleteMatchType::TAB_SEARCH) {
const int ts_button_width = tab_switch_button_->GetPreferredSize().width(); const int ts_button_width = tab_switch_button_->GetPreferredSize().width();
const int ts_button_height = height(); const int ts_button_height = height();
tab_switch_button_->SetSize(gfx::Size(ts_button_width, ts_button_height)); tab_switch_button_->SetSize(gfx::Size(ts_button_width, ts_button_height));
......
...@@ -149,7 +149,7 @@ class OmniboxResultView : public views::View, ...@@ -149,7 +149,7 @@ class OmniboxResultView : public views::View,
views::ImageView* icon_view_; // Small icon. e.g. favicon. views::ImageView* icon_view_; // Small icon. e.g. favicon.
views::ImageView* image_view_; // Larger image for rich suggestions. views::ImageView* image_view_; // Larger image for rich suggestions.
views::ImageView* keyword_icon_view_; // An icon resembling a '>'. views::ImageView* keyword_icon_view_; // An icon resembling a '>'.
OmniboxTabSwitchButton* tab_switch_button_; std::unique_ptr<OmniboxTabSwitchButton> tab_switch_button_;
OmniboxTextView* content_view_; OmniboxTextView* content_view_;
OmniboxTextView* description_view_; OmniboxTextView* description_view_;
OmniboxTextView* keyword_content_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