| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void RegisterFontFamilyMap(PrefService* prefs, const char* map_name) { | 111 void RegisterFontFamilyMap(PrefService* prefs, const char* map_name) { |
| 112 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | 112 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| 113 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | 113 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| 114 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script); | 114 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script); |
| 115 const char* pref_name = pref_name_str.c_str(); | 115 const char* pref_name = pref_name_str.c_str(); |
| 116 if (!prefs->FindPreference(pref_name)) | 116 if (!prefs->FindPreference(pref_name)) |
| 117 prefs->RegisterStringPref(pref_name, "", PrefService::UNSYNCABLE_PREF); | 117 prefs->RegisterStringPref(pref_name, "", PrefService::UNSYNCABLE_PREF); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 struct PrefResource { |
| 122 const char* pref_name; |
| 123 int resource_id; |
| 124 }; |
| 125 |
| 126 // Per-script font pref defaults. The prefs that have defaults vary by |
| 127 // platform, since not all platforms have fonts for all scripts for all generic |
| 128 // families. |
| 129 // TODO(falken): add proper defaults when possible for all |
| 130 // platforms/scripts/generic families. |
| 131 const PrefResource kPerScriptFontDefaults[] = { |
| 132 #if defined(OS_CHROMEOS) |
| 133 { prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC }, |
| 134 { prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC }, |
| 135 { prefs::kWebKitSansSerifFontFamilyArabic, |
| 136 IDS_SANS_SERIF_FONT_FAMILY_ARABIC }, |
| 137 { prefs::kWebKitStandardFontFamilyJapanese, |
| 138 IDS_STANDARD_FONT_FAMILY_JAPANESE }, |
| 139 { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE }, |
| 140 { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE }, |
| 141 { prefs::kWebKitSansSerifFontFamilyJapanese, |
| 142 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE }, |
| 143 { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN }, |
| 144 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN }, |
| 145 { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN }, |
| 146 { prefs::kWebKitSansSerifFontFamilyKorean, |
| 147 IDS_SANS_SERIF_FONT_FAMILY_KOREAN }, |
| 148 { prefs::kWebKitStandardFontFamilySimplifiedHan, |
| 149 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 150 { prefs::kWebKitFixedFontFamilySimplifiedHan, |
| 151 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 152 { prefs::kWebKitSerifFontFamilySimplifiedHan, |
| 153 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 154 { prefs::kWebKitSansSerifFontFamilySimplifiedHan, |
| 155 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 156 { prefs::kWebKitStandardFontFamilyTraditionalHan, |
| 157 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN }, |
| 158 { prefs::kWebKitFixedFontFamilyTraditionalHan, |
| 159 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN }, |
| 160 { prefs::kWebKitSerifFontFamilyTraditionalHan, |
| 161 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }, |
| 162 { prefs::kWebKitSansSerifFontFamilyTraditionalHan, |
| 163 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN } |
| 164 #elif defined(OS_WIN) |
| 165 { prefs::kWebKitStandardFontFamilyJapanese, |
| 166 IDS_STANDARD_FONT_FAMILY_JAPANESE }, |
| 167 { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE }, |
| 168 { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE }, |
| 169 { prefs::kWebKitSansSerifFontFamilyJapanese, |
| 170 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE }, |
| 171 { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN }, |
| 172 { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN }, |
| 173 { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN }, |
| 174 { prefs::kWebKitSansSerifFontFamilyKorean, |
| 175 IDS_SANS_SERIF_FONT_FAMILY_KOREAN }, |
| 176 { prefs::kWebKitCursiveFontFamilyKorean, IDS_CURSIVE_FONT_FAMILY_KOREAN }, |
| 177 { prefs::kWebKitStandardFontFamilySimplifiedHan, |
| 178 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 179 { prefs::kWebKitFixedFontFamilySimplifiedHan, |
| 180 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 181 { prefs::kWebKitSerifFontFamilySimplifiedHan, |
| 182 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 183 { prefs::kWebKitSansSerifFontFamilySimplifiedHan, |
| 184 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN }, |
| 185 { prefs::kWebKitStandardFontFamilyTraditionalHan, |
| 186 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN }, |
| 187 { prefs::kWebKitFixedFontFamilyTraditionalHan, |
| 188 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN }, |
| 189 { prefs::kWebKitSerifFontFamilyTraditionalHan, |
| 190 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }, |
| 191 { prefs::kWebKitSansSerifFontFamilyTraditionalHan, |
| 192 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN } |
| 193 #endif |
| 194 }; |
| 195 |
| 196 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 197 // To avoid Clang warning, only define kPerScriptFontDefaultsLength when it is |
| 198 // non-zero. When it is zero, code like |
| 199 // for (size_t i = 0; i < kPerScriptFontDefaultsLength; ++i) |
| 200 // causes a warning due to comparison of unsigned expression < 0. |
| 201 const size_t kPerScriptFontDefaultsLength = arraysize(kPerScriptFontDefaults); |
| 202 #endif |
| 203 |
| 121 } // namespace | 204 } // namespace |
| 122 | 205 |
| 123 //////////////////////////////////////////////////////////////////////////////// | 206 //////////////////////////////////////////////////////////////////////////////// |
| 124 // TabContentsWrapper, public: | 207 // TabContentsWrapper, public: |
| 125 | 208 |
| 126 TabContentsWrapper::TabContentsWrapper(TabContents* contents) | 209 TabContentsWrapper::TabContentsWrapper(TabContents* contents) |
| 127 : TabContentsObserver(contents), | 210 : TabContentsObserver(contents), |
| 128 delegate_(NULL), | 211 delegate_(NULL), |
| 129 infobars_enabled_(true), | 212 infobars_enabled_(true), |
| 130 ALLOW_THIS_IN_INITIALIZER_LIST( | 213 ALLOW_THIS_IN_INITIALIZER_LIST( |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily, | 377 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamily, |
| 295 IDS_SANS_SERIF_FONT_FAMILY, | 378 IDS_SANS_SERIF_FONT_FAMILY, |
| 296 PrefService::UNSYNCABLE_PREF); | 379 PrefService::UNSYNCABLE_PREF); |
| 297 prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily, | 380 prefs->RegisterLocalizedStringPref(prefs::kWebKitCursiveFontFamily, |
| 298 IDS_CURSIVE_FONT_FAMILY, | 381 IDS_CURSIVE_FONT_FAMILY, |
| 299 PrefService::UNSYNCABLE_PREF); | 382 PrefService::UNSYNCABLE_PREF); |
| 300 prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily, | 383 prefs->RegisterLocalizedStringPref(prefs::kWebKitFantasyFontFamily, |
| 301 IDS_FANTASY_FONT_FAMILY, | 384 IDS_FANTASY_FONT_FAMILY, |
| 302 PrefService::UNSYNCABLE_PREF); | 385 PrefService::UNSYNCABLE_PREF); |
| 303 | 386 |
| 304 // Register per-script font prefs that have defaults. Currently defaults are | 387 // Register per-script font prefs that have defaults. |
| 305 // defined only for some scripts and only on Chrome OS to begin with (it is | 388 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 306 // the easiest since we readily know what fonts are available there). | 389 // As explained by its definition, kPerScriptFontDefaultsLength is only |
| 307 // TODO(falken): add defaults for all platforms and for scripts that should | 390 // defined for platforms where it would be non-zero. |
| 308 // have defaults. | 391 for (size_t i = 0; i < kPerScriptFontDefaultsLength; ++i) { |
| 309 #if defined(OS_CHROMEOS) | 392 prefs->RegisterLocalizedStringPref(kPerScriptFontDefaults[i].pref_name, |
| 310 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyArabic, | 393 kPerScriptFontDefaults[i].resource_id, |
| 311 IDS_STANDARD_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF); | 394 PrefService::UNSYNCABLE_PREF); |
| 312 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyArabic, | 395 } |
| 313 IDS_SERIF_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF); | |
| 314 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyArabic, | |
| 315 IDS_SANS_SERIF_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF); | |
| 316 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyJapanese, | |
| 317 IDS_STANDARD_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF); | |
| 318 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyJapanese, | |
| 319 IDS_FIXED_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF); | |
| 320 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyJapanese, | |
| 321 IDS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF); | |
| 322 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyJapanese, | |
| 323 IDS_SANS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF); | |
| 324 prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyKorean, | |
| 325 IDS_STANDARD_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF); | |
| 326 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyKorean, | |
| 327 IDS_FIXED_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF); | |
| 328 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyKorean, | |
| 329 IDS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF); | |
| 330 prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyKorean, | |
| 331 IDS_SANS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF); | |
| 332 prefs->RegisterLocalizedStringPref( | |
| 333 prefs::kWebKitStandardFontFamilySimplifiedHan, | |
| 334 IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF); | |
| 335 prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilySimplifiedHan, | |
| 336 IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF); | |
| 337 prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilySimplifiedHan, | |
| 338 IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF); | |
| 339 prefs->RegisterLocalizedStringPref( | |
| 340 prefs::kWebKitSansSerifFontFamilySimplifiedHan, | |
| 341 IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF); | |
| 342 prefs->RegisterLocalizedStringPref( | |
| 343 prefs::kWebKitStandardFontFamilyTraditionalHan, | |
| 344 IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF); | |
| 345 prefs->RegisterLocalizedStringPref( | |
| 346 prefs::kWebKitFixedFontFamilyTraditionalHan, | |
| 347 IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF); | |
| 348 prefs->RegisterLocalizedStringPref( | |
| 349 prefs::kWebKitSerifFontFamilyTraditionalHan, | |
| 350 IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF); | |
| 351 prefs->RegisterLocalizedStringPref( | |
| 352 prefs::kWebKitSansSerifFontFamilyTraditionalHan, | |
| 353 IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF); | |
| 354 #endif | 396 #endif |
| 355 | 397 |
| 398 // Register the rest of the per-script font prefs. |
| 356 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap); | 399 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap); |
| 357 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap); | 400 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap); |
| 358 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap); | 401 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap); |
| 359 RegisterFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap); | 402 RegisterFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap); |
| 360 RegisterFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap); | 403 RegisterFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap); |
| 361 RegisterFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap); | 404 RegisterFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap); |
| 362 | 405 |
| 363 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, | 406 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, |
| 364 IDS_DEFAULT_FONT_SIZE, | 407 IDS_DEFAULT_FONT_SIZE, |
| 365 PrefService::UNSYNCABLE_PREF); | 408 PrefService::UNSYNCABLE_PREF); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 797 } |
| 755 | 798 |
| 756 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { | 799 void TabContentsWrapper::RemoveAllInfoBars(bool animate) { |
| 757 while (!infobars_.empty()) | 800 while (!infobars_.empty()) |
| 758 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); | 801 RemoveInfoBarInternal(GetInfoBarDelegateAt(infobar_count() - 1), animate); |
| 759 } | 802 } |
| 760 | 803 |
| 761 void TabContentsWrapper::ExitFullscreenMode() { | 804 void TabContentsWrapper::ExitFullscreenMode() { |
| 762 Send(new ViewMsg_ExitFullscreen(routing_id())); | 805 Send(new ViewMsg_ExitFullscreen(routing_id())); |
| 763 } | 806 } |
| OLD | NEW |