diff options
author | edwardjung <edwardjung@chromium.org> | 2016-01-15 06:18:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-15 14:19:48 +0000 |
commit | b7dac1a6a7997c1c7bb440d5eb5a4aa6ee38cf8b (patch) | |
tree | 45d01a5f31121f2b7fb272441e2505829fb3f0d6 /ui | |
parent | 3d14d22a68702b3ec8118f1fe60a3bc2bd002f30 (diff) | |
download | chromium_src-b7dac1a6a7997c1c7bb440d5eb5a4aa6ee38cf8b.zip chromium_src-b7dac1a6a7997c1c7bb440d5eb5a4aa6ee38cf8b.tar.gz chromium_src-b7dac1a6a7997c1c7bb440d5eb5a4aa6ee38cf8b.tar.bz2 |
Incognito NTP style tweaks
BUG=512984
Review URL: https://codereview.chromium.org/1516233003
Cr-Commit-Position: refs/heads/master@{#369736}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/webui/web_ui_util.cc | 15 | ||||
-rw-r--r-- | ui/base/webui/web_ui_util.h | 8 | ||||
-rw-r--r-- | ui/webui/resources/css/roboto.css | 8 | ||||
-rw-r--r-- | ui/webui/resources/css/text_defaults_md.css | 31 | ||||
-rw-r--r-- | ui/webui/resources/roboto/roboto-light.woff2 | bin | 0 -> 61372 bytes | |||
-rw-r--r-- | ui/webui/resources/webui_resources.grd | 7 |
6 files changed, 65 insertions, 4 deletions
diff --git a/ui/base/webui/web_ui_util.cc b/ui/base/webui/web_ui_util.cc index 7c894f6..d9c1d76 100644 --- a/ui/base/webui/web_ui_util.cc +++ b/ui/base/webui/web_ui_util.cc @@ -122,19 +122,30 @@ void SetLoadTimeDataDefaults(const std::string& app_locale, localized_strings->SetString("textdirection", GetTextDirection()); } -std::string GetWebUiCssTextDefaults() { +std::string GetWebUiCssTextDefaults(const std::string& css_template) { std::map<base::StringPiece, std::string> placeholders; placeholders["textDirection"] = GetTextDirection(); placeholders["fontFamily"] = GetFontFamily(); placeholders["fontSize"] = GetFontSize(); + return ui::ReplaceTemplateExpressions(css_template, placeholders); +} +std::string GetWebUiCssTextDefaults() { const ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); const std::string& css_template = resource_bundle.GetRawDataResource(IDR_WEBUI_CSS_TEXT_DEFAULTS) .as_string(); + return GetWebUiCssTextDefaults(css_template); +} - return ui::ReplaceTemplateExpressions(css_template, placeholders); +std::string GetWebUiCssTextDefaultsMd() { + const ui::ResourceBundle& resource_bundle = + ui::ResourceBundle::GetSharedInstance(); + const std::string& css_template = + resource_bundle.GetRawDataResource(IDR_WEBUI_CSS_TEXT_DEFAULTS_MD) + .as_string(); + return GetWebUiCssTextDefaults(css_template); } void AppendWebUiCssTextDefaults(std::string* html) { diff --git a/ui/base/webui/web_ui_util.h b/ui/base/webui/web_ui_util.h index c774af9..dc24839 100644 --- a/ui/base/webui/web_ui_util.h +++ b/ui/base/webui/web_ui_util.h @@ -50,9 +50,17 @@ UI_BASE_EXPORT void SetLoadTimeDataDefaults( const std::string& app_locale, base::DictionaryValue* localized_strings); +// Get a CSS declaration for common text styles using provided template. +UI_BASE_EXPORT std::string GetWebUiCssTextDefaults( + const std::string& css_template); + // Get a CSS declaration for common text styles for all of Web UI. UI_BASE_EXPORT std::string GetWebUiCssTextDefaults(); +// Get a CSS declaration for common text styles for Web UI using +// Material Design. +UI_BASE_EXPORT std::string GetWebUiCssTextDefaultsMd(); + // Appends the CSS declaration returned by GetWebUiCssTextDefaults() as an // inline stylesheet. UI_BASE_EXPORT void AppendWebUiCssTextDefaults(std::string* html); diff --git a/ui/webui/resources/css/roboto.css b/ui/webui/resources/css/roboto.css index 34c0ad7..c9554f2 100644 --- a/ui/webui/resources/css/roboto.css +++ b/ui/webui/resources/css/roboto.css @@ -5,6 +5,14 @@ @font-face { font-family: 'Roboto'; font-style: normal; + font-weight: 300; + src: local('Roboto Light'), local('Roboto-Light'), + url(chrome://resources/roboto/roboto-light.woff2) format('woff2'); +} + +@font-face { + font-family: 'Roboto'; + font-style: normal; font-weight: 400; src: local('Roboto'), local('Roboto-Regular'), url(chrome://resources/roboto/roboto-regular.woff2) format('woff2'); diff --git a/ui/webui/resources/css/text_defaults_md.css b/ui/webui/resources/css/text_defaults_md.css new file mode 100644 index 0000000..a2b2022 --- /dev/null +++ b/ui/webui/resources/css/text_defaults_md.css @@ -0,0 +1,31 @@ +/* Copyright 2015 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. */ + +/* This file is dynamically processed by a C++ data source handler to fill in + * some per-platform/locale styles that dramatically alter the page. This is + * done to reduce flicker, as JS may not run before the page is rendered. + * + * There are two ways to include this stylesheet: + * 1. via its chrome://resources/ URL in HTML, i.e.: + * + * <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css"> + * + * 2. via the webui::AppendWebUICSSTextDefaultsMd() method to directly append it + * to an HTML string. + * Otherwise its $placeholders won't be expanded. */ + +@import url(chrome://resources/css/roboto.css); + +html { + direction: ${textDirection}; +} + +body { + font-family: Roboto, ${fontFamily}; + font-size: ${fontSize}; +} + +button { + font-family: Roboto, ${fontFamily}; +} diff --git a/ui/webui/resources/roboto/roboto-light.woff2 b/ui/webui/resources/roboto/roboto-light.woff2 Binary files differnew file mode 100644 index 0000000..49288bc --- /dev/null +++ b/ui/webui/resources/roboto/roboto-light.woff2 diff --git a/ui/webui/resources/webui_resources.grd b/ui/webui/resources/webui_resources.grd index 8abacac..df687b7 100644 --- a/ui/webui/resources/webui_resources.grd +++ b/ui/webui/resources/webui_resources.grd @@ -16,9 +16,10 @@ without changes to the corresponding grd file. --> <include name="IDR_WEBUI_I18N_TEMPLATE_JS" file="js/i18n_template.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_WEBUI_JSTEMPLATE_JS" file="js/jstemplate_compiled.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_WEBUI_ANALYTICS_JS" file="js/analytics.js" flattenhtml="true" type="BINDATA" /> - <!-- Roboto Font. Roboto-Regular is already available on Android, and - Roboto-Medium is not used on Android. --> + <!-- Roboto Font. Roboto-Regular and Roboto-Light is already available on + Android, and Roboto-Medium is not used on Android. --> <if expr="not android"> + <include name="IDR_WEBUI_ROBOTO_ROBOTO_LIGHT_WOFF2" file="roboto/roboto-light.woff2" type="BINDATA" /> <include name="IDR_WEBUI_ROBOTO_ROBOTO_REGULAR_WOFF2" file="roboto/roboto-regular.woff2" type="BINDATA" /> <include name="IDR_WEBUI_ROBOTO_ROBOTO_MEDIUM_WOFF2" file="roboto/roboto-medium.woff2" type="BINDATA" /> </if> @@ -230,6 +231,8 @@ without changes to the corresponding grd file. --> flattenhtml="true" /> <structure name="IDR_WEBUI_CSS_TEXT_DEFAULTS" file="css/text_defaults.css" type="chrome_html" /> + <structure name="IDR_WEBUI_CSS_TEXT_DEFAULTS_MD" + file="css/text_defaults_md.css" type="chrome_html" /> <structure name="IDR_WEBUI_CSS_OVERLAY" file="css/overlay.css" type="chrome_html" flattenhtml="true" /> |