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

Side by Side Diff: chrome/browser/ui/prefs/prefs_tab_helper.cc

Issue 2454583002: Update the default generic font family settings for Chinese/Japanese (Closed)
Patch Set: Remove Times New Roman Created 4 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 unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 struct FontDefault { 169 struct FontDefault {
170 const char* pref_name; 170 const char* pref_name;
171 int resource_id; 171 int resource_id;
172 }; 172 };
173 173
174 // Font pref defaults. The prefs that have defaults vary by platform, since not 174 // Font pref defaults. The prefs that have defaults vary by platform, since not
175 // all platforms have fonts for all scripts for all generic families. 175 // all platforms have fonts for all scripts for all generic families.
176 // TODO(falken): add proper defaults when possible for all 176 // TODO(falken): add proper defaults when possible for all
177 // platforms/scripts/generic families. 177 // platforms/scripts/generic families.
178 const FontDefault kFontDefaults[] = { 178 const FontDefault kFontDefaults[] = {
179 { prefs::kWebKitStandardFontFamily, IDS_STANDARD_FONT_FAMILY }, 179 {prefs::kWebKitStandardFontFamily, IDS_STANDARD_FONT_FAMILY},
180 { prefs::kWebKitFixedFontFamily, IDS_FIXED_FONT_FAMILY }, 180 {prefs::kWebKitFixedFontFamily, IDS_FIXED_FONT_FAMILY},
181 { prefs::kWebKitSerifFontFamily, IDS_SERIF_FONT_FAMILY }, 181 {prefs::kWebKitSerifFontFamily, IDS_SERIF_FONT_FAMILY},
182 { prefs::kWebKitSansSerifFontFamily, IDS_SANS_SERIF_FONT_FAMILY }, 182 {prefs::kWebKitSansSerifFontFamily, IDS_SANS_SERIF_FONT_FAMILY},
183 { prefs::kWebKitCursiveFontFamily, IDS_CURSIVE_FONT_FAMILY }, 183 {prefs::kWebKitCursiveFontFamily, IDS_CURSIVE_FONT_FAMILY},
184 { prefs::kWebKitFantasyFontFamily, IDS_FANTASY_FONT_FAMILY }, 184 {prefs::kWebKitFantasyFontFamily, IDS_FANTASY_FONT_FAMILY},
185 { prefs::kWebKitPictographFontFamily, IDS_PICTOGRAPH_FONT_FAMILY }, 185 {prefs::kWebKitPictographFontFamily, IDS_PICTOGRAPH_FONT_FAMILY},
186 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) || defined(OS_WIN) 186 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) || defined(OS_WIN)
187 { prefs::kWebKitStandardFontFamilyJapanese, 187 {prefs::kWebKitStandardFontFamilyJapanese,
188 IDS_STANDARD_FONT_FAMILY_JAPANESE }, 188 IDS_STANDARD_FONT_FAMILY_JAPANESE},
189 { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE }, 189 {prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE},
190 { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE }, 190 {prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE},
191 { prefs::kWebKitSansSerifFontFamilyJapanese, 191 {prefs::kWebKitSansSerifFontFamilyJapanese,
192 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE }, 192 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE},
193 { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN }, 193 {prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN},
194 { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN }, 194 {prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN},
195 { prefs::kWebKitSansSerifFontFamilyKorean, 195 {prefs::kWebKitSansSerifFontFamilyKorean,
196 IDS_SANS_SERIF_FONT_FAMILY_KOREAN }, 196 IDS_SANS_SERIF_FONT_FAMILY_KOREAN},
197 { prefs::kWebKitStandardFontFamilySimplifiedHan, 197 {prefs::kWebKitStandardFontFamilySimplifiedHan,
198 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN }, 198 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN},
199 { prefs::kWebKitSerifFontFamilySimplifiedHan, 199 {prefs::kWebKitSerifFontFamilySimplifiedHan,
200 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, 200 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN},
201 { prefs::kWebKitSansSerifFontFamilySimplifiedHan, 201 {prefs::kWebKitSansSerifFontFamilySimplifiedHan,
202 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, 202 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN},
203 { prefs::kWebKitStandardFontFamilyTraditionalHan, 203 {prefs::kWebKitStandardFontFamilyTraditionalHan,
204 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN }, 204 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN},
205 { prefs::kWebKitSerifFontFamilyTraditionalHan, 205 {prefs::kWebKitSerifFontFamilyTraditionalHan,
206 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }, 206 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN},
207 { prefs::kWebKitSansSerifFontFamilyTraditionalHan, 207 {prefs::kWebKitSansSerifFontFamilyTraditionalHan,
208 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }, 208 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN},
209 #endif
210 #if defined(OS_MACOSX) || defined(OS_WIN)
211 {prefs::kWebKitCursiveFontFamilySimplifiedHan,
212 IDS_CURSIVE_FONT_FAMILY_SIMPLIFIED_HAN},
213 {prefs::kWebKitCursiveFontFamilyTraditionalHan,
214 IDS_CURSIVE_FONT_FAMILY_TRADITIONAL_HAN},
209 #endif 215 #endif
210 #if defined(OS_CHROMEOS) 216 #if defined(OS_CHROMEOS)
211 { prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC }, 217 {prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC},
212 { prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC }, 218 {prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC},
213 { prefs::kWebKitSansSerifFontFamilyArabic, 219 {prefs::kWebKitSansSerifFontFamilyArabic,
214 IDS_SANS_SERIF_FONT_FAMILY_ARABIC }, 220 IDS_SANS_SERIF_FONT_FAMILY_ARABIC},
215 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN }, 221 {prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN},
216 { prefs::kWebKitFixedFontFamilySimplifiedHan, 222 {prefs::kWebKitFixedFontFamilySimplifiedHan,
217 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN }, 223 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN},
218 { prefs::kWebKitFixedFontFamilyTraditionalHan, 224 {prefs::kWebKitFixedFontFamilyTraditionalHan,
219 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN }, 225 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
220 #elif defined(OS_WIN) 226 #elif defined(OS_WIN)
221 { prefs::kWebKitFixedFontFamilyArabic, IDS_FIXED_FONT_FAMILY_ARABIC }, 227 {prefs::kWebKitFixedFontFamilyArabic, IDS_FIXED_FONT_FAMILY_ARABIC},
222 { prefs::kWebKitSansSerifFontFamilyArabic, 228 {prefs::kWebKitSansSerifFontFamilyArabic,
223 IDS_SANS_SERIF_FONT_FAMILY_ARABIC }, 229 IDS_SANS_SERIF_FONT_FAMILY_ARABIC},
224 { prefs::kWebKitStandardFontFamilyCyrillic, 230 {prefs::kWebKitStandardFontFamilyCyrillic,
225 IDS_STANDARD_FONT_FAMILY_CYRILLIC }, 231 IDS_STANDARD_FONT_FAMILY_CYRILLIC},
226 { prefs::kWebKitFixedFontFamilyCyrillic, IDS_FIXED_FONT_FAMILY_CYRILLIC }, 232 {prefs::kWebKitFixedFontFamilyCyrillic, IDS_FIXED_FONT_FAMILY_CYRILLIC},
227 { prefs::kWebKitSerifFontFamilyCyrillic, IDS_SERIF_FONT_FAMILY_CYRILLIC }, 233 {prefs::kWebKitSerifFontFamilyCyrillic, IDS_SERIF_FONT_FAMILY_CYRILLIC},
228 { prefs::kWebKitSansSerifFontFamilyCyrillic, 234 {prefs::kWebKitSansSerifFontFamilyCyrillic,
229 IDS_SANS_SERIF_FONT_FAMILY_CYRILLIC }, 235 IDS_SANS_SERIF_FONT_FAMILY_CYRILLIC},
230 { prefs::kWebKitStandardFontFamilyGreek, IDS_STANDARD_FONT_FAMILY_GREEK }, 236 {prefs::kWebKitStandardFontFamilyGreek, IDS_STANDARD_FONT_FAMILY_GREEK},
231 { prefs::kWebKitFixedFontFamilyGreek, IDS_FIXED_FONT_FAMILY_GREEK }, 237 {prefs::kWebKitFixedFontFamilyGreek, IDS_FIXED_FONT_FAMILY_GREEK},
232 { prefs::kWebKitSerifFontFamilyGreek, IDS_SERIF_FONT_FAMILY_GREEK }, 238 {prefs::kWebKitSerifFontFamilyGreek, IDS_SERIF_FONT_FAMILY_GREEK},
233 { prefs::kWebKitSansSerifFontFamilyGreek, IDS_SANS_SERIF_FONT_FAMILY_GREEK }, 239 {prefs::kWebKitSansSerifFontFamilyGreek, IDS_SANS_SERIF_FONT_FAMILY_GREEK},
234 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN }, 240 {prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN},
235 { prefs::kWebKitCursiveFontFamilyKorean, IDS_CURSIVE_FONT_FAMILY_KOREAN }, 241 {prefs::kWebKitCursiveFontFamilyKorean, IDS_CURSIVE_FONT_FAMILY_KOREAN},
236 { prefs::kWebKitFixedFontFamilySimplifiedHan, 242 {prefs::kWebKitFixedFontFamilySimplifiedHan,
237 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN }, 243 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN},
238 { prefs::kWebKitFixedFontFamilyTraditionalHan, 244 {prefs::kWebKitFixedFontFamilyTraditionalHan,
239 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN }, 245 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
240 #endif 246 #endif
241 }; 247 };
242 248
243 const size_t kFontDefaultsLength = arraysize(kFontDefaults); 249 const size_t kFontDefaultsLength = arraysize(kFontDefaults);
244 250
245 // Returns the script of the font pref |pref_name|. For example, suppose 251 // Returns the script of the font pref |pref_name|. For example, suppose
246 // |pref_name| is "webkit.webprefs.fonts.serif.Hant". Since the script code for 252 // |pref_name| is "webkit.webprefs.fonts.serif.Hant". Since the script code for
247 // the script name "Hant" is USCRIPT_TRADITIONAL_HAN, the function returns 253 // the script name "Hant" is USCRIPT_TRADITIONAL_HAN, the function returns
248 // USCRIPT_TRADITIONAL_HAN. |pref_name| must be a valid font pref name. 254 // USCRIPT_TRADITIONAL_HAN. |pref_name| must be a valid font pref name.
249 UScriptCode GetScriptOfFontPref(const char* pref_name) { 255 UScriptCode GetScriptOfFontPref(const char* pref_name) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 UScriptCode browser_script = GetScriptOfBrowserLocale(); 549 UScriptCode browser_script = GetScriptOfBrowserLocale();
544 for (size_t i = 0; i < kFontDefaultsLength; ++i) { 550 for (size_t i = 0; i < kFontDefaultsLength; ++i) {
545 FontDefault pref = kFontDefaults[i]; 551 FontDefault pref = kFontDefaults[i];
546 552
547 #if defined(OS_WIN) 553 #if defined(OS_WIN)
548 if (pref.pref_name == prefs::kWebKitFixedFontFamily) { 554 if (pref.pref_name == prefs::kWebKitFixedFontFamily) {
549 if (ShouldUseAlternateDefaultFixedFont( 555 if (ShouldUseAlternateDefaultFixedFont(
550 l10n_util::GetStringUTF8(pref.resource_id))) 556 l10n_util::GetStringUTF8(pref.resource_id)))
551 pref.resource_id = IDS_FIXED_FONT_FAMILY_ALT_WIN; 557 pref.resource_id = IDS_FIXED_FONT_FAMILY_ALT_WIN;
552 } 558 }
553
554 // The standard font (Meiryo) isn't installed by default as of Win 10.
555 if (base::win::GetVersion() >= base::win::VERSION_WIN10) {
556 if (pref.pref_name == prefs::kWebKitStandardFontFamilyJapanese) {
557 pref.resource_id = IDS_STANDARD_FONT_FAMILY_JAPANESE_ALT_WIN;
558 } else if (pref.pref_name == prefs::kWebKitSansSerifFontFamilyJapanese) {
559 pref.resource_id = IDS_SANS_SERIF_FONT_FAMILY_JAPANESE_ALT_WIN;
560 }
561 }
562 #endif 559 #endif
563 560
564 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name); 561 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name);
565 562
566 // Suppress this default font pref value if it is for the primary script of 563 // Suppress this default font pref value if it is for the primary script of
567 // the browser's UI locale. For example, if the pref is for the sans-serif 564 // the browser's UI locale. For example, if the pref is for the sans-serif
568 // font for the Cyrillic script, and the browser locale is "ru" (Russian), 565 // font for the Cyrillic script, and the browser locale is "ru" (Russian),
569 // the default is suppressed. Otherwise, the default would override the 566 // the default is suppressed. Otherwise, the default would override the
570 // user's font preferences when viewing pages in their native language. 567 // user's font preferences when viewing pages in their native language.
571 // This is because users have no way yet of customizing their per-script 568 // This is because users have no way yet of customizing their per-script
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 671 }
675 672
676 void PrefsTabHelper::NotifyWebkitPreferencesChanged( 673 void PrefsTabHelper::NotifyWebkitPreferencesChanged(
677 const std::string& pref_name) { 674 const std::string& pref_name) {
678 #if !defined(OS_ANDROID) 675 #if !defined(OS_ANDROID)
679 OnFontFamilyPrefChanged(pref_name); 676 OnFontFamilyPrefChanged(pref_name);
680 #endif 677 #endif
681 678
682 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); 679 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged();
683 } 680 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698