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

Side by Side Diff: chrome/browser/ui/tab_contents/tab_contents_wrapper.cc

Issue 7606028: Pass per-script fonts to WebKit settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pref strings instead of dictionary Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/tab_contents_wrapper.h" 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // TODO(pkasting): If there is no InfoBarContainer, this leaks all the 205 // TODO(pkasting): If there is no InfoBarContainer, this leaks all the
206 // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on 206 // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on
207 // Infobars. 207 // Infobars.
208 RemoveAllInfoBars(false); 208 RemoveAllInfoBars(false);
209 } 209 }
210 210
211 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() { 211 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() {
212 return g_tab_contents_wrapper_property_accessor.Pointer(); 212 return g_tab_contents_wrapper_property_accessor.Pointer();
213 } 213 }
214 214
215 void RegisterFontFamilyMap(PrefService* prefs, std::string map_name) {
216 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
217 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
218 std::string pref_name = map_name + "." + script;
219 const char* pref_name_str = pref_name.c_str();
220 if (!prefs->FindPreference(pref_name_str))
221 prefs->RegisterStringPref(pref_name_str,
222 "",
223 PrefService::UNSYNCABLE_PREF);
224 }
225 }
226
215 void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) { 227 void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) {
216 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled, 228 prefs->RegisterBooleanPref(prefs::kAlternateErrorPagesEnabled,
217 true, 229 true,
218 PrefService::SYNCABLE_PREF); 230 PrefService::SYNCABLE_PREF);
219 231
220 WebPreferences pref_defaults; 232 WebPreferences pref_defaults;
221 prefs->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled, 233 prefs->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled,
222 pref_defaults.javascript_enabled, 234 pref_defaults.javascript_enabled,
223 PrefService::UNSYNCABLE_PREF); 235 PrefService::UNSYNCABLE_PREF);
224 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, 236 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 PrefService::UNSYNCABLE_PREF); 288 PrefService::UNSYNCABLE_PREF);
277 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily, 289 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily,
278 IDS_SANS_SERIF_FONT_FAMILY, 290 IDS_SANS_SERIF_FONT_FAMILY,
279 PrefService::UNSYNCABLE_PREF); 291 PrefService::UNSYNCABLE_PREF);
280 prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily, 292 prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily,
281 IDS_CURSIVE_FONT_FAMILY, 293 IDS_CURSIVE_FONT_FAMILY,
282 PrefService::UNSYNCABLE_PREF); 294 PrefService::UNSYNCABLE_PREF);
283 prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily, 295 prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily,
284 IDS_FANTASY_FONT_FAMILY, 296 IDS_FANTASY_FONT_FAMILY,
285 PrefService::UNSYNCABLE_PREF); 297 PrefService::UNSYNCABLE_PREF);
298
299 #if defined(OS_CHROMEOS)
300 // Register per-script font prefs that have defaults.
301 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyJapanese,
302 IDS_STANDARD_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
tony 2011/08/15 23:08:28 Nit: We may want to move all the font related pref
303 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyJapanese,
304 IDS_FIXED_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
305 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyJapanese,
306 IDS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
307 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyJapanese,
308 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
309 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyKorean,
310 IDS_STANDARD_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
311 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyKorean,
312 IDS_FIXED_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
313 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyKorean,
314 IDS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
315 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyKorean,
316 IDS_SANS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
317 prefs->RegisterLocalizedStringPref(
318 prefs::kWebKitStandardFontFamilySimplifiedHan,
319 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
320 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilySimplifiedHan,
321 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
322 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilySimplifiedHan,
323 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
324 prefs->RegisterLocalizedStringPref(
325 prefs::kWebKitSansSerifFontFamilySimplifiedHan,
326 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
327 prefs->RegisterLocalizedStringPref(
328 prefs::kWebKitStandardFontFamilyTraditionalHan,
329 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
330 prefs->RegisterLocalizedStringPref(
331 prefs::kWebKitFixedFontFamilyTraditionalHan,
332 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
333 prefs->RegisterLocalizedStringPref(
334 prefs::kWebKitSerifFontFamilyTraditionalHan,
335 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
336 prefs->RegisterLocalizedStringPref(
337 prefs::kWebKitSansSerifFontFamilyTraditionalHan,
338 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
339 #endif
340
341 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap);
342 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap);
343 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap);
344 RegisterFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap);
345 RegisterFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap);
346 RegisterFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap);
347
286 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, 348 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize,
287 IDS_DEFAULT_FONT_SIZE, 349 IDS_DEFAULT_FONT_SIZE,
288 PrefService::UNSYNCABLE_PREF); 350 PrefService::UNSYNCABLE_PREF);
289 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize, 351 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize,
290 IDS_DEFAULT_FIXED_FONT_SIZE, 352 IDS_DEFAULT_FIXED_FONT_SIZE,
291 PrefService::UNSYNCABLE_PREF); 353 PrefService::UNSYNCABLE_PREF);
292 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, 354 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize,
293 IDS_MINIMUM_FONT_SIZE, 355 IDS_MINIMUM_FONT_SIZE,
294 PrefService::UNSYNCABLE_PREF); 356 PrefService::UNSYNCABLE_PREF);
295 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, 357 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize,
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (infobars_.empty()) { 797 if (infobars_.empty()) {
736 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 798 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
737 Source<NavigationController>(&tab_contents_->controller())); 799 Source<NavigationController>(&tab_contents_->controller()));
738 } 800 }
739 } 801 }
740 802
741 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { 803 void TabContentsWrapper::RemoveAllInfoBars(bool animate) {
742 while (!infobars_.empty()) 804 while (!infobars_.empty())
743 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); 805 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate);
744 } 806 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698