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 <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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/themes/theme_service_factory.h" | 34 #include "chrome/browser/themes/theme_service_factory.h" |
35 #endif | 35 #endif |
36 | 36 |
37 using content::WebContents; | 37 using content::WebContents; |
38 | 38 |
39 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); | 39 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // Registers prefs only used for migration. | 43 // Registers prefs only used for migration. |
44 void RegisterPrefsToMigrate(PrefRegistrySyncable* prefs) { | 44 void RegisterPrefsToMigrate(user_prefs::PrefRegistrySyncable* prefs) { |
45 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldStandardFontFamily, | 45 prefs->RegisterLocalizedStringPref( |
46 IDS_STANDARD_FONT_FAMILY, | 46 prefs::kWebKitOldStandardFontFamily, |
47 PrefRegistrySyncable::UNSYNCABLE_PREF); | 47 IDS_STANDARD_FONT_FAMILY, |
48 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFixedFontFamily, | 48 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
49 IDS_FIXED_FONT_FAMILY, | 49 prefs->RegisterLocalizedStringPref( |
50 PrefRegistrySyncable::UNSYNCABLE_PREF); | 50 prefs::kWebKitOldFixedFontFamily, |
51 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSerifFontFamily, | 51 IDS_FIXED_FONT_FAMILY, |
52 IDS_SERIF_FONT_FAMILY, | 52 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
53 PrefRegistrySyncable::UNSYNCABLE_PREF); | 53 prefs->RegisterLocalizedStringPref( |
54 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldSansSerifFontFamily, | 54 prefs::kWebKitOldSerifFontFamily, |
55 IDS_SANS_SERIF_FONT_FAMILY, | 55 IDS_SERIF_FONT_FAMILY, |
56 PrefRegistrySyncable::UNSYNCABLE_PREF); | 56 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
57 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldCursiveFontFamily, | 57 prefs->RegisterLocalizedStringPref( |
58 IDS_CURSIVE_FONT_FAMILY, | 58 prefs::kWebKitOldSansSerifFontFamily, |
59 PrefRegistrySyncable::UNSYNCABLE_PREF); | 59 IDS_SANS_SERIF_FONT_FAMILY, |
60 prefs->RegisterLocalizedStringPref(prefs::kWebKitOldFantasyFontFamily, | 60 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
61 IDS_FANTASY_FONT_FAMILY, | 61 prefs->RegisterLocalizedStringPref( |
62 PrefRegistrySyncable::UNSYNCABLE_PREF); | 62 prefs::kWebKitOldCursiveFontFamily, |
63 prefs->RegisterLocalizedStringPref(prefs::kGlobalDefaultCharset, | 63 IDS_CURSIVE_FONT_FAMILY, |
64 IDS_DEFAULT_ENCODING, | 64 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
65 PrefRegistrySyncable::SYNCABLE_PREF); | 65 prefs->RegisterLocalizedStringPref( |
66 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalDefaultFontSize, | 66 prefs::kWebKitOldFantasyFontFamily, |
67 IDS_DEFAULT_FONT_SIZE, | 67 IDS_FANTASY_FONT_FAMILY, |
68 PrefRegistrySyncable::UNSYNCABLE_PREF); | 68 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
69 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalDefaultFixedFontSize, | 69 prefs->RegisterLocalizedStringPref( |
70 IDS_DEFAULT_FIXED_FONT_SIZE, | 70 prefs::kGlobalDefaultCharset, |
71 PrefRegistrySyncable::UNSYNCABLE_PREF); | 71 IDS_DEFAULT_ENCODING, |
72 prefs->RegisterLocalizedIntegerPref(prefs::kWebKitGlobalMinimumFontSize, | 72 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
73 IDS_MINIMUM_FONT_SIZE, | 73 prefs->RegisterLocalizedIntegerPref( |
74 PrefRegistrySyncable::UNSYNCABLE_PREF); | 74 prefs::kWebKitGlobalDefaultFontSize, |
| 75 IDS_DEFAULT_FONT_SIZE, |
| 76 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 77 prefs->RegisterLocalizedIntegerPref( |
| 78 prefs::kWebKitGlobalDefaultFixedFontSize, |
| 79 IDS_DEFAULT_FIXED_FONT_SIZE, |
| 80 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 81 prefs->RegisterLocalizedIntegerPref( |
| 82 prefs::kWebKitGlobalMinimumFontSize, |
| 83 IDS_MINIMUM_FONT_SIZE, |
| 84 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
75 prefs->RegisterLocalizedIntegerPref( | 85 prefs->RegisterLocalizedIntegerPref( |
76 prefs::kWebKitGlobalMinimumLogicalFontSize, | 86 prefs::kWebKitGlobalMinimumLogicalFontSize, |
77 IDS_MINIMUM_LOGICAL_FONT_SIZE, | 87 IDS_MINIMUM_LOGICAL_FONT_SIZE, |
78 PrefRegistrySyncable::UNSYNCABLE_PREF); | 88 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
79 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalStandardFontFamily, | 89 prefs->RegisterLocalizedStringPref( |
80 IDS_STANDARD_FONT_FAMILY, | 90 prefs::kWebKitGlobalStandardFontFamily, |
81 PrefRegistrySyncable::UNSYNCABLE_PREF); | 91 IDS_STANDARD_FONT_FAMILY, |
82 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFixedFontFamily, | 92 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
83 IDS_FIXED_FONT_FAMILY, | 93 prefs->RegisterLocalizedStringPref( |
84 PrefRegistrySyncable::UNSYNCABLE_PREF); | 94 prefs::kWebKitGlobalFixedFontFamily, |
85 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSerifFontFamily, | 95 IDS_FIXED_FONT_FAMILY, |
86 IDS_SERIF_FONT_FAMILY, | 96 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
87 PrefRegistrySyncable::UNSYNCABLE_PREF); | 97 prefs->RegisterLocalizedStringPref( |
88 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalSansSerifFontFamily, | 98 prefs::kWebKitGlobalSerifFontFamily, |
89 IDS_SANS_SERIF_FONT_FAMILY, | 99 IDS_SERIF_FONT_FAMILY, |
90 PrefRegistrySyncable::UNSYNCABLE_PREF); | 100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
91 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalCursiveFontFamily, | 101 prefs->RegisterLocalizedStringPref( |
92 IDS_CURSIVE_FONT_FAMILY, | 102 prefs::kWebKitGlobalSansSerifFontFamily, |
93 PrefRegistrySyncable::UNSYNCABLE_PREF); | 103 IDS_SANS_SERIF_FONT_FAMILY, |
94 prefs->RegisterLocalizedStringPref(prefs::kWebKitGlobalFantasyFontFamily, | 104 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
95 IDS_FANTASY_FONT_FAMILY, | 105 prefs->RegisterLocalizedStringPref( |
96 PrefRegistrySyncable::UNSYNCABLE_PREF); | 106 prefs::kWebKitGlobalCursiveFontFamily, |
| 107 IDS_CURSIVE_FONT_FAMILY, |
| 108 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 109 prefs->RegisterLocalizedStringPref( |
| 110 prefs::kWebKitGlobalFantasyFontFamily, |
| 111 IDS_FANTASY_FONT_FAMILY, |
| 112 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
97 } | 113 } |
98 | 114 |
99 // The list of prefs we want to observe. | 115 // The list of prefs we want to observe. |
100 const char* kPrefsToObserve[] = { | 116 const char* kPrefsToObserve[] = { |
101 prefs::kDefaultCharset, | 117 prefs::kDefaultCharset, |
102 prefs::kWebKitAllowDisplayingInsecureContent, | 118 prefs::kWebKitAllowDisplayingInsecureContent, |
103 prefs::kWebKitAllowRunningInsecureContent, | 119 prefs::kWebKitAllowRunningInsecureContent, |
104 prefs::kWebKitDefaultFixedFontSize, | 120 prefs::kWebKitDefaultFixedFontSize, |
105 prefs::kWebKitDefaultFontSize, | 121 prefs::kWebKitDefaultFontSize, |
106 #if defined(OS_ANDROID) | 122 #if defined(OS_ANDROID) |
(...skipping 11 matching lines...) Expand all Loading... |
118 }; | 134 }; |
119 | 135 |
120 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); | 136 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); |
121 | 137 |
122 // Registers a preference under the path |pref_name| for each script used for | 138 // Registers a preference under the path |pref_name| for each script used for |
123 // per-script font prefs. | 139 // per-script font prefs. |
124 // For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"): | 140 // For example, for WEBKIT_WEBPREFS_FONTS_SERIF ("fonts.serif"): |
125 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. | 141 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. |
126 // |fonts_with_defaults| contains all |pref_names| already registered since they | 142 // |fonts_with_defaults| contains all |pref_names| already registered since they |
127 // have a specified default value. | 143 // have a specified default value. |
128 void RegisterFontFamilyPrefs(PrefRegistrySyncable* registry, | 144 void RegisterFontFamilyPrefs(user_prefs::PrefRegistrySyncable* registry, |
129 const std::set<std::string>& fonts_with_defaults) { | 145 const std::set<std::string>& fonts_with_defaults) { |
130 | 146 |
131 // Expand the font concatenated with script name so this stays at RO memory | 147 // Expand the font concatenated with script name so this stays at RO memory |
132 // rather than allocated in heap. | 148 // rather than allocated in heap. |
133 static const char* const kFontFamilyMap[] = { | 149 static const char* const kFontFamilyMap[] = { |
134 #define EXPAND_SCRIPT_FONT(map_name, script_name) map_name "." script_name, | 150 #define EXPAND_SCRIPT_FONT(map_name, script_name) map_name "." script_name, |
135 | 151 |
136 #include "chrome/common/pref_font_script_names-inl.h" | 152 #include "chrome/common/pref_font_script_names-inl.h" |
137 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_CURSIVE) | 153 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_CURSIVE) |
138 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_FANTASY) | 154 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_FANTASY) |
139 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_FIXED) | 155 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_FIXED) |
140 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_PICTOGRAPH) | 156 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_PICTOGRAPH) |
141 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_SANSERIF) | 157 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_SANSERIF) |
142 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_SERIF) | 158 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_SERIF) |
143 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_STANDARD) | 159 ALL_FONT_SCRIPTS(WEBKIT_WEBPREFS_FONTS_STANDARD) |
144 | 160 |
145 #undef EXPAND_SCRIPT_FONT | 161 #undef EXPAND_SCRIPT_FONT |
146 }; | 162 }; |
147 | 163 |
148 for (size_t i = 0; i < arraysize(kFontFamilyMap); ++i) { | 164 for (size_t i = 0; i < arraysize(kFontFamilyMap); ++i) { |
149 const char* pref_name = kFontFamilyMap[i]; | 165 const char* pref_name = kFontFamilyMap[i]; |
150 if (fonts_with_defaults.find(pref_name) == fonts_with_defaults.end()) { | 166 if (fonts_with_defaults.find(pref_name) == fonts_with_defaults.end()) { |
151 // We haven't already set a default value for this font preference, so set | 167 // We haven't already set a default value for this font preference, so set |
152 // an empty string as the default. | 168 // an empty string as the default. |
153 registry->RegisterStringPref( | 169 registry->RegisterStringPref( |
154 pref_name, std::string(), PrefRegistrySyncable::UNSYNCABLE_PREF); | 170 pref_name, |
| 171 std::string(), |
| 172 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
155 } | 173 } |
156 } | 174 } |
157 } | 175 } |
158 | 176 |
159 #if !defined(OS_ANDROID) | 177 #if !defined(OS_ANDROID) |
160 // Registers |obs| to observe per-script font prefs under the path |map_name|. | 178 // Registers |obs| to observe per-script font prefs under the path |map_name|. |
161 // On android, there's no exposed way to change these prefs, so we can save | 179 // On android, there's no exposed way to change these prefs, so we can save |
162 // ~715KB of heap and some startup cycles by avoiding observing these prefs | 180 // ~715KB of heap and some startup cycles by avoiding observing these prefs |
163 // since they will never change. | 181 // since they will never change. |
164 void RegisterFontFamilyMapObserver( | 182 void RegisterFontFamilyMapObserver( |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // List of keys that cannot be changed in the user prefs file by the incognito | 488 // List of keys that cannot be changed in the user prefs file by the incognito |
471 // profile. All preferences that store information about the browsing history | 489 // profile. All preferences that store information about the browsing history |
472 // or behavior of the user should have this property. | 490 // or behavior of the user should have this property. |
473 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement); | 491 pref_store->RegisterOverlayPref(prefs::kBrowserWindowPlacement); |
474 #if defined(OS_ANDROID) || defined(OS_IOS) | 492 #if defined(OS_ANDROID) || defined(OS_IOS) |
475 pref_store->RegisterOverlayPref(prefs::kProxy); | 493 pref_store->RegisterOverlayPref(prefs::kProxy); |
476 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 494 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
477 } | 495 } |
478 | 496 |
479 // static | 497 // static |
480 void PrefsTabHelper::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 498 void PrefsTabHelper::RegisterUserPrefs( |
| 499 user_prefs::PrefRegistrySyncable* registry) { |
481 WebPreferences pref_defaults; | 500 WebPreferences pref_defaults; |
482 registry->RegisterBooleanPref(prefs::kWebKitJavascriptEnabled, | 501 registry->RegisterBooleanPref( |
483 pref_defaults.javascript_enabled, | 502 prefs::kWebKitJavascriptEnabled, |
484 PrefRegistrySyncable::UNSYNCABLE_PREF); | 503 pref_defaults.javascript_enabled, |
485 registry->RegisterBooleanPref(prefs::kWebKitWebSecurityEnabled, | 504 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
486 pref_defaults.web_security_enabled, | 505 registry->RegisterBooleanPref( |
487 PrefRegistrySyncable::UNSYNCABLE_PREF); | 506 prefs::kWebKitWebSecurityEnabled, |
| 507 pref_defaults.web_security_enabled, |
| 508 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
488 registry->RegisterBooleanPref( | 509 registry->RegisterBooleanPref( |
489 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, | 510 prefs::kWebKitJavascriptCanOpenWindowsAutomatically, |
490 true, | 511 true, |
491 PrefRegistrySyncable::UNSYNCABLE_PREF); | 512 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
492 registry->RegisterBooleanPref(prefs::kWebKitLoadsImagesAutomatically, | 513 registry->RegisterBooleanPref( |
493 pref_defaults.loads_images_automatically, | 514 prefs::kWebKitLoadsImagesAutomatically, |
494 PrefRegistrySyncable::UNSYNCABLE_PREF); | 515 pref_defaults.loads_images_automatically, |
495 registry->RegisterBooleanPref(prefs::kWebKitPluginsEnabled, | 516 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
496 pref_defaults.plugins_enabled, | 517 registry->RegisterBooleanPref( |
497 PrefRegistrySyncable::UNSYNCABLE_PREF); | 518 prefs::kWebKitPluginsEnabled, |
498 registry->RegisterBooleanPref(prefs::kWebKitDomPasteEnabled, | 519 pref_defaults.plugins_enabled, |
499 pref_defaults.dom_paste_enabled, | 520 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
500 PrefRegistrySyncable::UNSYNCABLE_PREF); | 521 registry->RegisterBooleanPref( |
501 registry->RegisterBooleanPref(prefs::kWebKitShrinksStandaloneImagesToFit, | 522 prefs::kWebKitDomPasteEnabled, |
502 pref_defaults.shrinks_standalone_images_to_fit, | 523 pref_defaults.dom_paste_enabled, |
503 PrefRegistrySyncable::UNSYNCABLE_PREF); | 524 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
504 registry->RegisterDictionaryPref(prefs::kWebKitInspectorSettings, | 525 registry->RegisterBooleanPref( |
505 PrefRegistrySyncable::UNSYNCABLE_PREF); | 526 prefs::kWebKitShrinksStandaloneImagesToFit, |
506 registry->RegisterBooleanPref(prefs::kWebKitTextAreasAreResizable, | 527 pref_defaults.shrinks_standalone_images_to_fit, |
507 pref_defaults.text_areas_are_resizable, | 528 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
508 PrefRegistrySyncable::UNSYNCABLE_PREF); | 529 registry->RegisterDictionaryPref( |
509 registry->RegisterBooleanPref(prefs::kWebKitJavaEnabled, | 530 prefs::kWebKitInspectorSettings, |
510 pref_defaults.java_enabled, | 531 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
511 PrefRegistrySyncable::UNSYNCABLE_PREF); | 532 registry->RegisterBooleanPref( |
512 registry->RegisterBooleanPref(prefs::kWebkitTabsToLinks, | 533 prefs::kWebKitTextAreasAreResizable, |
513 pref_defaults.tabs_to_links, | 534 pref_defaults.text_areas_are_resizable, |
514 PrefRegistrySyncable::UNSYNCABLE_PREF); | 535 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
515 registry->RegisterBooleanPref(prefs::kWebKitAllowRunningInsecureContent, | 536 registry->RegisterBooleanPref( |
516 false, | 537 prefs::kWebKitJavaEnabled, |
517 PrefRegistrySyncable::UNSYNCABLE_PREF); | 538 pref_defaults.java_enabled, |
518 registry->RegisterBooleanPref(prefs::kWebKitAllowDisplayingInsecureContent, | 539 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
519 true, | 540 registry->RegisterBooleanPref( |
520 PrefRegistrySyncable::UNSYNCABLE_PREF); | 541 prefs::kWebkitTabsToLinks, |
521 registry->RegisterBooleanPref(prefs::kEnableReferrers, | 542 pref_defaults.tabs_to_links, |
522 true, | 543 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
523 PrefRegistrySyncable::UNSYNCABLE_PREF); | 544 registry->RegisterBooleanPref( |
| 545 prefs::kWebKitAllowRunningInsecureContent, |
| 546 false, |
| 547 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 548 registry->RegisterBooleanPref( |
| 549 prefs::kWebKitAllowDisplayingInsecureContent, |
| 550 true, |
| 551 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 552 registry->RegisterBooleanPref( |
| 553 prefs::kEnableReferrers, |
| 554 true, |
| 555 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
524 #if defined(OS_ANDROID) | 556 #if defined(OS_ANDROID) |
525 registry->RegisterDoublePref(prefs::kWebKitFontScaleFactor, | 557 registry->RegisterDoublePref( |
526 pref_defaults.font_scale_factor, | 558 prefs::kWebKitFontScaleFactor, |
527 PrefRegistrySyncable::UNSYNCABLE_PREF); | 559 pref_defaults.font_scale_factor, |
528 registry->RegisterBooleanPref(prefs::kWebKitForceEnableZoom, | 560 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
529 pref_defaults.force_enable_zoom, | 561 registry->RegisterBooleanPref( |
530 PrefRegistrySyncable::UNSYNCABLE_PREF); | 562 prefs::kWebKitForceEnableZoom, |
| 563 pref_defaults.force_enable_zoom, |
| 564 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
531 #endif | 565 #endif |
532 | 566 |
533 #if !defined(OS_MACOSX) | 567 #if !defined(OS_MACOSX) |
534 registry->RegisterLocalizedStringPref(prefs::kAcceptLanguages, | 568 registry->RegisterLocalizedStringPref( |
535 IDS_ACCEPT_LANGUAGES, | 569 prefs::kAcceptLanguages, |
536 PrefRegistrySyncable::SYNCABLE_PREF); | 570 IDS_ACCEPT_LANGUAGES, |
| 571 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
537 #else | 572 #else |
538 // Not used in OSX. | 573 // Not used in OSX. |
539 registry->RegisterLocalizedStringPref(prefs::kAcceptLanguages, | 574 registry->RegisterLocalizedStringPref( |
540 IDS_ACCEPT_LANGUAGES, | 575 prefs::kAcceptLanguages, |
541 PrefRegistrySyncable::UNSYNCABLE_PREF); | 576 IDS_ACCEPT_LANGUAGES, |
| 577 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
542 #endif | 578 #endif |
543 registry->RegisterLocalizedStringPref(prefs::kDefaultCharset, | 579 registry->RegisterLocalizedStringPref( |
544 IDS_DEFAULT_ENCODING, | 580 prefs::kDefaultCharset, |
545 PrefRegistrySyncable::SYNCABLE_PREF); | 581 IDS_DEFAULT_ENCODING, |
| 582 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
546 | 583 |
547 // Register font prefs that have defaults. | 584 // Register font prefs that have defaults. |
548 std::set<std::string> fonts_with_defaults; | 585 std::set<std::string> fonts_with_defaults; |
549 UScriptCode browser_script = GetScriptOfBrowserLocale(); | 586 UScriptCode browser_script = GetScriptOfBrowserLocale(); |
550 for (size_t i = 0; i < kFontDefaultsLength; ++i) { | 587 for (size_t i = 0; i < kFontDefaultsLength; ++i) { |
551 const FontDefault& pref = kFontDefaults[i]; | 588 const FontDefault& pref = kFontDefaults[i]; |
552 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name); | 589 UScriptCode pref_script = GetScriptOfFontPref(pref.pref_name); |
553 | 590 |
554 // Suppress this default font pref value if it is for the primary script of | 591 // Suppress this default font pref value if it is for the primary script of |
555 // the browser's UI locale. For example, if the pref is for the sans-serif | 592 // the browser's UI locale. For example, if the pref is for the sans-serif |
556 // font for the Cyrillic script, and the browser locale is "ru" (Russian), | 593 // font for the Cyrillic script, and the browser locale is "ru" (Russian), |
557 // the default is suppressed. Otherwise, the default would override the | 594 // the default is suppressed. Otherwise, the default would override the |
558 // user's font preferences when viewing pages in their native language. | 595 // user's font preferences when viewing pages in their native language. |
559 // This is because users have no way yet of customizing their per-script | 596 // This is because users have no way yet of customizing their per-script |
560 // font preferences. The font prefs accessible in the options UI are for | 597 // font preferences. The font prefs accessible in the options UI are for |
561 // the default, unknown script; these prefs have less priority than the | 598 // the default, unknown script; these prefs have less priority than the |
562 // per-script font prefs when the script of the content is known. This code | 599 // per-script font prefs when the script of the content is known. This code |
563 // can possibly be removed later if users can easily access per-script font | 600 // can possibly be removed later if users can easily access per-script font |
564 // prefs (e.g., via the extensions workflow), or the problem turns out to | 601 // prefs (e.g., via the extensions workflow), or the problem turns out to |
565 // not be really critical after all. | 602 // not be really critical after all. |
566 if (browser_script != pref_script) { | 603 if (browser_script != pref_script) { |
567 registry->RegisterLocalizedStringPref( | 604 registry->RegisterLocalizedStringPref( |
568 pref.pref_name, | 605 pref.pref_name, |
569 pref.resource_id, | 606 pref.resource_id, |
570 PrefRegistrySyncable::UNSYNCABLE_PREF); | 607 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
571 fonts_with_defaults.insert(pref.pref_name); | 608 fonts_with_defaults.insert(pref.pref_name); |
572 } | 609 } |
573 } | 610 } |
574 | 611 |
575 // Register font prefs that don't have defaults. | 612 // Register font prefs that don't have defaults. |
576 RegisterFontFamilyPrefs(registry, fonts_with_defaults); | 613 RegisterFontFamilyPrefs(registry, fonts_with_defaults); |
577 | 614 |
578 registry->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFontSize, | 615 registry->RegisterLocalizedIntegerPref( |
579 IDS_DEFAULT_FONT_SIZE, | 616 prefs::kWebKitDefaultFontSize, |
580 PrefRegistrySyncable::UNSYNCABLE_PREF); | 617 IDS_DEFAULT_FONT_SIZE, |
581 registry->RegisterLocalizedIntegerPref(prefs::kWebKitDefaultFixedFontSize, | 618 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
582 IDS_DEFAULT_FIXED_FONT_SIZE, | 619 registry->RegisterLocalizedIntegerPref( |
583 PrefRegistrySyncable::UNSYNCABLE_PREF); | 620 prefs::kWebKitDefaultFixedFontSize, |
584 registry->RegisterLocalizedIntegerPref(prefs::kWebKitMinimumFontSize, | 621 IDS_DEFAULT_FIXED_FONT_SIZE, |
585 IDS_MINIMUM_FONT_SIZE, | 622 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
586 PrefRegistrySyncable::UNSYNCABLE_PREF); | 623 registry->RegisterLocalizedIntegerPref( |
| 624 prefs::kWebKitMinimumFontSize, |
| 625 IDS_MINIMUM_FONT_SIZE, |
| 626 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
587 registry->RegisterLocalizedIntegerPref( | 627 registry->RegisterLocalizedIntegerPref( |
588 prefs::kWebKitMinimumLogicalFontSize, | 628 prefs::kWebKitMinimumLogicalFontSize, |
589 IDS_MINIMUM_LOGICAL_FONT_SIZE, | 629 IDS_MINIMUM_LOGICAL_FONT_SIZE, |
590 PrefRegistrySyncable::UNSYNCABLE_PREF); | 630 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
591 registry->RegisterLocalizedBooleanPref(prefs::kWebKitUsesUniversalDetector, | 631 registry->RegisterLocalizedBooleanPref( |
592 IDS_USES_UNIVERSAL_DETECTOR, | 632 prefs::kWebKitUsesUniversalDetector, |
593 PrefRegistrySyncable::SYNCABLE_PREF); | 633 IDS_USES_UNIVERSAL_DETECTOR, |
594 registry->RegisterLocalizedStringPref(prefs::kStaticEncodings, | 634 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
595 IDS_STATIC_ENCODING_LIST, | 635 registry->RegisterLocalizedStringPref( |
596 PrefRegistrySyncable::UNSYNCABLE_PREF); | 636 prefs::kStaticEncodings, |
597 registry->RegisterStringPref(prefs::kRecentlySelectedEncoding, | 637 IDS_STATIC_ENCODING_LIST, |
598 std::string(), | 638 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
599 PrefRegistrySyncable::UNSYNCABLE_PREF); | 639 registry->RegisterStringPref( |
| 640 prefs::kRecentlySelectedEncoding, |
| 641 std::string(), |
| 642 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
600 | 643 |
601 RegisterPrefsToMigrate(registry); | 644 RegisterPrefsToMigrate(registry); |
602 } | 645 } |
603 | 646 |
604 void PrefsTabHelper::MigrateUserPrefs(PrefService* prefs) { | 647 void PrefsTabHelper::MigrateUserPrefs(PrefService* prefs) { |
605 for (int i = 0; i < kPrefsToMigrateLength; ++i) { | 648 for (int i = 0; i < kPrefsToMigrateLength; ++i) { |
606 const PrefService::Preference* pref = | 649 const PrefService::Preference* pref = |
607 prefs->FindPreference(kPrefNamesToMigrate[i].from); | 650 prefs->FindPreference(kPrefNamesToMigrate[i].from); |
608 if (pref && !pref->IsDefaultValue()) { | 651 if (pref && !pref->IsDefaultValue()) { |
609 prefs->Set(kPrefNamesToMigrate[i].to, *pref->GetValue()); | 652 prefs->Set(kPrefNamesToMigrate[i].to, *pref->GetValue()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 WebPreferences web_prefs = | 720 WebPreferences web_prefs = |
678 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); | 721 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); |
679 OverrideFontFamily(&web_prefs, generic_family, script, std::string()); | 722 OverrideFontFamily(&web_prefs, generic_family, script, std::string()); |
680 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); | 723 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); |
681 return; | 724 return; |
682 } | 725 } |
683 } | 726 } |
684 | 727 |
685 UpdateWebPreferences(); | 728 UpdateWebPreferences(); |
686 } | 729 } |
OLD | NEW |