Chromium Code Reviews| Index: chrome/browser/ui/prefs/prefs_tab_helper.cc |
| diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc |
| index 2e3c8ab1239342f9acbc7b5c4268ab51fe1c740a..13ed9906b501935af8b6c64c67a1a5f85b3e737b 100644 |
| --- a/chrome/browser/ui/prefs/prefs_tab_helper.cc |
| +++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc |
| @@ -15,6 +15,7 @@ |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/renderer_preferences_util.h" |
| #include "chrome/common/chrome_notification_types.h" |
| +#include "chrome/common/pref_font_webkit_names.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/pref_names_util.h" |
| #include "components/user_prefs/pref_registry_syncable.h" |
| @@ -123,12 +124,27 @@ const int kPrefsToObserveLength = arraysize(kPrefsToObserve); |
| // per-script font prefs. For example, if |map_name| is "fonts.serif", then |
| // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. |
| void RegisterFontFamilyMap(PrefRegistrySyncable* registry, |
|
falken
2013/03/19 18:26:04
Can you update this comment and change the functio
bulach
2013/03/20 11:01:27
Done.
|
| - const char* map_name, |
| const std::set<std::string>& fonts_with_defaults) { |
| - for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| - const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| - std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script); |
| - const char* pref_name = pref_name_str.c_str(); |
| + |
| + // Expand the font concatenated with script name so this stays at RO memory |
| + // rather than allocated in heap. |
| + static const char* const kFontFamilyMap[] = { |
| +#define EXPAND_SCRIPT_FONT(map_name, script_name) map_name "." script_name, |
| + |
| +#include "chrome/common/pref_font_script_names-inl.h" |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_CURSIVE) |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_FANTASY) |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_FIXED) |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_PICTOGRAPH) |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_SANSERIF) |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_SERIF) |
| +ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_STANDARD) |
| + |
| +#undef EXPAND_SCRIPT_FONT |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(kFontFamilyMap); ++i) { |
| + const char* pref_name = kFontFamilyMap[i]; |
| if (fonts_with_defaults.find(pref_name) == fonts_with_defaults.end()) { |
| // We haven't already set a default value for this font preference, so set |
| // an empty string as the default. |
| @@ -546,20 +562,7 @@ void PrefsTabHelper::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| } |
| // Register font prefs that don't have defaults. |
| - RegisterFontFamilyMap(registry, prefs::kWebKitStandardFontFamilyMap, |
| - fonts_with_defaults); |
| - RegisterFontFamilyMap(registry, prefs::kWebKitFixedFontFamilyMap, |
| - fonts_with_defaults); |
| - RegisterFontFamilyMap(registry, prefs::kWebKitSerifFontFamilyMap, |
| - fonts_with_defaults); |
| - RegisterFontFamilyMap(registry, prefs::kWebKitSansSerifFontFamilyMap, |
| - fonts_with_defaults); |
| - RegisterFontFamilyMap(registry, prefs::kWebKitCursiveFontFamilyMap, |
| - fonts_with_defaults); |
| - RegisterFontFamilyMap(registry, prefs::kWebKitFantasyFontFamilyMap, |
| - fonts_with_defaults); |
| - RegisterFontFamilyMap(registry, prefs::kWebKitPictographFontFamilyMap, |
| - fonts_with_defaults); |
| + RegisterFontFamilyMap(registry, fonts_with_defaults); |
| registry->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, |
| IDS_DEFAULT_FONT_SIZE, |