Commit 5ac5785a authored by Kevin Bailey's avatar Kevin Bailey Committed by Commit Bot

[omnibox] Fix tab switch suggestion visuals when button present

When we're using a button to trigger tab switches, we don't want the
description or icon hinting at switching, since the main suggestion
won't switch in this state.

In addition to these tiny changes, it adds a new icon for the button,
per the UI spec.

Bug: 780835
Change-Id: I01d0c913292852e6ecaf569c1feecccbebd0646d
Reviewed-on: https://chromium-review.googlesource.com/943831
Commit-Queue: Kevin Bailey <krb@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540338}
parent 6d73147b
...@@ -17,7 +17,7 @@ class OmniboxTabSwitchButton : public views::LabelButton, ...@@ -17,7 +17,7 @@ class OmniboxTabSwitchButton : public views::LabelButton,
views::ButtonListener { views::ButtonListener {
public: public:
explicit OmniboxTabSwitchButton(OmniboxResultView* result_view) explicit OmniboxTabSwitchButton(OmniboxResultView* result_view)
: LabelButton(this, base::ASCIIToUTF16("Switch tabs")), : LabelButton(this, base::ASCIIToUTF16("Switch to open tab")),
result_view_(result_view) { result_view_(result_view) {
// TODO: SetTooltipText(text); // TODO: SetTooltipText(text);
// SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE); // SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
...@@ -26,7 +26,7 @@ class OmniboxTabSwitchButton : public views::LabelButton, ...@@ -26,7 +26,7 @@ class OmniboxTabSwitchButton : public views::LabelButton,
SetBackground( SetBackground(
std::make_unique<BackgroundWith1PxBorder>(bg_color, SK_ColorBLACK)); std::make_unique<BackgroundWith1PxBorder>(bg_color, SK_ColorBLACK));
SetImage(STATE_NORMAL, SetImage(STATE_NORMAL,
gfx::CreateVectorIcon(omnibox::kTabIcon, 16, SK_ColorBLACK)); gfx::CreateVectorIcon(omnibox::kSwitchIcon, 16, SK_ColorBLACK));
} }
void SetPressed(); void SetPressed();
......
...@@ -30,6 +30,7 @@ aggregate_vector_icons("omnibox_vector_icons") { ...@@ -30,6 +30,7 @@ aggregate_vector_icons("omnibox_vector_icons") {
"keyword_search.icon", "keyword_search.icon",
"star.1x.icon", "star.1x.icon",
"star.icon", "star.icon",
"switch.icon",
"tab.icon", "tab.icon",
"touchable_bookmark.icon", "touchable_bookmark.icon",
"touchable_clear.icon", "touchable_clear.icon",
......
...@@ -197,6 +197,12 @@ const gfx::VectorIcon& AutocompleteMatch::TypeToVectorIcon(Type type, ...@@ -197,6 +197,12 @@ const gfx::VectorIcon& AutocompleteMatch::TypeToVectorIcon(Type type,
return is_touch_ui ? omnibox::kTouchableBookmarkIcon : omnibox::kStarIcon; return is_touch_ui ? omnibox::kTouchableBookmarkIcon : omnibox::kStarIcon;
switch (type) { switch (type) {
case Type::TAB_SEARCH:
if (!OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial())
return omnibox::kTabIcon;
// Behave like history match.
FALLTHROUGH;
case Type::URL_WHAT_YOU_TYPED: case Type::URL_WHAT_YOU_TYPED:
case Type::HISTORY_URL: case Type::HISTORY_URL:
case Type::HISTORY_TITLE: case Type::HISTORY_TITLE:
...@@ -210,9 +216,6 @@ const gfx::VectorIcon& AutocompleteMatch::TypeToVectorIcon(Type type, ...@@ -210,9 +216,6 @@ const gfx::VectorIcon& AutocompleteMatch::TypeToVectorIcon(Type type,
case Type::PHYSICAL_WEB_OVERFLOW: case Type::PHYSICAL_WEB_OVERFLOW:
return is_touch_ui ? omnibox::kTouchablePageIcon : omnibox::kHttpIcon; return is_touch_ui ? omnibox::kTouchablePageIcon : omnibox::kHttpIcon;
case Type::TAB_SEARCH:
return omnibox::kTabIcon;
case Type::SEARCH_WHAT_YOU_TYPED: case Type::SEARCH_WHAT_YOU_TYPED:
case Type::SEARCH_HISTORY: case Type::SEARCH_HISTORY:
case Type::SEARCH_SUGGEST: case Type::SEARCH_SUGGEST:
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/omnibox/browser/autocomplete_input.h" #include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/in_memory_url_index_types.h" #include "components/omnibox/browser/in_memory_url_index_types.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "url/url_util.h" #include "url/url_util.h"
...@@ -110,6 +111,8 @@ void HistoryProvider::ConvertOpenTabMatches() { ...@@ -110,6 +111,8 @@ void HistoryProvider::ConvertOpenTabMatches() {
// If url is in a tab, change type, update classification. // If url is in a tab, change type, update classification.
if (client()->IsTabOpenWithURL(match.destination_url)) { if (client()->IsTabOpenWithURL(match.destination_url)) {
match.type = AutocompleteMatchType::TAB_SEARCH; match.type = AutocompleteMatchType::TAB_SEARCH;
if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial())
continue;
const base::string16 switch_tab_message = const base::string16 switch_tab_message =
l10n_util::GetStringUTF16(IDS_OMNIBOX_TAB_SUGGEST_HINT) + l10n_util::GetStringUTF16(IDS_OMNIBOX_TAB_SUGGEST_HINT) +
base::UTF8ToUTF16(match.description.empty() ? "" : " - "); base::UTF8ToUTF16(match.description.empty() ? "" : " - ");
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 32,
MOVE_TO, 4, 6,
LINE_TO, 26, 6,
LINE_TO, 26, 24,
LINE_TO, 4, 24,
LINE_TO, 4, 8,
LINE_TO, 5, 8,
LINE_TO, 5, 23,
LINE_TO, 25, 23,
LINE_TO, 25, 13,
LINE_TO, 16, 13,
LINE_TO, 16, 7,
LINE_TO, 4, 7,
CLOSE,
END
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