Commit 0e42201e authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[omnibox] Adds support for trending match icon on Desktop

- Displays trending icon for non-historical matches with SUBTYPE_TRENDS.
- Adds Vector and SVG icons for use in Omnibox and Realbox respectively.

The SVG was optimized using svgomg and converted to .icon using skiafy.

Omnibox: https://screenshot.googleplex.com/7iRhFnNGXP2Kh4j
Realbox: https://screenshot.googleplex.com/FjvWaT4DXonaFWz

Bug: 1122669
Change-Id: Ic9fd6594e633128eed0c2ff621509acdddf100f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386096Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804097}
parent 6f8919b6
......@@ -28,4 +28,6 @@
file="resources/local_ntp/icons/extension_app.svg" type="BINDATA" />
<include name="IDR_LOCAL_NTP_ICONS_PAGE"
file="resources/local_ntp/icons/page.svg" type="BINDATA" />
<include name="IDR_LOCAL_NTP_ICONS_TRENDING_UP"
file="resources/local_ntp/icons/trending_up.svg" type="BINDATA" />
</grit-part>
<svg width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.8 4v1.333h1.806L8.987 8.78l-2.8-2.667L1 11.06l.987.94 4.2-4 2.8 2.667L13.6 6.28V8H15V4h-4.2z" fill="#000"/></svg>
......@@ -171,6 +171,8 @@ const struct Resource{
{omnibox::kPageIconResourceName, IDR_LOCAL_NTP_ICONS_PAGE, "image/svg+xml"},
{omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH,
"image/svg+xml"},
{omnibox::kTrendingUpIconResourceName, IDR_LOCAL_NTP_ICONS_TRENDING_UP,
"image/svg+xml"},
};
// This enum must match the numbering for NTPSearchSuggestionsRequestStatusi in
......
......@@ -55,6 +55,7 @@ const char kDriveVideoIconResourceName[] = "drive_video.svg";
const char kExtensionAppIconResourceName[] = "extension_app.svg";
const char kPageIconResourceName[] = "page.svg";
const char kSearchIconResourceName[] = "search.svg";
const char kTrendingUpIconResourceName[] = "trending_up.svg";
std::string AutocompleteMatchVectorIconToResourceName(
const gfx::VectorIcon& icon) {
......@@ -92,6 +93,8 @@ std::string AutocompleteMatchVectorIconToResourceName(
return ""; // Pedals are not supported in the NTP Realbox.
} else if (icon.name == vector_icons::kSearchIcon.name) {
return kSearchIconResourceName;
} else if (icon.name == omnibox::kTrendingUpIcon.name) {
return kTrendingUpIconResourceName;
} else {
NOTREACHED()
<< "Every vector icon returned by AutocompleteMatch::GetVectorIcon "
......
......@@ -36,6 +36,7 @@ extern const char kDriveVideoIconResourceName[];
extern const char kExtensionAppIconResourceName[];
extern const char kPageIconResourceName[];
extern const char kSearchIconResourceName[];
extern const char kTrendingUpIconResourceName[];
std::string AutocompleteMatchVectorIconToResourceName(
const gfx::VectorIcon& icon);
......
......@@ -207,7 +207,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{omnibox::kExtensionAppIconResourceName,
IDR_LOCAL_NTP_ICONS_EXTENSION_APP},
{omnibox::kPageIconResourceName, IDR_LOCAL_NTP_ICONS_PAGE},
{omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH}};
{omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH},
{omnibox::kTrendingUpIconResourceName, IDR_LOCAL_NTP_ICONS_TRENDING_UP}};
webui::AddResourcePathsBulk(source, kImages);
#if BUILDFLAG(ENABLE_KALEIDOSCOPE)
......
......@@ -61,6 +61,7 @@ aggregate_vector_icons("omnibox_vector_icons") {
"star.icon",
"switch.icon",
"tab.icon",
"trending_up.icon",
]
}
......
......@@ -266,8 +266,13 @@ const gfx::VectorIcon& AutocompleteMatch::GetVectorIcon(
case Type::TAB_SEARCH_DEPRECATED:
return omnibox::kPageIcon;
case Type::SEARCH_SUGGEST: {
if (subtypes.contains(/*SUBTYPE_TRENDS=*/143))
return omnibox::kTrendingUpIcon;
return vector_icons::kSearchIcon;
}
case Type::SEARCH_WHAT_YOU_TYPED:
case Type::SEARCH_SUGGEST:
case Type::SEARCH_SUGGEST_ENTITY:
case Type::SEARCH_SUGGEST_PROFILE:
case Type::SEARCH_OTHER_ENGINE:
......
// Copyright 2020 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, 16,
MOVE_TO, 10.8f, 4,
R_V_LINE_TO, 1.33f,
R_H_LINE_TO, 1.81f,
LINE_TO, 8.99f, 8.78f,
R_LINE_TO, -2.8f, -2.67f,
LINE_TO, 1, 11.06f,
R_LINE_TO, 0.99f, 0.94f,
R_LINE_TO, 4.2f, -4,
R_LINE_TO, 2.8f, 2.67f,
LINE_TO, 13.6f, 6.28f,
V_LINE_TO, 8,
H_LINE_TO, 15,
V_LINE_TO, 4,
R_H_LINE_TO, -4.2f,
CLOSE
......@@ -21,6 +21,9 @@ OmniboxSuggestionIconType GetOmniboxSuggestionIconTypeForAutocompleteMatchType(
if (is_starred)
return BOOKMARK;
// TODO(crbug.com/1122669): Handle trending zero-prefix suggestions by
// checking the match subtype similar to AutocompleteMatch::GetVectorIcon().
switch (type) {
case AutocompleteMatchType::BOOKMARK_TITLE:
case AutocompleteMatchType::CLIPBOARD_URL:
......
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