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

Unified Diff: chrome/browser/tab_contents/render_view_host_delegate_helper.cc

Issue 7606028: Pass per-script fonts to WebKit settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch to commit Created 9 years, 4 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
Index: chrome/browser/tab_contents/render_view_host_delegate_helper.cc
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
index 78cbf565985dff44932d3ae9d3a1bcf8bcb7138c..41da738ef1a6cfc44ef1b96ff27588f536d444cb 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
@@ -38,6 +38,24 @@
#include "content/common/view_messages.h"
#include "net/base/network_change_notifier.h"
+namespace {
+
+// Fills |map| with the per-script font prefs under path |map_name|.
+void FillFontFamilyMap(const PrefService* prefs,
+ const char* map_name,
+ WebPreferences::ScriptFontFamilyMap* map) {
+ for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
+ const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
+ std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
+ std::string font_family = prefs->GetString(pref_name.c_str());
+ if (!font_family.empty())
+ map->push_back(std::make_pair(script, UTF8ToUTF16(font_family)));
+ }
+}
+
+} // namespace
+
+
RenderViewHostDelegateViewHelper::RenderViewHostDelegateViewHelper() {
registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
NotificationService::AllSources());
@@ -319,6 +337,19 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
web_prefs.fantasy_font_family =
UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily));
+ FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
+ &web_prefs.standard_font_family_map);
+ FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
+ &web_prefs.fixed_font_family_map);
+ FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
+ &web_prefs.serif_font_family_map);
+ FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
+ &web_prefs.sans_serif_font_family_map);
+ FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
+ &web_prefs.cursive_font_family_map);
+ FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
+ &web_prefs.fantasy_font_family_map);
+
web_prefs.default_font_size =
prefs->GetInteger(prefs::kWebKitDefaultFontSize);
web_prefs.default_fixed_font_size =

Powered by Google App Engine
This is Rietveld 408576698