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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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) 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/string_util.h" 10 #include "base/string_util.h"
(...skipping 22 matching lines...) Expand all
33 #endif 33 #endif
34 34
35 using content::WebContents; 35 using content::WebContents;
36 using webkit_glue::WebPreferences; 36 using webkit_glue::WebPreferences;
37 37
38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper) 38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper)
39 39
40 namespace { 40 namespace {
41 41
42 // Registers prefs only used for migration. 42 // Registers prefs only used for migration.
43 void RegisterPrefsToMigrate(PrefService* prefs) { 43 void RegisterPrefsToMigrate(PrefServiceSyncable* prefs) {
44 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldStandardFontFamily, 44 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldStandardFontFamily,
45 IDS_STANDARD_FONT_FAMILY, 45 IDS_STANDARD_FONT_FAMILY,
46 PrefService::UNSYNCABLE_PREF); 46 PrefServiceSyncable::UNSYNCABLE_PREF);
47 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFixedFontFamily, 47 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFixedFontFamily,
48 IDS_FIXED_FONT_FAMILY, 48 IDS_FIXED_FONT_FAMILY,
49 PrefService::UNSYNCABLE_PREF); 49 PrefServiceSyncable::UNSYNCABLE_PREF);
50 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSerifFontFamily, 50 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSerifFontFamily,
51 IDS_SERIF_FONT_FAMILY, 51 IDS_SERIF_FONT_FAMILY,
52 PrefService::UNSYNCABLE_PREF); 52 PrefServiceSyncable::UNSYNCABLE_PREF);
53 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSansSerifFontFamily, 53 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSansSerifFontFamily,
54 IDS_SANS_SERIF_FONT_FAMILY, 54 IDS_SANS_SERIF_FONT_FAMILY,
55 PrefService::UNSYNCABLE_PREF); 55 PrefServiceSyncable::UNSYNCABLE_PREF);
56 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldCursiveFontFamily, 56 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldCursiveFontFamily,
57 IDS_CURSIVE_FONT_FAMILY, 57 IDS_CURSIVE_FONT_FAMILY,
58 PrefService::UNSYNCABLE_PREF); 58 PrefServiceSyncable::UNSYNCABLE_PREF);
59 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFantasyFontFamily, 59 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFantasyFontFamily,
60 IDS_FANTASY_FONT_FAMILY, 60 IDS_FANTASY_FONT_FAMILY,
61 PrefService::UNSYNCABLE_PREF); 61 PrefServiceSyncable::UNSYNCABLE_PREF);
62 prefs->RegisterLocalizedStringPref(prefs::kGlobalDefaultCharset, 62 prefs->RegisterLocalizedStringPref(prefs::kGlobalDefaultCharset,
63 IDS_DEFAULT_ENCODING, 63 IDS_DEFAULT_ENCODING,
64 PrefService::SYNCABLE_PREF); 64 PrefServiceSyncable::SYNCABLE_PREF);
65 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalDefaultFontSize, 65 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalDefaultFontSize,
66 IDS_DEFAULT_FONT_SIZE, 66 IDS_DEFAULT_FONT_SIZE,
67 PrefService::UNSYNCABLE_PREF); 67 PrefServiceSyncable::UNSYNCABLE_PREF);
68 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalDefaultFixedFontSize, 68 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalDefaultFixedFontSize,
69 IDS_DEFAULT_FIXED_FONT_SIZE, 69 IDS_DEFAULT_FIXED_FONT_SIZE,
70 PrefService::UNSYNCABLE_PREF); 70 PrefServiceSyncable::UNSYNCABLE_PREF);
71 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalMinimumFontSize, 71 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalMinimumFontSize,
72 IDS_MINIMUM_FONT_SIZE, 72 IDS_MINIMUM_FONT_SIZE,
73 PrefService::UNSYNCABLE_PREF); 73 PrefServiceSyncable::UNSYNCABLE_PREF);
74 prefs->RegisterLocalizedIntegerPref( 74 prefs->RegisterLocalizedIntegerPref(
75 prefs::kWebKitGlobalMinimumLogicalFontSize, 75 prefs::kWebKitGlobalMinimumLogicalFontSize,
76 IDS_MINIMUM_LOGICAL_FONT_SIZE, 76 IDS_MINIMUM_LOGICAL_FONT_SIZE,
77 PrefService::UNSYNCABLE_PREF); 77 PrefServiceSyncable::UNSYNCABLE_PREF);
78 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalStandardFontFamily, 78 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalStandardFontFamily,
79 IDS_STANDARD_FONT_FAMILY, 79 IDS_STANDARD_FONT_FAMILY,
80 PrefService::UNSYNCABLE_PREF); 80 PrefServiceSyncable::UNSYNCABLE_PREF);
81 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFixedFontFamily, 81 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFixedFontFamily,
82 IDS_FIXED_FONT_FAMILY, 82 IDS_FIXED_FONT_FAMILY,
83 PrefService::UNSYNCABLE_PREF); 83 PrefServiceSyncable::UNSYNCABLE_PREF);
84 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSerifFontFamily, 84 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSerifFontFamily,
85 IDS_SERIF_FONT_FAMILY, 85 IDS_SERIF_FONT_FAMILY,
86 PrefService::UNSYNCABLE_PREF); 86 PrefServiceSyncable::UNSYNCABLE_PREF);
87 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSansSerifFontFamily, 87 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSansSerifFontFamily,
88 IDS_SANS_SERIF_FONT_FAMILY, 88 IDS_SANS_SERIF_FONT_FAMILY,
89 PrefService::UNSYNCABLE_PREF); 89 PrefServiceSyncable::UNSYNCABLE_PREF);
90 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalCursiveFontFamily, 90 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalCursiveFontFamily,
91 IDS_CURSIVE_FONT_FAMILY, 91 IDS_CURSIVE_FONT_FAMILY,
92 PrefService::UNSYNCABLE_PREF); 92 PrefServiceSyncable::UNSYNCABLE_PREF);
93 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily, 93 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily,
94 IDS_FANTASY_FONT_FAMILY, 94 IDS_FANTASY_FONT_FAMILY,
95 PrefService::UNSYNCABLE_PREF); 95 PrefServiceSyncable::UNSYNCABLE_PREF);
96 } 96 }
97 97
98 // The list of prefs we want to observe. 98 // The list of prefs we want to observe.
99 const char* kPrefsToObserve[] = { 99 const char* kPrefsToObserve[] = {
100 prefs::kDefaultCharset, 100 prefs::kDefaultCharset,
101 prefs::kWebKitAllowDisplayingInsecureContent, 101 prefs::kWebKitAllowDisplayingInsecureContent,
102 prefs::kWebKitAllowRunningInsecureContent, 102 prefs::kWebKitAllowRunningInsecureContent,
103 prefs::kWebKitDefaultFixedFontSize, 103 prefs::kWebKitDefaultFixedFontSize,
104 prefs::kWebKitDefaultFontSize, 104 prefs::kWebKitDefaultFontSize,
105 #if defined(OS_ANDROID) 105 #if defined(OS_ANDROID)
106 prefs::kWebKitFontScaleFactor, 106 prefs::kWebKitFontScaleFactor,
107 prefs::kWebKitForceEnableZoom, 107 prefs::kWebKitForceEnableZoom,
108 #endif 108 #endif
109 prefs::kWebKitJavascriptEnabled, 109 prefs::kWebKitJavascriptEnabled,
110 prefs::kWebKitJavaEnabled, 110 prefs::kWebKitJavaEnabled,
111 prefs::kWebKitLoadsImagesAutomatically, 111 prefs::kWebKitLoadsImagesAutomatically,
112 prefs::kWebKitMinimumFontSize, 112 prefs::kWebKitMinimumFontSize,
113 prefs::kWebKitMinimumLogicalFontSize, 113 prefs::kWebKitMinimumLogicalFontSize,
114 prefs::kWebKitPluginsEnabled, 114 prefs::kWebKitPluginsEnabled,
115 prefs::kWebkitTabsToLinks, 115 prefs::kWebkitTabsToLinks,
116 prefs::kWebKitUsesUniversalDetector 116 prefs::kWebKitUsesUniversalDetector
117 }; 117 };
118 118
119 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); 119 const int kPrefsToObserveLength = arraysize(kPrefsToObserve);
120 120
121 // Registers a preference under the path |map_name| for each script used for 121 // Registers a preference under the path |map_name| for each script used for
122 // per-script font prefs. For example, if |map_name| is "fonts.serif", then 122 // per-script font prefs. For example, if |map_name| is "fonts.serif", then
123 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. 123 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered.
124 void RegisterFontFamilyMap(PrefService* prefs, 124 void RegisterFontFamilyMap(PrefServiceSyncable* prefs,
125 const char* map_name, 125 const char* map_name,
126 const std::set<std::string>& fonts_with_defaults) { 126 const std::set<std::string>& fonts_with_defaults) {
127 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 127 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
128 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; 128 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
129 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script); 129 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script);
130 const char* pref_name = pref_name_str.c_str(); 130 const char* pref_name = pref_name_str.c_str();
131 if (fonts_with_defaults.find(pref_name) == fonts_with_defaults.end()) { 131 if (fonts_with_defaults.find(pref_name) == fonts_with_defaults.end()) {
132 // We haven't already set a default value for this font preference, so set 132 // We haven't already set a default value for this font preference, so set
133 // an empty string as the default. 133 // an empty string as the default.
134 prefs->RegisterStringPref(pref_name, "", PrefService::UNSYNCABLE_PREF); 134 prefs->RegisterStringPref(
135 pref_name, "", PrefServiceSyncable::UNSYNCABLE_PREF);
135 } 136 }
136 } 137 }
137 } 138 }
138 139
139 // Registers |obs| to observe per-script font prefs under the path |map_name|. 140 // Registers |obs| to observe per-script font prefs under the path |map_name|.
140 void RegisterFontFamilyMapObserver( 141 void RegisterFontFamilyMapObserver(
141 PrefChangeRegistrar* registrar, 142 PrefChangeRegistrar* registrar,
142 const char* map_name, 143 const char* map_name,
143 const PrefChangeRegistrar::NamedChangeCallback& obs) { 144 const PrefChangeRegistrar::NamedChangeCallback& obs) {
144 DCHECK(StartsWithASCII(map_name, "webkit.webprefs.", true)); 145 DCHECK(StartsWithASCII(map_name, "webkit.webprefs.", true));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 { prefs::kWebKitGlobalSansSerifFontFamily, 332 { prefs::kWebKitGlobalSansSerifFontFamily,
332 prefs::kWebKitSansSerifFontFamily }, 333 prefs::kWebKitSansSerifFontFamily },
333 { prefs::kWebKitGlobalSerifFontFamily, 334 { prefs::kWebKitGlobalSerifFontFamily,
334 prefs::kWebKitSerifFontFamily }, 335 prefs::kWebKitSerifFontFamily },
335 { prefs::kWebKitGlobalStandardFontFamily, 336 { prefs::kWebKitGlobalStandardFontFamily,
336 prefs::kWebKitStandardFontFamily } 337 prefs::kWebKitStandardFontFamily }
337 }; 338 };
338 339
339 const int kPrefsToMigrateLength = ARRAYSIZE_UNSAFE(kPrefNamesToMigrate); 340 const int kPrefsToMigrateLength = ARRAYSIZE_UNSAFE(kPrefNamesToMigrate);
340 341
341 void MigratePreferences(PrefService* prefs) { 342 void MigratePreferences(PrefServiceSyncable* prefs) {
342 RegisterPrefsToMigrate(prefs); 343 RegisterPrefsToMigrate(prefs);
343 for (int i = 0; i < kPrefsToMigrateLength; ++i) { 344 for (int i = 0; i < kPrefsToMigrateLength; ++i) {
344 const PrefService::Preference* pref = 345 const PrefService::Preference* pref =
345 prefs->FindPreference(kPrefNamesToMigrate[i].from); 346 prefs->FindPreference(kPrefNamesToMigrate[i].from);
346 if (!pref) continue; 347 if (!pref) continue;
347 if (!pref->IsDefaultValue()) { 348 if (!pref->IsDefaultValue()) {
348 prefs->Set(kPrefNamesToMigrate[i].to, *pref->GetValue()); 349 prefs->Set(kPrefNamesToMigrate[i].to, *pref->GetValue());
349 } 350 }
350 prefs->ClearPref(kPrefNamesToMigrate[i].from); 351 prefs->ClearPref(kPrefNamesToMigrate[i].from);
351 prefs->UnregisterPreference(kPrefNamesToMigrate[i].from); 352 prefs->UnregisterPreference(kPrefNamesToMigrate[i].from);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // List of keys that cannot be changed in the user prefs file by the incognito 444 // List of keys that cannot be changed in the user prefs file by the incognito
444 // profile. All preferences that store information about the browsing history 445 // profile. All preferences that store information about the browsing history
445 // or behavior of the user should have this property. 446 // or behavior of the user should have this property.
446 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement); 447 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement);
447 #if defined(OS_ANDROID) 448 #if defined(OS_ANDROID)
448 pref_store->RegisterOverlayPref(prefs::kProxy); 449 pref_store->RegisterOverlayPref(prefs::kProxy);
449 #endif 450 #endif
450 } 451 }
451 452
452 // static 453 // static
453 void PrefsTabHelper::RegisterUserPrefs(PrefService* prefs) { 454 void PrefsTabHelper::RegisterUserPrefs(PrefServiceSyncable* prefs) {
454 WebPreferences pref_defaults; 455 WebPreferences pref_defaults;
455 prefs->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled, 456 prefs->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled,
456 pref_defaults.javascript_enabled, 457 pref_defaults.javascript_enabled,
457 PrefService::UNSYNCABLE_PREF); 458 PrefServiceSyncable::UNSYNCABLE_PREF);
458 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, 459 prefs->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled,
459 pref_defaults.web_security_enabled, 460 pref_defaults.web_security_enabled,
460 PrefService::UNSYNCABLE_PREF); 461 PrefServiceSyncable::UNSYNCABLE_PREF);
461 prefs->RegisterBooleanPref( 462 prefs->RegisterBooleanPref(
462 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, 463 prefs::kWebKitJavascriptCanOpenWindowsAutomatically,
463 true, 464 true,
464 PrefService::UNSYNCABLE_PREF); 465 PrefServiceSyncable::UNSYNCABLE_PREF);
465 prefs->RegisterBooleanPref(prefs::kWebKitLoadsImagesAutomatically, 466 prefs->RegisterBooleanPref(prefs::kWebKitLoadsImagesAutomatically,
466 pref_defaults.loads_images_automatically, 467 pref_defaults.loads_images_automatically,
467 PrefService::UNSYNCABLE_PREF); 468 PrefServiceSyncable::UNSYNCABLE_PREF);
468 prefs->RegisterBooleanPref(prefs::kWebKitPluginsEnabled, 469 prefs->RegisterBooleanPref(prefs::kWebKitPluginsEnabled,
469 pref_defaults.plugins_enabled, 470 pref_defaults.plugins_enabled,
470 PrefService::UNSYNCABLE_PREF); 471 PrefServiceSyncable::UNSYNCABLE_PREF);
471 prefs->RegisterBooleanPref(prefs::kWebKitDomPasteEnabled, 472 prefs->RegisterBooleanPref(prefs::kWebKitDomPasteEnabled,
472 pref_defaults.dom_paste_enabled, 473 pref_defaults.dom_paste_enabled,
473 PrefService::UNSYNCABLE_PREF); 474 PrefServiceSyncable::UNSYNCABLE_PREF);
474 prefs->RegisterBooleanPref(prefs::kWebKitShrinksStandaloneImagesToFit, 475 prefs->RegisterBooleanPref(prefs::kWebKitShrinksStandaloneImagesToFit,
475 pref_defaults.shrinks_standalone_images_to_fit, 476 pref_defaults.shrinks_standalone_images_to_fit,
476 PrefService::UNSYNCABLE_PREF); 477 PrefServiceSyncable::UNSYNCABLE_PREF);
477 prefs->RegisterDictionaryPref(prefs::kWebKitInspectorSettings, 478 prefs->RegisterDictionaryPref(prefs::kWebKitInspectorSettings,
478 PrefService::UNSYNCABLE_PREF); 479 PrefServiceSyncable::UNSYNCABLE_PREF);
479 prefs->RegisterBooleanPref(prefs::kWebKitTextAreasAreResizable, 480 prefs->RegisterBooleanPref(prefs::kWebKitTextAreasAreResizable,
480 pref_defaults.text_areas_are_resizable, 481 pref_defaults.text_areas_are_resizable,
481 PrefService::UNSYNCABLE_PREF); 482 PrefServiceSyncable::UNSYNCABLE_PREF);
482 prefs->RegisterBooleanPref(prefs::kWebKitJavaEnabled, 483 prefs->RegisterBooleanPref(prefs::kWebKitJavaEnabled,
483 pref_defaults.java_enabled, 484 pref_defaults.java_enabled,
484 PrefService::UNSYNCABLE_PREF); 485 PrefServiceSyncable::UNSYNCABLE_PREF);
485 prefs->RegisterBooleanPref(prefs::kWebkitTabsToLinks, 486 prefs->RegisterBooleanPref(prefs::kWebkitTabsToLinks,
486 pref_defaults.tabs_to_links, 487 pref_defaults.tabs_to_links,
487 PrefService::UNSYNCABLE_PREF); 488 PrefServiceSyncable::UNSYNCABLE_PREF);
488 prefs->RegisterBooleanPref(prefs::kWebKitAllowRunningInsecureContent, 489 prefs->RegisterBooleanPref(prefs::kWebKitAllowRunningInsecureContent,
489 false, 490 false,
490 PrefService::UNSYNCABLE_PREF); 491 PrefServiceSyncable::UNSYNCABLE_PREF);
491 prefs->RegisterBooleanPref(prefs::kWebKitAllowDisplayingInsecureContent, 492 prefs->RegisterBooleanPref(prefs::kWebKitAllowDisplayingInsecureContent,
492 true, 493 true,
493 PrefService::UNSYNCABLE_PREF); 494 PrefServiceSyncable::UNSYNCABLE_PREF);
494 prefs->RegisterBooleanPref(prefs::kEnableReferrers, 495 prefs->RegisterBooleanPref(prefs::kEnableReferrers,
495 true, 496 true,
496 PrefService::UNSYNCABLE_PREF); 497 PrefServiceSyncable::UNSYNCABLE_PREF);
497 #if defined(OS_ANDROID) 498 #if defined(OS_ANDROID)
498 prefs->RegisterDoublePref(prefs::kWebKitFontScaleFactor, 499 prefs->RegisterDoublePref(prefs::kWebKitFontScaleFactor,
499 pref_defaults.font_scale_factor, 500 pref_defaults.font_scale_factor,
500 PrefService::UNSYNCABLE_PREF); 501 PrefServiceSyncable::UNSYNCABLE_PREF);
501 prefs->RegisterBooleanPref(prefs::kWebKitForceEnableZoom, 502 prefs->RegisterBooleanPref(prefs::kWebKitForceEnableZoom,
502 pref_defaults.force_enable_zoom, 503 pref_defaults.force_enable_zoom,
503 PrefService::UNSYNCABLE_PREF); 504 PrefServiceSyncable::UNSYNCABLE_PREF);
504 #endif 505 #endif
505 506
506 #if !defined(OS_MACOSX) 507 #if !defined(OS_MACOSX)
507 prefs->RegisterLocalizedStringPref(prefs::kAcceptLanguages, 508 prefs->RegisterLocalizedStringPref(prefs::kAcceptLanguages,
508 IDS_ACCEPT_LANGUAGES, 509 IDS_ACCEPT_LANGUAGES,
509 PrefService::SYNCABLE_PREF); 510 PrefServiceSyncable::SYNCABLE_PREF);
510 #else 511 #else
511 // Not used in OSX. 512 // Not used in OSX.
512 prefs->RegisterLocalizedStringPref(prefs::kAcceptLanguages, 513 prefs->RegisterLocalizedStringPref(prefs::kAcceptLanguages,
513 IDS_ACCEPT_LANGUAGES, 514 IDS_ACCEPT_LANGUAGES,
514 PrefService::UNSYNCABLE_PREF); 515 PrefServiceSyncable::UNSYNCABLE_PREF);
515 #endif 516 #endif
516 prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset, 517 prefs->RegisterLocalizedStringPref(prefs::kDefaultCharset,
517 IDS_DEFAULT_ENCODING, 518 IDS_DEFAULT_ENCODING,
518 PrefService::SYNCABLE_PREF); 519 PrefServiceSyncable::SYNCABLE_PREF);
519 520
520 // Register font prefs that have defaults. 521 // Register font prefs that have defaults.
521 std::set<std::string> fonts_with_defaults; 522 std::set<std::string> fonts_with_defaults;
522 UScriptCode browser_script = GetScriptOfBrowserLocale(); 523 UScriptCode browser_script = GetScriptOfBrowserLocale();
523 for (size_t i = 0; i < kFontDefaultsLength; ++i) { 524 for (size_t i = 0; i < kFontDefaultsLength; ++i) {
524 const FontDefault& pref = kFontDefaults[i]; 525 const FontDefault& pref = kFontDefaults[i];
525 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name); 526 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name);
526 527
527 // Suppress this default font pref value if it is for the primary script of 528 // Suppress this default font pref value if it is for the primary script of
528 // the browser's UI locale. For example, if the pref is for the sans-serif 529 // the browser's UI locale. For example, if the pref is for the sans-serif
529 // font for the Cyrillic script, and the browser locale is "ru" (Russian), 530 // font for the Cyrillic script, and the browser locale is "ru" (Russian),
530 // the default is suppressed. Otherwise, the default would override the 531 // the default is suppressed. Otherwise, the default would override the
531 // user's font preferences when viewing pages in their native language. 532 // user's font preferences when viewing pages in their native language.
532 // This is because users have no way yet of customizing their per-script 533 // This is because users have no way yet of customizing their per-script
533 // font preferences. The font prefs accessible in the options UI are for 534 // font preferences. The font prefs accessible in the options UI are for
534 // the default, unknown script; these prefs have less priority than the 535 // the default, unknown script; these prefs have less priority than the
535 // per-script font prefs when the script of the content is known. This code 536 // per-script font prefs when the script of the content is known. This code
536 // can possibly be removed later if users can easily access per-script font 537 // can possibly be removed later if users can easily access per-script font
537 // prefs (e.g., via the extensions workflow), or the problem turns out to 538 // prefs (e.g., via the extensions workflow), or the problem turns out to
538 // not be really critical after all. 539 // not be really critical after all.
539 if (browser_script != pref_script) { 540 if (browser_script != pref_script) {
540 prefs->RegisterLocalizedStringPref(pref.pref_name, 541 prefs->RegisterLocalizedStringPref(pref.pref_name,
541 pref.resource_id, 542 pref.resource_id,
542 PrefService::UNSYNCABLE_PREF); 543 PrefServiceSyncable::UNSYNCABLE_PREF);
543 fonts_with_defaults.insert(pref.pref_name); 544 fonts_with_defaults.insert(pref.pref_name);
544 } 545 }
545 } 546 }
546 547
547 // Register font prefs that don't have defaults. 548 // Register font prefs that don't have defaults.
548 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, 549 RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap,
549 fonts_with_defaults); 550 fonts_with_defaults);
550 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, 551 RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap,
551 fonts_with_defaults); 552 fonts_with_defaults);
552 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, 553 RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap,
553 fonts_with_defaults); 554 fonts_with_defaults);
554 RegisterFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, 555 RegisterFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap,
555 fonts_with_defaults); 556 fonts_with_defaults);
556 RegisterFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, 557 RegisterFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap,
557 fonts_with_defaults); 558 fonts_with_defaults);
558 RegisterFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, 559 RegisterFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap,
559 fonts_with_defaults); 560 fonts_with_defaults);
560 RegisterFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap, 561 RegisterFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap,
561 fonts_with_defaults); 562 fonts_with_defaults);
562 563
563 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, 564 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize,
564 IDS_DEFAULT_FONT_SIZE, 565 IDS_DEFAULT_FONT_SIZE,
565 PrefService::UNSYNCABLE_PREF); 566 PrefServiceSyncable::UNSYNCABLE_PREF);
566 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize, 567 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize,
567 IDS_DEFAULT_FIXED_FONT_SIZE, 568 IDS_DEFAULT_FIXED_FONT_SIZE,
568 PrefService::UNSYNCABLE_PREF); 569 PrefServiceSyncable::UNSYNCABLE_PREF);
569 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, 570 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize,
570 IDS_MINIMUM_FONT_SIZE, 571 IDS_MINIMUM_FONT_SIZE,
571 PrefService::UNSYNCABLE_PREF); 572 PrefServiceSyncable::UNSYNCABLE_PREF);
572 prefs->RegisterLocalizedIntegerPref( 573 prefs->RegisterLocalizedIntegerPref(
573 prefs::kWebKitMinimumLogicalFontSize, 574 prefs::kWebKitMinimumLogicalFontSize,
574 IDS_MINIMUM_LOGICAL_FONT_SIZE, 575 IDS_MINIMUM_LOGICAL_FONT_SIZE,
575 PrefService::UNSYNCABLE_PREF); 576 PrefServiceSyncable::UNSYNCABLE_PREF);
576 prefs->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector, 577 prefs->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector,
577 IDS_USES_UNIVERSAL_DETECTOR, 578 IDS_USES_UNIVERSAL_DETECTOR,
578 PrefService::SYNCABLE_PREF); 579 PrefServiceSyncable::SYNCABLE_PREF);
579 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings, 580 prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings,
580 IDS_STATIC_ENCODING_LIST, 581 IDS_STATIC_ENCODING_LIST,
581 PrefService::UNSYNCABLE_PREF); 582 PrefServiceSyncable::UNSYNCABLE_PREF);
582 prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, 583 prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding,
583 "", 584 "",
584 PrefService::UNSYNCABLE_PREF); 585 PrefServiceSyncable::UNSYNCABLE_PREF);
585 MigratePreferences(prefs); 586 MigratePreferences(prefs);
586 } 587 }
587 588
588 void PrefsTabHelper::Observe(int type, 589 void PrefsTabHelper::Observe(int type,
589 const content::NotificationSource& source, 590 const content::NotificationSource& source,
590 const content::NotificationDetails& details) { 591 const content::NotificationDetails& details) {
591 switch (type) { 592 switch (type) {
592 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED: 593 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED:
593 UpdateWebPreferences(); 594 UpdateWebPreferences();
594 break; 595 break;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 WebPreferences web_prefs = 643 WebPreferences web_prefs =
643 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); 644 web_contents_->GetRenderViewHost()->GetWebkitPreferences();
644 OverrideFontFamily(&web_prefs, generic_family, script, ""); 645 OverrideFontFamily(&web_prefs, generic_family, script, "");
645 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); 646 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs);
646 return; 647 return;
647 } 648 }
648 } 649 }
649 650
650 UpdateWebPreferences(); 651 UpdateWebPreferences();
651 } 652 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper.h ('k') | chrome/browser/ui/search_engines/keyword_editor_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698