OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
6 | 6 |
7 #include "base/string_split.h" | 7 #include "base/string_split.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/prefs/overlay_user_pref_store.h" | 11 #include "chrome/browser/prefs/overlay_user_pref_store.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/renderer_preferences_util.h" | 14 #include "chrome/browser/renderer_preferences_util.h" |
15 #include "chrome/browser/themes/theme_service.h" | 15 #include "chrome/browser/themes/theme_service.h" |
16 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
17 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 17 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "grit/locale_settings.h" | 24 #include "grit/locale_settings.h" |
25 #include "grit/platform_locale_settings.h" | 25 #include "grit/platform_locale_settings.h" |
| 26 #include "unicode/uchar.h" |
| 27 #include "unicode/uscript.h" |
26 #include "webkit/glue/webpreferences.h" | 28 #include "webkit/glue/webpreferences.h" |
27 | 29 |
28 using content::WebContents; | 30 using content::WebContents; |
29 using webkit_glue::WebPreferences; | 31 using webkit_glue::WebPreferences; |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 // Registers prefs only used for migration. | 35 // Registers prefs only used for migration. |
34 static void RegisterPrefsToMigrate(PrefService* prefs) { | 36 static void RegisterPrefsToMigrate(PrefService* prefs) { |
35 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldStandardFontFamily, | 37 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldStandardFontFamily, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | 129 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
128 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | 130 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
129 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); | 131 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); |
130 registrar->Add(pref_name.c_str(), obs); | 132 registrar->Add(pref_name.c_str(), obs); |
131 } | 133 } |
132 } | 134 } |
133 | 135 |
134 struct FontDefault { | 136 struct FontDefault { |
135 const char* pref_name; | 137 const char* pref_name; |
136 int resource_id; | 138 int resource_id; |
137 | |
138 // The locale that matches the script this default pref is for. May be a | |
139 // comma-separated list. For example, for a Cyrillic font pref, | |
140 // |native_locale| is something like "sr,ru" (Serbian and Russian). When the | |
141 // locale of the browser process is in |native_locale|, the default is not | |
142 // registered to avoid overriding the user's font pref (see comments in | |
143 // PrefTabsHelper::RegisterUserPrefs). When |native_locale| is the empty | |
144 // string, the default is registered regardless of locale. | |
145 const char* native_locale; | |
146 }; | 139 }; |
147 | 140 |
148 // Locales that match Cyrllic script, according to ICU data. Only define | |
149 // |kCyrllicLocales| on platforms it's used on to avoid compiler error. | |
150 #if defined(OS_WIN) | |
151 const char* kCyrllicLocales = "be,bg,kk,mk,ru,sr,uk,uz"; | |
152 #endif | |
153 | |
154 // Font pref defaults. The prefs that have defaults vary by platform, since not | 141 // Font pref defaults. The prefs that have defaults vary by platform, since not |
155 // all platforms have fonts for all scripts for all generic families. | 142 // all platforms have fonts for all scripts for all generic families. |
156 // TODO(falken): add proper defaults when possible for all | 143 // TODO(falken): add proper defaults when possible for all |
157 // platforms/scripts/generic families. | 144 // platforms/scripts/generic families. |
158 const FontDefault kFontDefaults[] = { | 145 const FontDefault kFontDefaults[] = { |
159 { prefs::kWebKitStandardFontFamily, IDS_STANDARD_FONT_FAMILY, "" }, | 146 { prefs::kWebKitStandardFontFamily, IDS_STANDARD_FONT_FAMILY }, |
160 { prefs::kWebKitFixedFontFamily, IDS_FIXED_FONT_FAMILY, "" }, | 147 { prefs::kWebKitFixedFontFamily, IDS_FIXED_FONT_FAMILY }, |
161 { prefs::kWebKitSerifFontFamily, IDS_SERIF_FONT_FAMILY, "" }, | 148 { prefs::kWebKitSerifFontFamily, IDS_SERIF_FONT_FAMILY }, |
162 { prefs::kWebKitSansSerifFontFamily, IDS_SANS_SERIF_FONT_FAMILY, "" }, | 149 { prefs::kWebKitSansSerifFontFamily, IDS_SANS_SERIF_FONT_FAMILY }, |
163 { prefs::kWebKitCursiveFontFamily, IDS_CURSIVE_FONT_FAMILY, "" }, | 150 { prefs::kWebKitCursiveFontFamily, IDS_CURSIVE_FONT_FAMILY }, |
164 { prefs::kWebKitFantasyFontFamily, IDS_FANTASY_FONT_FAMILY, "" }, | 151 { prefs::kWebKitFantasyFontFamily, IDS_FANTASY_FONT_FAMILY }, |
165 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) || defined(OS_WIN) | 152 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) || defined(OS_WIN) |
166 { prefs::kWebKitStandardFontFamilyJapanese, | 153 { prefs::kWebKitStandardFontFamilyJapanese, |
167 IDS_STANDARD_FONT_FAMILY_JAPANESE, "ja" }, | 154 IDS_STANDARD_FONT_FAMILY_JAPANESE }, |
168 { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE, | 155 { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE }, |
169 "ja" }, | 156 { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE }, |
170 { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE, | |
171 "ja" }, | |
172 { prefs::kWebKitSansSerifFontFamilyJapanese, | 157 { prefs::kWebKitSansSerifFontFamilyJapanese, |
173 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE, "ja" }, | 158 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE }, |
174 { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN, | 159 { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN }, |
175 "ko" }, | 160 { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN }, |
176 { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN, "ko" }, | |
177 { prefs::kWebKitSansSerifFontFamilyKorean, | 161 { prefs::kWebKitSansSerifFontFamilyKorean, |
178 IDS_SANS_SERIF_FONT_FAMILY_KOREAN, "ko" }, | 162 IDS_SANS_SERIF_FONT_FAMILY_KOREAN }, |
179 { prefs::kWebKitStandardFontFamilySimplifiedHan, | 163 { prefs::kWebKitStandardFontFamilySimplifiedHan, |
180 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN, "zh-CN" }, | 164 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN }, |
181 { prefs::kWebKitSerifFontFamilySimplifiedHan, | 165 { prefs::kWebKitSerifFontFamilySimplifiedHan, |
182 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, "zh-CN" }, | 166 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, |
183 { prefs::kWebKitSansSerifFontFamilySimplifiedHan, | 167 { prefs::kWebKitSansSerifFontFamilySimplifiedHan, |
184 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, "zh-CN" }, | 168 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, |
185 { prefs::kWebKitStandardFontFamilyTraditionalHan, | 169 { prefs::kWebKitStandardFontFamilyTraditionalHan, |
186 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN, "zh-TW" }, | 170 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN }, |
187 { prefs::kWebKitSerifFontFamilyTraditionalHan, | 171 { prefs::kWebKitSerifFontFamilyTraditionalHan, |
188 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, "zh-TW" }, | 172 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }, |
189 { prefs::kWebKitSansSerifFontFamilyTraditionalHan, | 173 { prefs::kWebKitSansSerifFontFamilyTraditionalHan, |
190 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, "zh-TW" }, | 174 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }, |
191 #endif | 175 #endif |
192 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
193 { prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC, | 177 { prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC }, |
194 "ar" }, | 178 { prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC }, |
195 { prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC, "ar" }, | |
196 { prefs::kWebKitSansSerifFontFamilyArabic, | 179 { prefs::kWebKitSansSerifFontFamilyArabic, |
197 IDS_SANS_SERIF_FONT_FAMILY_ARABIC, "ar" }, | 180 IDS_SANS_SERIF_FONT_FAMILY_ARABIC }, |
198 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN, "ko" }, | 181 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN }, |
199 { prefs::kWebKitFixedFontFamilySimplifiedHan, | 182 { prefs::kWebKitFixedFontFamilySimplifiedHan, |
200 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN, "zh-CN" }, | 183 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN }, |
201 { prefs::kWebKitFixedFontFamilyTraditionalHan, | 184 { prefs::kWebKitFixedFontFamilyTraditionalHan, |
202 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN, "zh-TW" }, | 185 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN }, |
203 #elif defined(OS_WIN) | 186 #elif defined(OS_WIN) |
204 { prefs::kWebKitStandardFontFamilyCyrillic, | 187 { prefs::kWebKitStandardFontFamilyCyrillic, |
205 IDS_STANDARD_FONT_FAMILY_CYRILLIC, kCyrllicLocales }, | 188 IDS_STANDARD_FONT_FAMILY_CYRILLIC }, |
206 { prefs::kWebKitFixedFontFamilyCyrillic, | 189 { prefs::kWebKitFixedFontFamilyCyrillic, IDS_FIXED_FONT_FAMILY_CYRILLIC }, |
207 IDS_FIXED_FONT_FAMILY_CYRILLIC, kCyrllicLocales }, | 190 { prefs::kWebKitSerifFontFamilyCyrillic, IDS_SERIF_FONT_FAMILY_CYRILLIC }, |
208 { prefs::kWebKitSerifFontFamilyCyrillic, | |
209 IDS_SERIF_FONT_FAMILY_CYRILLIC, kCyrllicLocales }, | |
210 { prefs::kWebKitSansSerifFontFamilyCyrillic, | 191 { prefs::kWebKitSansSerifFontFamilyCyrillic, |
211 IDS_SANS_SERIF_FONT_FAMILY_CYRILLIC, kCyrllicLocales }, | 192 IDS_SANS_SERIF_FONT_FAMILY_CYRILLIC }, |
212 { prefs::kWebKitStandardFontFamilyGreek, | 193 { prefs::kWebKitStandardFontFamilyGreek, IDS_STANDARD_FONT_FAMILY_GREEK }, |
213 IDS_STANDARD_FONT_FAMILY_GREEK, "el" }, | 194 { prefs::kWebKitFixedFontFamilyGreek, IDS_FIXED_FONT_FAMILY_GREEK }, |
214 { prefs::kWebKitFixedFontFamilyGreek, IDS_FIXED_FONT_FAMILY_GREEK, "el" }, | 195 { prefs::kWebKitSerifFontFamilyGreek, IDS_SERIF_FONT_FAMILY_GREEK }, |
215 { prefs::kWebKitSerifFontFamilyGreek, IDS_SERIF_FONT_FAMILY_GREEK, "el" }, | 196 { prefs::kWebKitSansSerifFontFamilyGreek, IDS_SANS_SERIF_FONT_FAMILY_GREEK }, |
216 { prefs::kWebKitSansSerifFontFamilyGreek, | 197 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN }, |
217 IDS_SANS_SERIF_FONT_FAMILY_GREEK, "el" }, | 198 { prefs::kWebKitCursiveFontFamilyKorean, IDS_CURSIVE_FONT_FAMILY_KOREAN }, |
218 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN, "ko" }, | |
219 { prefs::kWebKitCursiveFontFamilyKorean, IDS_CURSIVE_FONT_FAMILY_KOREAN, | |
220 "ko" }, | |
221 { prefs::kWebKitFixedFontFamilySimplifiedHan, | 199 { prefs::kWebKitFixedFontFamilySimplifiedHan, |
222 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN, "zh-CN" }, | 200 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN }, |
223 { prefs::kWebKitFixedFontFamilyTraditionalHan, | 201 { prefs::kWebKitFixedFontFamilyTraditionalHan, |
224 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN, "zh-TW" }, | 202 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN }, |
225 #endif | 203 #endif |
226 }; | 204 }; |
227 | 205 |
228 const size_t kFontDefaultsLength = arraysize(kFontDefaults); | 206 const size_t kFontDefaultsLength = arraysize(kFontDefaults); |
229 | 207 |
230 // Returns true if |locale| matches a string in comma-separated list | 208 // Returns the script of the font pref |pref_name|. For example, suppose |
231 // |locale_list|. | 209 // |pref_name| is "webkit.webprefs.fonts.serif.Hant". Since the script code for |
232 static bool MatchesLocale(const std::string& locale, | 210 // the script name "Hant" is USCRIPT_TRADITIONAL_HAN, the function returns |
233 const std::string& locale_list) { | 211 // USCRIPT_TRADITIONAL_HAN. |pref_name| must be a valid font pref name. |
234 std::vector<std::string> list; | 212 UScriptCode GetScriptOfFontPref(const char* pref_name) { |
235 base::SplitString(locale_list, ',', &list); | 213 // ICU script names are four letters. |
236 for (std::vector<std::string>::const_iterator iter = list.begin(); | 214 static const size_t kScriptNameLength = 4; |
237 iter != list.end(); ++iter) { | 215 |
238 if (StartsWithASCII(locale, *iter, false)) | 216 size_t len = strlen(pref_name); |
239 return true; | 217 DCHECK_GT(len, kScriptNameLength); |
| 218 const char* scriptName = &pref_name[len - kScriptNameLength]; |
| 219 int32 code = u_getPropertyValueEnum(UCHAR_SCRIPT, scriptName); |
| 220 DCHECK(code >= 0 && code < USCRIPT_CODE_LIMIT); |
| 221 return static_cast<UScriptCode>(code); |
| 222 } |
| 223 |
| 224 // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 225 // the script code in that family that is used in font pref names. For example, |
| 226 // USCRIPT_HANGUL and USCRIPT_KOREAN are considered equivalent for the purposes |
| 227 // of font selection. Chrome uses the script code USCRIPT_HANGUL (script name |
| 228 // "Hang") in Korean font pref names (for example, |
| 229 // "webkit.webprefs.fonts.serif.Hang"). So, if |scriptCode| is USCRIPT_KOREAN, |
| 230 // the function returns USCRIPT_HANGUL. If |scriptCode| is not a member of such |
| 231 // a family, returns |scriptCode|. |
| 232 UScriptCode GetScriptForFontPrefMatching(UScriptCode scriptCode) { |
| 233 switch (scriptCode) { |
| 234 case USCRIPT_HIRAGANA: |
| 235 case USCRIPT_KATAKANA: |
| 236 case USCRIPT_JAPANESE: |
| 237 return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 238 case USCRIPT_KOREAN: |
| 239 return USCRIPT_HANGUL; |
| 240 default: |
| 241 return scriptCode; |
240 } | 242 } |
241 return false; | 243 } |
| 244 |
| 245 // Returns the primary script used by the browser's UI locale. For example, if |
| 246 // the locale is "ru", the function returns USCRIPT_CYRILLIC, and if the locale |
| 247 // is "en", the function returns USCRIPT_LATIN. |
| 248 UScriptCode GetScriptOfBrowserLocale() { |
| 249 std::string locale = g_browser_process->GetApplicationLocale(); |
| 250 |
| 251 UScriptCode code = USCRIPT_INVALID_CODE; |
| 252 UErrorCode err = U_ZERO_ERROR; |
| 253 uscript_getCode(locale.c_str(), &code, 1, &err); |
| 254 |
| 255 // Ignore the error that multiple scripts could be returned, since we only |
| 256 // want one script. |
| 257 if (U_FAILURE(err) && err != U_BUFFER_OVERFLOW_ERROR) |
| 258 code = USCRIPT_INVALID_CODE; |
| 259 return GetScriptForFontPrefMatching(code); |
242 } | 260 } |
243 | 261 |
244 const struct { | 262 const struct { |
245 const char* from; | 263 const char* from; |
246 const char* to; | 264 const char* to; |
247 } kPrefNamesToMigrate[] = { | 265 } kPrefNamesToMigrate[] = { |
248 // Migrate prefs like "webkit.webprefs.standard_font_family" to | 266 // Migrate prefs like "webkit.webprefs.standard_font_family" to |
249 // "webkit.webprefs.fonts.standard.Zyyy". This moves the formerly | 267 // "webkit.webprefs.fonts.standard.Zyyy". This moves the formerly |
250 // "non-per-script" font prefs into the per-script font pref maps, as the | 268 // "non-per-script" font prefs into the per-script font pref maps, as the |
251 // entry for the "Common" script (Zyyy is the ISO 15924 script code for the | 269 // entry for the "Common" script (Zyyy is the ISO 15924 script code for the |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 // Not used in OSX. | 426 // Not used in OSX. |
409 prefs->RegisterLocalizedStringPref(prefs::kAcceptLanguages, | 427 prefs->RegisterLocalizedStringPref(prefs::kAcceptLanguages, |
410 IDS_ACCEPT_LANGUAGES, | 428 IDS_ACCEPT_LANGUAGES, |
411 PrefService::UNSYNCABLE_PREF); | 429 PrefService::UNSYNCABLE_PREF); |
412 #endif | 430 #endif |
413 prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset, | 431 prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset, |
414 IDS_DEFAULT_ENCODING, | 432 IDS_DEFAULT_ENCODING, |
415 PrefService::SYNCABLE_PREF); | 433 PrefService::SYNCABLE_PREF); |
416 | 434 |
417 // Register font prefs that have defaults. | 435 // Register font prefs that have defaults. |
418 std::string locale = g_browser_process->GetApplicationLocale(); | 436 UScriptCode browser_script = GetScriptOfBrowserLocale(); |
419 for (size_t i = 0; i < kFontDefaultsLength; ++i) { | 437 for (size_t i = 0; i < kFontDefaultsLength; ++i) { |
420 const FontDefault& pref = kFontDefaults[i]; | 438 const FontDefault& pref = kFontDefaults[i]; |
421 // Suppress default per-script font when the script matches the browser's | 439 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name); |
422 // locale. Otherwise, the default would override the user's preferences | 440 |
423 // when viewing pages in their native language. This would be bad | 441 // Suppress this default font pref value if it is for the primary script of |
424 // particularly because there is not yet a way for users to customize | 442 // the browser's UI locale. For example, if the pref is for the sans-serif |
425 // their per-script font prefs. This code can possibly be removed later if | 443 // font for the Cyrillic script, and the browser locale is "ru" (Russian), |
426 // users can easily access per-script font prefs (e.g., via the extensions | 444 // the default is suppressed. Otherwise, the default would override the |
427 // workflow), or the problem turns out to not be really critical after all. | 445 // user's font preferences when viewing pages in their native language. |
428 if (!MatchesLocale(locale, pref.native_locale)) { | 446 // This is because users have no way yet of customizing their per-script |
| 447 // font preferences. The font prefs accessible in the options UI are for |
| 448 // the default, unknown script; these prefs have less priority than the |
| 449 // per-script font prefs when the script of the content is known. This code |
| 450 // can possibly be removed later if users can easily access per-script font |
| 451 // prefs (e.g., via the extensions workflow), or the problem turns out to |
| 452 // not be really critical after all. |
| 453 if (browser_script != pref_script) { |
429 prefs->RegisterLocalizedStringPref(pref.pref_name, | 454 prefs->RegisterLocalizedStringPref(pref.pref_name, |
430 pref.resource_id, | 455 pref.resource_id, |
431 PrefService::UNSYNCABLE_PREF); | 456 PrefService::UNSYNCABLE_PREF); |
432 } | 457 } |
433 } | 458 } |
434 | 459 |
435 // Register font prefs that don't have defaults. | 460 // Register font prefs that don't have defaults. |
436 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap); | 461 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap); |
437 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap); | 462 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap); |
438 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap); | 463 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 530 |
506 void PrefsTabHelper::UpdateRendererPreferences() { | 531 void PrefsTabHelper::UpdateRendererPreferences() { |
507 renderer_preferences_util::UpdateFromSystemSettings( | 532 renderer_preferences_util::UpdateFromSystemSettings( |
508 web_contents_->GetMutableRendererPrefs(), GetProfile()); | 533 web_contents_->GetMutableRendererPrefs(), GetProfile()); |
509 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 534 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
510 } | 535 } |
511 | 536 |
512 Profile* PrefsTabHelper::GetProfile() { | 537 Profile* PrefsTabHelper::GetProfile() { |
513 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 538 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
514 } | 539 } |
OLD | NEW |