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

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: patch to commit Created 9 years, 3 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 prefs::kWebKitPluginsEnabled, 102 prefs::kWebKitPluginsEnabled,
103 prefs::kWebKitSansSerifFontFamily, 103 prefs::kWebKitSansSerifFontFamily,
104 prefs::kWebKitSerifFontFamily, 104 prefs::kWebKitSerifFontFamily,
105 prefs::kWebKitStandardFontFamily, 105 prefs::kWebKitStandardFontFamily,
106 prefs::kWebkitTabsToLinks, 106 prefs::kWebkitTabsToLinks,
107 prefs::kWebKitUsesUniversalDetector 107 prefs::kWebKitUsesUniversalDetector
108 }; 108 };
109 109
110 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); 110 const int kPrefsToObserveLength = arraysize(kPrefsToObserve);
111 111
112 // Registers a preference under the path |map_name| for each script used for
113 // per-script font prefs. For example, if |map_name| is "fonts.serif", then
114 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered.
115 void RegisterFontFamilyMap(PrefService* prefs, const char* map_name) {
116 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
117 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
118 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script);
119 const char* pref_name = pref_name_str.c_str();
120 if (!prefs->FindPreference(pref_name))
121 prefs->RegisterStringPref(pref_name, "", PrefService::UNSYNCABLE_PREF);
122 }
112 } 123 }
113 124
125 } // namespace
126
114 //////////////////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////////////////
115 // TabContentsWrapper, public: 128 // TabContentsWrapper, public:
116 129
117 TabContentsWrapper::TabContentsWrapper(TabContents* contents) 130 TabContentsWrapper::TabContentsWrapper(TabContents* contents)
118 : TabContentsObserver(contents), 131 : TabContentsObserver(contents),
119 delegate_(NULL), 132 delegate_(NULL),
120 infobars_enabled_(true), 133 infobars_enabled_(true),
121 ALLOW_THIS_IN_INITIALIZER_LIST( 134 ALLOW_THIS_IN_INITIALIZER_LIST(
122 synced_tab_delegate_(new TabContentsWrapperSyncedTabDelegate(this))), 135 synced_tab_delegate_(new TabContentsWrapperSyncedTabDelegate(this))),
123 in_destructor_(false), 136 in_destructor_(false),
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 PrefService::UNSYNCABLE_PREF); 298 PrefService::UNSYNCABLE_PREF);
286 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily, 299 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily,
287 IDS_SANS_SERIF_FONT_FAMILY, 300 IDS_SANS_SERIF_FONT_FAMILY,
288 PrefService::UNSYNCABLE_PREF); 301 PrefService::UNSYNCABLE_PREF);
289 prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily, 302 prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily,
290 IDS_CURSIVE_FONT_FAMILY, 303 IDS_CURSIVE_FONT_FAMILY,
291 PrefService::UNSYNCABLE_PREF); 304 PrefService::UNSYNCABLE_PREF);
292 prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily, 305 prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily,
293 IDS_FANTASY_FONT_FAMILY, 306 IDS_FANTASY_FONT_FAMILY,
294 PrefService::UNSYNCABLE_PREF); 307 PrefService::UNSYNCABLE_PREF);
308
309 // Register per-script font prefs that have defaults. Currently defaults are
310 // defined only for some scripts and only on Chrome OS to begin with (it is
311 // the easiest since we readily know what fonts are available there).
312 // TODO(falken): add defaults for all platforms and for scripts that should
313 // have defaults.
314 #if defined(OS_CHROMEOS)
315 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyArabic,
316 IDS_STANDARD_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF);
317 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyArabic,
318 IDS_SERIF_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF);
319 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyArabic,
320 IDS_SANS_SERIF_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF);
321 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyJapanese,
322 IDS_STANDARD_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
323 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyJapanese,
324 IDS_FIXED_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
325 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyJapanese,
326 IDS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
327 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyJapanese,
328 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
329 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyKorean,
330 IDS_STANDARD_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
331 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyKorean,
332 IDS_FIXED_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
333 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyKorean,
334 IDS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
335 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyKorean,
336 IDS_SANS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
337 prefs->RegisterLocalizedStringPref(
338 prefs::kWebKitStandardFontFamilySimplifiedHan,
339 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
340 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilySimplifiedHan,
341 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
342 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilySimplifiedHan,
343 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
344 prefs->RegisterLocalizedStringPref(
345 prefs::kWebKitSansSerifFontFamilySimplifiedHan,
346 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
347 prefs->RegisterLocalizedStringPref(
348 prefs::kWebKitStandardFontFamilyTraditionalHan,
349 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
350 prefs->RegisterLocalizedStringPref(
351 prefs::kWebKitFixedFontFamilyTraditionalHan,
352 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
353 prefs->RegisterLocalizedStringPref(
354 prefs::kWebKitSerifFontFamilyTraditionalHan,
355 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
356 prefs->RegisterLocalizedStringPref(
357 prefs::kWebKitSansSerifFontFamilyTraditionalHan,
358 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
359 #endif
360
361 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap);
362 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap);
363 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap);
364 RegisterFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap);
365 RegisterFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap);
366 RegisterFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap);
367
295 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, 368 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize,
296 IDS_DEFAULT_FONT_SIZE, 369 IDS_DEFAULT_FONT_SIZE,
297 PrefService::UNSYNCABLE_PREF); 370 PrefService::UNSYNCABLE_PREF);
298 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize, 371 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize,
299 IDS_DEFAULT_FIXED_FONT_SIZE, 372 IDS_DEFAULT_FIXED_FONT_SIZE,
300 PrefService::UNSYNCABLE_PREF); 373 PrefService::UNSYNCABLE_PREF);
301 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, 374 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize,
302 IDS_MINIMUM_FONT_SIZE, 375 IDS_MINIMUM_FONT_SIZE,
303 PrefService::UNSYNCABLE_PREF); 376 PrefService::UNSYNCABLE_PREF);
304 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize, 377 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumLogicalFontSize,
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 if (infobars_.empty()) { 835 if (infobars_.empty()) {
763 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 836 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
764 Source<NavigationController>(&tab_contents_->controller())); 837 Source<NavigationController>(&tab_contents_->controller()));
765 } 838 }
766 } 839 }
767 840
768 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { 841 void TabContentsWrapper::RemoveAllInfoBars(bool animate) {
769 while (!infobars_.empty()) 842 while (!infobars_.empty())
770 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); 843 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate);
771 } 844 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698