| 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..3f0d234707765647b2c25dc7addce4744f08e1d7 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"
|
| @@ -119,16 +120,34 @@ const char* kPrefsToObserve[] = {
|
|
|
| const int kPrefsToObserveLength = arraysize(kPrefsToObserve);
|
|
|
| -// Registers a preference under the path |map_name| for each script used for
|
| -// per-script font prefs. For example, if |map_name| is "fonts.serif", then
|
| +// Registers a preference under the path |pref_name| for each script used for
|
| +// per-script font prefs.
|
| +// For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"):
|
| // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered.
|
| -void RegisterFontFamilyMap(PrefRegistrySyncable* registry,
|
| - 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();
|
| +// |fonts_with_defaults| contains all |pref_names| already registered since they
|
| +// have a specified default value.
|
| +void RegisterFontFamilyPrefs(PrefRegistrySyncable* registry,
|
| + const std::set<std::string>& fonts_with_defaults) {
|
| +
|
| + // 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 +565,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);
|
| + RegisterFontFamilyPrefs(registry, fonts_with_defaults);
|
|
|
| registry->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize,
|
| IDS_DEFAULT_FONT_SIZE,
|
|
|