Commit edf7e440 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[WebUI][NTP] Adds the remaining realbox resources

Bug: 1041129
Change-Id: I2536d27d869d0fe98b5b3f474f152ad9947cd065
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2162085Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762121}
parent 8218744a
...@@ -231,11 +231,11 @@ body.hide-fakebox #fakebox { ...@@ -231,11 +231,11 @@ body.hide-fakebox #fakebox {
right: 16px; right: 16px;
} }
#realbox-icon[data-icon='google_g'] { #realbox-icon[data-icon='google_g.png'] {
background-size: 12px; background-size: 12px;
} }
#realbox-icon[data-icon='search'] { #realbox-icon[data-icon='search.svg'] {
-webkit-mask-size: 20px; /* Loupe in realbox is bigger than in matches. */ -webkit-mask-size: 20px; /* Loupe in realbox is bigger than in matches. */
} }
......
...@@ -80,11 +80,17 @@ ...@@ -80,11 +80,17 @@
right: 16px; right: 16px;
} }
#realboxIcon[data-icon='search'] { #realboxIcon[data-icon='search.svg'] {
-webkit-mask-image: url(chrome://resources/images/icon_search.svg); -webkit-mask-image: url(search.svg);
-webkit-mask-size: 20px; /* "Search" icon is larger than the other icons. */ -webkit-mask-size: 20px; /* "Search" icon is larger than the other icons. */
} }
#realboxIcon[data-icon='google_g.png'] {
background-color: transparent;
background-image: url(google_g.png);
background-size: 12px;
}
#voiceSearchButton { #voiceSearchButton {
background-size: 21px; background-size: 21px;
background: url(icons/googlemic_clr_24px.svg) no-repeat center; background: url(icons/googlemic_clr_24px.svg) no-repeat center;
...@@ -108,7 +114,7 @@ ...@@ -108,7 +114,7 @@
} }
</style> </style>
<div id="realboxInputWrapper"> <div id="realboxInputWrapper">
<div id="realboxIcon" data-icon="search"></div> <div id="realboxIcon" data-icon$="[[realboxIcon_]]"></div>
<input type="search" autocomplete="off" spellcheck="false" <input type="search" autocomplete="off" spellcheck="false"
aria-live="polite" placeholder="$i18n{searchBoxHint}"> aria-live="polite" placeholder="$i18n{searchBoxHint}">
</input> </input>
......
...@@ -27,6 +27,11 @@ class RealboxElement extends PolymerElement { ...@@ -27,6 +27,11 @@ class RealboxElement extends PolymerElement {
type: Object, type: Object,
observer: 'onThemeChange_', observer: 'onThemeChange_',
}, },
realboxIcon_: {
type: String,
value: () => loadTimeData.getString('realboxDefaultIcon')
}
}; };
} }
......
...@@ -38,22 +38,22 @@ CreateSuggestionGroupsMap( ...@@ -38,22 +38,22 @@ CreateSuggestionGroupsMap(
} // namespace } // namespace
const char kGoogleGIconResourceName[] = "google_g"; const char kGoogleGIconResourceName[] = "google_g.png";
const char kBookmarkIconResourceName[] = "bookmark"; const char kBookmarkIconResourceName[] = "bookmark.svg";
const char kCalculatorIconResourceName[] = "calculator"; const char kCalculatorIconResourceName[] = "calculator.svg";
const char kClockIconResourceName[] = "clock"; const char kClockIconResourceName[] = "clock.svg";
const char kDriveDocsIconResourceName[] = "drive_docs"; const char kDriveDocsIconResourceName[] = "drive_docs.svg";
const char kDriveFolderIconResourceName[] = "drive_folder"; const char kDriveFolderIconResourceName[] = "drive_folder.svg";
const char kDriveFormIconResourceName[] = "drive_form"; const char kDriveFormIconResourceName[] = "drive_form.svg";
const char kDriveImageIconResourceName[] = "drive_image"; const char kDriveImageIconResourceName[] = "drive_image.svg";
const char kDriveLogoIconResourceName[] = "drive_logo"; const char kDriveLogoIconResourceName[] = "drive_logo.svg";
const char kDrivePdfIconResourceName[] = "drive_pdf"; const char kDrivePdfIconResourceName[] = "drive_pdf.svg";
const char kDriveSheetsIconResourceName[] = "drive_sheets"; const char kDriveSheetsIconResourceName[] = "drive_sheets.svg";
const char kDriveSlidesIconResourceName[] = "drive_slides"; const char kDriveSlidesIconResourceName[] = "drive_slides.svg";
const char kDriveVideoIconResourceName[] = "drive_video"; const char kDriveVideoIconResourceName[] = "drive_video.svg";
const char kExtensionAppIconResourceName[] = "extension_app"; const char kExtensionAppIconResourceName[] = "extension_app.svg";
const char kPageIconResourceName[] = "page"; const char kPageIconResourceName[] = "page.svg";
const char kSearchIconResourceName[] = "search"; const char kSearchIconResourceName[] = "search.svg";
std::string AutocompleteMatchVectorIconToResourceName( std::string AutocompleteMatchVectorIconToResourceName(
const gfx::VectorIcon& icon) { const gfx::VectorIcon& icon) {
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
#include "chrome/browser/search/instant_service_factory.h" #include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/ntp_features.h" #include "chrome/browser/search/ntp_features.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search/omnibox_mojo_utils.h"
#include "chrome/browser/ui/webui/favicon_source.h" #include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h" #include "chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h"
#include "chrome/browser/ui/webui/new_tab_page/untrusted_source.h" #include "chrome/browser/ui/webui/new_tab_page/untrusted_source.h"
#include "chrome/browser/ui/webui/webui_util.h" #include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/new_tab_page_resources.h" #include "chrome/grit/new_tab_page_resources.h"
#include "chrome/grit/new_tab_page_resources_map.h" #include "chrome/grit/new_tab_page_resources_map.h"
...@@ -27,6 +29,7 @@ ...@@ -27,6 +29,7 @@
#include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
#include "ui/resources/grit/webui_resources.h"
using content::BrowserContext; using content::BrowserContext;
using content::WebContents; using content::WebContents;
...@@ -52,17 +55,23 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) { ...@@ -52,17 +55,23 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
.GoogleBaseURLValue()) .GoogleBaseURLValue())
.spec()); .spec());
// Realbox.
source->AddBoolean("realboxEnabled", ntp_features::IsRealboxEnabled()); source->AddBoolean("realboxEnabled", ntp_features::IsRealboxEnabled());
source->AddBoolean( source->AddBoolean(
"realboxMatchOmniboxTheme", "realboxMatchOmniboxTheme",
base::FeatureList::IsEnabled(ntp_features::kRealboxMatchOmniboxTheme)); base::FeatureList::IsEnabled(ntp_features::kRealboxMatchOmniboxTheme));
source->AddString(
"realboxDefaultIcon",
base::FeatureList::IsEnabled(ntp_features::kRealboxUseGoogleGIcon)
? omnibox::kGoogleGIconResourceName
: omnibox::kSearchIconResourceName);
static constexpr webui::LocalizedString kStrings[] = { static constexpr webui::LocalizedString kStrings[] = {
{"doneButton", IDS_DONE}, {"doneButton", IDS_DONE},
{"title", IDS_NEW_TAB_TITLE}, {"title", IDS_NEW_TAB_TITLE},
{"undo", IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE}, {"undo", IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE},
// Custom Links // Custom Links.
{"addLinkTitle", IDS_NTP_CUSTOM_LINKS_ADD_SHORTCUT_TITLE}, {"addLinkTitle", IDS_NTP_CUSTOM_LINKS_ADD_SHORTCUT_TITLE},
{"editLinkTitle", IDS_NTP_CUSTOM_LINKS_EDIT_SHORTCUT}, {"editLinkTitle", IDS_NTP_CUSTOM_LINKS_EDIT_SHORTCUT},
{"invalidUrl", IDS_NTP_CUSTOM_LINKS_INVALID_URL}, {"invalidUrl", IDS_NTP_CUSTOM_LINKS_INVALID_URL},
...@@ -119,8 +128,10 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) { ...@@ -119,8 +128,10 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"voiceSearchButtonLabel", IDS_TOOLTIP_MIC_SEARCH}, {"voiceSearchButtonLabel", IDS_TOOLTIP_MIC_SEARCH},
{"waiting", IDS_NEW_TAB_VOICE_WAITING}, {"waiting", IDS_NEW_TAB_VOICE_WAITING},
// Search box. // Realbox.
{"searchBoxHint", IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD}, {"searchBoxHint", IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD},
{"realboxSeparator", IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR},
{"removeSuggestion", IDS_OMNIBOX_REMOVE_SUGGESTION},
// Logo/doodle. // Logo/doodle.
{"copyLink", IDS_NTP_DOODLE_SHARE_DIALOG_COPY_LABEL}, {"copyLink", IDS_NTP_DOODLE_SHARE_DIALOG_COPY_LABEL},
...@@ -132,6 +143,28 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) { ...@@ -132,6 +143,28 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
}; };
AddLocalizedStringsBulk(source, kStrings); AddLocalizedStringsBulk(source, kStrings);
// Register images that are purposefully not inlined in the HTML and instead
// are set in Javascript.
static constexpr webui::ResourcePath kImages[] = {
{omnibox::kGoogleGIconResourceName, IDR_WEBUI_IMAGES_200_LOGO_GOOGLE_G},
{omnibox::kBookmarkIconResourceName, IDR_LOCAL_NTP_ICONS_BOOKMARK},
{omnibox::kCalculatorIconResourceName, IDR_LOCAL_NTP_ICONS_CALCULATOR},
{omnibox::kClockIconResourceName, IDR_LOCAL_NTP_ICONS_CLOCK},
{omnibox::kDriveDocsIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_DOCS},
{omnibox::kDriveFolderIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_FOLDER},
{omnibox::kDriveFormIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_FORM},
{omnibox::kDriveImageIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_IMAGE},
{omnibox::kDriveLogoIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_LOGO},
{omnibox::kDrivePdfIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_PDF},
{omnibox::kDriveSheetsIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_SHEETS},
{omnibox::kDriveSlidesIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_SLIDES},
{omnibox::kDriveVideoIconResourceName, IDR_LOCAL_NTP_ICONS_DRIVE_VIDEO},
{omnibox::kExtensionAppIconResourceName,
IDR_LOCAL_NTP_ICONS_EXTENSION_APP},
{omnibox::kPageIconResourceName, IDR_LOCAL_NTP_ICONS_PAGE},
{omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH}};
webui::AddResourcePathsBulk(source, kImages);
source->AddResourcePath("skcolor.mojom-lite.js", source->AddResourcePath("skcolor.mojom-lite.js",
IDR_NEW_TAB_PAGE_SKCOLOR_MOJO_LITE_JS); IDR_NEW_TAB_PAGE_SKCOLOR_MOJO_LITE_JS);
source->AddResourcePath("new_tab_page.mojom-lite.js", source->AddResourcePath("new_tab_page.mojom-lite.js",
......
...@@ -71,4 +71,26 @@ suite('NewTabPageRealboxTest', () => { ...@@ -71,4 +71,26 @@ suite('NewTabPageRealboxTest', () => {
assertStyle(realbox, '--search-box-text', 'rgba(0, 0, 12, 255)'); assertStyle(realbox, '--search-box-text', 'rgba(0, 0, 12, 255)');
assertStyle(realbox, '--search-box-icon', 'rgba(0, 0, 1, 255)'); assertStyle(realbox, '--search-box-icon', 'rgba(0, 0, 1, 255)');
}); });
test('realbox default icon', async () => {
// Assert.
assertStyle(
realbox.$.realboxIcon, '-webkit-mask-image',
'url("chrome://new-tab-page/search.svg")');
assertStyle(realbox.$.realboxIcon, 'background-image', 'none');
// Arrange.
loadTimeData.overrideValues({
realboxDefaultIcon: 'google_g.png',
});
PolymerTest.clearBody();
realbox = document.createElement('ntp-realbox');
document.body.appendChild(realbox);
// Assert.
assertStyle(realbox.$.realboxIcon, '-webkit-mask-image', 'none');
assertStyle(
realbox.$.realboxIcon, 'background-image',
'url("chrome://new-tab-page/google_g.png")');
});
}); });
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