Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Unified Diff: ui/base/webui/web_ui_util.cc

Issue 830743003: Directly inline shared WebUI CSS declarations into the security and supervised user interstitials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: revert stuff Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/webui/web_ui_util.h ('k') | ui/webui/resources/css/text_defaults.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/webui/web_ui_util.cc
diff --git a/ui/base/webui/web_ui_util.cc b/ui/base/webui/web_ui_util.cc
index 0c5b9f0a1787591dbb60b3c547e235fd9b2d6b54..3382a3034cd03da4feddfc7729460fee0a900eaa 100644
--- a/ui/base/webui/web_ui_util.cc
+++ b/ui/base/webui/web_ui_util.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
#include "net/base/escape.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -19,6 +20,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/resources/grit/webui_resources.h"
#include "ui/strings/grit/app_locale_settings.h"
#include "url/gurl.h"
@@ -129,6 +131,33 @@ void ParsePathAndScale(const GURL& url,
}
}
+void SetFontAndTextDirection(base::DictionaryValue* localized_strings) {
+ localized_strings->SetString("fontfamily", GetFontFamily());
+ localized_strings->SetString("fontsize", GetFontSize());
+ localized_strings->SetString("textdirection", GetTextDirection());
+}
+
+std::string GetWebUiCssTextDefaults() {
+ std::vector<std::string> placeholders;
+ placeholders.push_back(GetTextDirection()); // $1
+ placeholders.push_back(GetFontFamily()); // $2
+ placeholders.push_back(GetFontSize()); // $3
+
+ const ui::ResourceBundle& resource_bundle =
+ ui::ResourceBundle::GetSharedInstance();
+ const std::string& css_template =
+ resource_bundle.GetRawDataResource(IDR_WEBUI_CSS_TEXT_DEFAULTS)
+ .as_string();
+
+ return ReplaceStringPlaceholders(css_template, placeholders, nullptr);
+}
+
+void AppendWebUiCssTextDefaults(std::string* html) {
+ html->append("<style>");
+ html->append(GetWebUiCssTextDefaults());
+ html->append("</style>");
+}
+
std::string GetFontFamily() {
std::string font_family = l10n_util::GetStringUTF8(
#if defined(OS_WIN)
@@ -164,10 +193,4 @@ std::string GetTextDirection() {
return base::i18n::IsRTL() ? "rtl" : "ltr";
}
-void SetFontAndTextDirection(base::DictionaryValue* localized_strings) {
- localized_strings->SetString("fontfamily", GetFontFamily());
- localized_strings->SetString("fontsize", GetFontSize());
- localized_strings->SetString("textdirection", GetTextDirection());
-}
-
} // namespace webui
« no previous file with comments | « ui/base/webui/web_ui_util.h ('k') | ui/webui/resources/css/text_defaults.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698