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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 #endif // !defined(OS_ANDROID) | 130 #endif // !defined(OS_ANDROID) |
131 | 131 |
132 // Registers |obs| to observe per-script font prefs under the path |map_name|. | 132 // Registers |obs| to observe per-script font prefs under the path |map_name|. |
133 // On android, there's no exposed way to change these prefs, so we can save | 133 // On android, there's no exposed way to change these prefs, so we can save |
134 // ~715KB of heap and some startup cycles by avoiding observing these prefs | 134 // ~715KB of heap and some startup cycles by avoiding observing these prefs |
135 // since they will never change. | 135 // since they will never change. |
136 void RegisterFontFamilyMapObserver( | 136 void RegisterFontFamilyMapObserver( |
137 PrefChangeRegistrar* registrar, | 137 PrefChangeRegistrar* registrar, |
138 const char* map_name, | 138 const char* map_name, |
139 const PrefChangeRegistrar::NamedChangeCallback& obs) { | 139 const PrefChangeRegistrar::NamedChangeCallback& obs) { |
140 DCHECK(base::StartsWithASCII(map_name, "webkit.webprefs.", true)); | 140 DCHECK(base::StartsWith(map_name, "webkit.webprefs.", |
| 141 base::CompareCase::SENSITIVE)); |
141 | 142 |
142 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | 143 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
143 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | 144 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
144 registrar->Add(base::StringPrintf("%s.%s", map_name, script), obs); | 145 registrar->Add(base::StringPrintf("%s.%s", map_name, script), obs); |
145 } | 146 } |
146 } | 147 } |
147 | 148 |
148 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
149 // On Windows with antialising we want to use an alternate fixed font like | 150 // On Windows with antialising we want to use an alternate fixed font like |
150 // Consolas, which looks much better than Courier New. | 151 // Consolas, which looks much better than Courier New. |
151 bool ShouldUseAlternateDefaultFixedFont(const std::string& script) { | 152 bool ShouldUseAlternateDefaultFixedFont(const std::string& script) { |
152 if (!base::StartsWithASCII(script, "courier", false)) | 153 if (!base::StartsWith(script, "courier", |
| 154 base::CompareCase::INSENSITIVE_ASCII)) |
153 return false; | 155 return false; |
154 UINT smooth_type = 0; | 156 UINT smooth_type = 0; |
155 SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smooth_type, 0); | 157 SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smooth_type, 0); |
156 return (base::win::GetVersion() >= base::win::VERSION_WIN7) && | 158 return (base::win::GetVersion() >= base::win::VERSION_WIN7) && |
157 (smooth_type == FE_FONTSMOOTHINGCLEARTYPE); | 159 (smooth_type == FE_FONTSMOOTHINGCLEARTYPE); |
158 } | 160 } |
159 #endif | 161 #endif |
160 | 162 |
161 struct FontDefault { | 163 struct FontDefault { |
162 const char* pref_name; | 164 const char* pref_name; |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 } | 684 } |
683 } | 685 } |
684 | 686 |
685 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { | 687 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { |
686 #if !defined(OS_ANDROID) | 688 #if !defined(OS_ANDROID) |
687 OnFontFamilyPrefChanged(pref_name); | 689 OnFontFamilyPrefChanged(pref_name); |
688 #endif | 690 #endif |
689 | 691 |
690 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); | 692 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
691 } | 693 } |
OLD | NEW |