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

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

Issue 346763011: Merge 279449 "Use Consolas for Windows 7 and above as default mo..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/resources/locale_settings_win.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 8
9 #include "base/prefs/overlay_user_pref_store.h" 9 #include "base/prefs/overlay_user_pref_store.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 16 matching lines...) Expand all
27 #include "grit/platform_locale_settings.h" 27 #include "grit/platform_locale_settings.h"
28 #include "third_party/icu/source/common/unicode/uchar.h" 28 #include "third_party/icu/source/common/unicode/uchar.h"
29 #include "third_party/icu/source/common/unicode/uscript.h" 29 #include "third_party/icu/source/common/unicode/uscript.h"
30 #include "webkit/common/webpreferences.h" 30 #include "webkit/common/webpreferences.h"
31 31
32 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) 32 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES)
33 #include "chrome/browser/themes/theme_service.h" 33 #include "chrome/browser/themes/theme_service.h"
34 #include "chrome/browser/themes/theme_service_factory.h" 34 #include "chrome/browser/themes/theme_service_factory.h"
35 #endif 35 #endif
36 36
37 #if defined(OS_WIN)
38 #include "base/win/windows_version.h"
39 #endif
40
37 using content::WebContents; 41 using content::WebContents;
38 42
39 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); 43 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper);
40 44
41 namespace { 45 namespace {
42 46
43 // The list of prefs we want to observe. 47 // The list of prefs we want to observe.
44 const char* kPrefsToObserve[] = { 48 const char* kPrefsToObserve[] = {
45 prefs::kDefaultCharset, 49 prefs::kDefaultCharset,
46 prefs::kWebKitAllowDisplayingInsecureContent, 50 prefs::kWebKitAllowDisplayingInsecureContent,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const PrefChangeRegistrar::NamedChangeCallback& obs) { 121 const PrefChangeRegistrar::NamedChangeCallback& obs) {
118 DCHECK(StartsWithASCII(map_name, "webkit.webprefs.", true)); 122 DCHECK(StartsWithASCII(map_name, "webkit.webprefs.", true));
119 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 123 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
120 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; 124 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
121 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); 125 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
122 registrar->Add(pref_name.c_str(), obs); 126 registrar->Add(pref_name.c_str(), obs);
123 } 127 }
124 } 128 }
125 #endif // !defined(OS_ANDROID) 129 #endif // !defined(OS_ANDROID)
126 130
131 #if defined(OS_WIN)
132 // On Windows with DirectWrite we want to use an alternate fixed font like
133 // Consolas, which looks much better than Courier New.
134 bool ShouldUseAlternateDefaultFixedFont() {
135 UINT smooth_type = 0;
136 SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smooth_type, 0);
137 return (base::win::GetVersion() >= base::win::VERSION_WIN7) &&
138 (smooth_type == FE_FONTSMOOTHINGCLEARTYPE);
139 }
140 #endif
141
127 struct FontDefault { 142 struct FontDefault {
128 const char* pref_name; 143 const char* pref_name;
129 int resource_id; 144 int resource_id;
130 }; 145 };
131 146
132 // Font pref defaults. The prefs that have defaults vary by platform, since not 147 // Font pref defaults. The prefs that have defaults vary by platform, since not
133 // all platforms have fonts for all scripts for all generic families. 148 // all platforms have fonts for all scripts for all generic families.
134 // TODO(falken): add proper defaults when possible for all 149 // TODO(falken): add proper defaults when possible for all
135 // platforms/scripts/generic families. 150 // platforms/scripts/generic families.
136 const FontDefault kFontDefaults[] = { 151 const FontDefault kFontDefaults[] = {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 462 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
448 registry->RegisterLocalizedStringPref( 463 registry->RegisterLocalizedStringPref(
449 prefs::kDefaultCharset, 464 prefs::kDefaultCharset,
450 IDS_DEFAULT_ENCODING, 465 IDS_DEFAULT_ENCODING,
451 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 466 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
452 467
453 // Register font prefs that have defaults. 468 // Register font prefs that have defaults.
454 std::set<std::string> fonts_with_defaults; 469 std::set<std::string> fonts_with_defaults;
455 UScriptCode browser_script = GetScriptOfBrowserLocale(); 470 UScriptCode browser_script = GetScriptOfBrowserLocale();
456 for (size_t i = 0; i < kFontDefaultsLength; ++i) { 471 for (size_t i = 0; i < kFontDefaultsLength; ++i) {
457 const FontDefault& pref = kFontDefaults[i]; 472 FontDefault pref = kFontDefaults[i];
473
474 #if defined(OS_WIN)
475 if (pref.pref_name == prefs::kWebKitFixedFontFamily) {
476 if (ShouldUseAlternateDefaultFixedFont())
477 pref.resource_id = IDS_FIXED_FONT_FAMILY_ALT_WIN;
478 }
479 #endif
480
458 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name); 481 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name);
459 482
460 // Suppress this default font pref value if it is for the primary script of 483 // Suppress this default font pref value if it is for the primary script of
461 // the browser's UI locale. For example, if the pref is for the sans-serif 484 // the browser's UI locale. For example, if the pref is for the sans-serif
462 // font for the Cyrillic script, and the browser locale is "ru" (Russian), 485 // font for the Cyrillic script, and the browser locale is "ru" (Russian),
463 // the default is suppressed. Otherwise, the default would override the 486 // the default is suppressed. Otherwise, the default would override the
464 // user's font preferences when viewing pages in their native language. 487 // user's font preferences when viewing pages in their native language.
465 // This is because users have no way yet of customizing their per-script 488 // This is because users have no way yet of customizing their per-script
466 // font preferences. The font prefs accessible in the options UI are for 489 // font preferences. The font prefs accessible in the options UI are for
467 // the default, unknown script; these prefs have less priority than the 490 // the default, unknown script; these prefs have less priority than the
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 WebPreferences web_prefs = 595 WebPreferences web_prefs =
573 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); 596 web_contents_->GetRenderViewHost()->GetWebkitPreferences();
574 OverrideFontFamily(&web_prefs, generic_family, script, std::string()); 597 OverrideFontFamily(&web_prefs, generic_family, script, std::string());
575 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); 598 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs);
576 return; 599 return;
577 } 600 }
578 } 601 }
579 602
580 UpdateWebPreferences(); 603 UpdateWebPreferences();
581 } 604 }
OLDNEW
« no previous file with comments | « chrome/app/resources/locale_settings_win.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698