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

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

Issue 747923004: webui: minimize webui flicker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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 c67e23edd40ef2c96b7873e3b7757800d1bc0be3..3dfa9189fd99e5a0dd4d008a280c892dd0715a1e 100644
--- a/ui/base/webui/web_ui_util.cc
+++ b/ui/base/webui/web_ui_util.cc
@@ -26,6 +26,35 @@
#include "base/win/windows_version.h"
#endif
+namespace {
+
+std::string GetFontFamily() {
+ int web_font_family_id = IDS_WEB_FONT_FAMILY;
+#if defined(OS_WIN)
+ if (base::win::GetVersion() < base::win::VERSION_VISTA)
+ web_font_family_id = IDS_WEB_FONT_FAMILY_XP;
+#endif
+ std::string font_family = l10n_util::GetStringUTF8(web_font_family_id);
+// TODO(dnicoara) Remove Ozone check when PlatformFont support is introduced
+// into Ozone: crbug.com/320050
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE)
+ font_family = ui::ResourceBundle::GetSharedInstance().GetFont(
+ ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family;
+#endif
+ return font_family;
+}
+
+std::string GetFontSize() {
+ int web_font_size_id = IDS_WEB_FONT_SIZE;
+#if defined(OS_WIN)
+ if (base::win::GetVersion() < base::win::VERSION_VISTA)
+ web_font_size_id = IDS_WEB_FONT_SIZE_XP;
+#endif
+ return l10n_util::GetStringUTF8(web_font_size_id);
+}
+
+}
Evan Stade 2014/11/22 05:14:44 nit: // namespace
+
namespace webui {
std::string GetBitmapDataUrl(const SkBitmap& bitmap) {
@@ -125,32 +154,16 @@ void ParsePathAndScale(const GURL& url,
}
}
-// static
void SetFontAndTextDirection(base::DictionaryValue* localized_strings) {
- int web_font_family_id = IDS_WEB_FONT_FAMILY;
- int web_font_size_id = IDS_WEB_FONT_SIZE;
-#if defined(OS_WIN)
- // Vary font settings for Windows XP.
- if (base::win::GetVersion() < base::win::VERSION_VISTA) {
- web_font_family_id = IDS_WEB_FONT_FAMILY_XP;
- web_font_size_id = IDS_WEB_FONT_SIZE_XP;
- }
-#endif
-
- std::string font_family = l10n_util::GetStringUTF8(web_font_family_id);
-
-// TODO(dnicoara) Remove Ozone check when PlatformFont support is introduced
-// into Ozone: crbug.com/320050
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE)
- font_family = ui::ResourceBundle::GetSharedInstance().GetFont(
- ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family;
-#endif
-
- localized_strings->SetString("fontfamily", font_family);
- localized_strings->SetString("fontsize",
- l10n_util::GetStringUTF8(web_font_size_id));
+ localized_strings->SetString("fontfamily", GetFontFamily());
+ localized_strings->SetString("fontsize", GetFontSize());
localized_strings->SetString("textdirection",
base::i18n::IsRTL() ? "rtl" : "ltr");
}
+std::string ReplaceFontFamilyAndSize(const std::string& html_page) {
+ std::vector<std::string> replacements = { GetFontFamily(), GetFontSize() };
+ return ReplaceStringPlaceholders(html_page, replacements, NULL);
+}
+
} // namespace webui

Powered by Google App Engine
This is Rietveld 408576698