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/browser_ui_prefs.h" | 5 #include "chrome/browser/ui/browser_ui_prefs.h" |
6 | 6 |
7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/first_run/first_run.h" | 9 #include "chrome/browser/first_run/first_run.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "components/user_prefs/pref_registry_syncable.h" | 12 #include "components/user_prefs/pref_registry_syncable.h" |
13 | 13 |
14 namespace chrome { | 14 namespace chrome { |
15 | 15 |
16 void RegisterBrowserPrefs(PrefRegistrySimple* registry) { | 16 void RegisterBrowserPrefs(PrefRegistrySimple* registry) { |
17 registry->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); | 17 registry->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); |
18 registry->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true); | 18 registry->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true); |
19 registry->RegisterIntegerPref(prefs::kShowFirstRunBubbleOption, | 19 registry->RegisterIntegerPref(prefs::kShowFirstRunBubbleOption, |
20 first_run::FIRST_RUN_BUBBLE_DONT_SHOW); | 20 first_run::FIRST_RUN_BUBBLE_DONT_SHOW); |
21 } | 21 } |
22 | 22 |
23 void RegisterBrowserUserPrefs(PrefRegistrySyncable* registry) { | 23 void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable* registry) { |
24 registry->RegisterBooleanPref(prefs::kHomePageChanged, | 24 registry->RegisterBooleanPref( |
25 false, | 25 prefs::kHomePageChanged, |
26 PrefRegistrySyncable::UNSYNCABLE_PREF); | 26 false, |
27 registry->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, | 27 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
28 true, | 28 registry->RegisterBooleanPref( |
29 PrefRegistrySyncable::SYNCABLE_PREF); | 29 prefs::kHomePageIsNewTabPage, |
30 registry->RegisterBooleanPref(prefs::kShowHomeButton, | 30 true, |
31 false, | 31 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
32 PrefRegistrySyncable::SYNCABLE_PREF); | 32 registry->RegisterBooleanPref( |
| 33 prefs::kShowHomeButton, |
| 34 false, |
| 35 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
33 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
34 // This really belongs in platform code, but there's no good place to | 37 // This really belongs in platform code, but there's no good place to |
35 // initialize it between the time when the AppController is created | 38 // initialize it between the time when the AppController is created |
36 // (where there's no profile) and the time the controller gets another | 39 // (where there's no profile) and the time the controller gets another |
37 // crack at the start of the main event loop. By that time, | 40 // crack at the start of the main event loop. By that time, |
38 // StartupBrowserCreator has already created the browser window, and it's too | 41 // StartupBrowserCreator has already created the browser window, and it's too |
39 // late: we need the pref to be already initialized. Doing it here also saves | 42 // late: we need the pref to be already initialized. Doing it here also saves |
40 // us from having to hard-code pref registration in the several unit tests | 43 // us from having to hard-code pref registration in the several unit tests |
41 // that use this preference. | 44 // that use this preference. |
42 registry->RegisterBooleanPref(prefs::kShowUpdatePromotionInfoBar, | 45 registry->RegisterBooleanPref( |
43 true, | 46 prefs::kShowUpdatePromotionInfoBar, |
44 PrefRegistrySyncable::UNSYNCABLE_PREF); | 47 true, |
| 48 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
45 #endif | 49 #endif |
46 registry->RegisterBooleanPref(prefs::kDeleteBrowsingHistory, | 50 registry->RegisterBooleanPref( |
47 true, | 51 prefs::kDeleteBrowsingHistory, |
48 PrefRegistrySyncable::SYNCABLE_PREF); | 52 true, |
49 registry->RegisterBooleanPref(prefs::kDeleteDownloadHistory, | 53 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
50 true, | 54 registry->RegisterBooleanPref( |
51 PrefRegistrySyncable::SYNCABLE_PREF); | 55 prefs::kDeleteDownloadHistory, |
52 registry->RegisterBooleanPref(prefs::kDeleteCache, | 56 true, |
53 true, | 57 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
54 PrefRegistrySyncable::SYNCABLE_PREF); | 58 registry->RegisterBooleanPref( |
55 registry->RegisterBooleanPref(prefs::kDeleteCookies, | 59 prefs::kDeleteCache, |
56 true, | 60 true, |
57 PrefRegistrySyncable::SYNCABLE_PREF); | 61 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
58 registry->RegisterBooleanPref(prefs::kDeletePasswords, | 62 registry->RegisterBooleanPref( |
59 false, | 63 prefs::kDeleteCookies, |
60 PrefRegistrySyncable::SYNCABLE_PREF); | 64 true, |
61 registry->RegisterBooleanPref(prefs::kDeleteFormData, | 65 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
62 false, | 66 registry->RegisterBooleanPref( |
63 PrefRegistrySyncable::SYNCABLE_PREF); | 67 prefs::kDeletePasswords, |
64 registry->RegisterBooleanPref(prefs::kDeleteHostedAppsData, | 68 false, |
65 false, | 69 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
66 PrefRegistrySyncable::SYNCABLE_PREF); | 70 registry->RegisterBooleanPref( |
67 registry->RegisterIntegerPref(prefs::kDeleteTimePeriod, | 71 prefs::kDeleteFormData, |
68 0, | 72 false, |
69 PrefRegistrySyncable::SYNCABLE_PREF); | 73 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
70 registry->RegisterInt64Pref(prefs::kLastClearBrowsingDataTime, | 74 registry->RegisterBooleanPref( |
71 0, | 75 prefs::kDeleteHostedAppsData, |
72 PrefRegistrySyncable::UNSYNCABLE_PREF); | 76 false, |
73 registry->RegisterBooleanPref(prefs::kCheckDefaultBrowser, | 77 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
74 true, | 78 registry->RegisterIntegerPref( |
75 PrefRegistrySyncable::UNSYNCABLE_PREF); | 79 prefs::kDeleteTimePeriod, |
| 80 0, |
| 81 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 82 registry->RegisterInt64Pref( |
| 83 prefs::kLastClearBrowsingDataTime, |
| 84 0, |
| 85 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 86 registry->RegisterBooleanPref( |
| 87 prefs::kCheckDefaultBrowser, |
| 88 true, |
| 89 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
76 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
77 // As with Mac-spacific code above, it should be in a platform-specific | 91 // As with Mac-spacific code above, it should be in a platform-specific |
78 // section somewhere, but there is no good place for it. | 92 // section somewhere, but there is no good place for it. |
79 registry->RegisterBooleanPref(prefs::kSuppressSwitchToMetroModeOnSetDefault, | 93 registry->RegisterBooleanPref( |
80 false, | 94 prefs::kSuppressSwitchToMetroModeOnSetDefault, |
81 PrefRegistrySyncable::UNSYNCABLE_PREF); | 95 false, |
| 96 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
82 #endif | 97 #endif |
83 registry->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, | 98 registry->RegisterBooleanPref( |
84 true, | 99 prefs::kShowOmniboxSearchHint, |
85 PrefRegistrySyncable::UNSYNCABLE_PREF); | 100 true, |
86 registry->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, | 101 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
87 true, | 102 registry->RegisterBooleanPref( |
88 PrefRegistrySyncable::UNSYNCABLE_PREF); | 103 prefs::kWebAppCreateOnDesktop, |
89 registry->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, | 104 true, |
90 true, | 105 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
91 PrefRegistrySyncable::UNSYNCABLE_PREF); | 106 registry->RegisterBooleanPref( |
92 registry->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, | 107 prefs::kWebAppCreateInAppsMenu, |
93 true, | 108 true, |
94 PrefRegistrySyncable::UNSYNCABLE_PREF); | 109 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
95 registry->RegisterBooleanPref(prefs::kEnableTranslate, | 110 registry->RegisterBooleanPref( |
96 true, | 111 prefs::kWebAppCreateInQuickLaunchBar, |
97 PrefRegistrySyncable::SYNCABLE_PREF); | 112 true, |
98 registry->RegisterStringPref(prefs::kCloudPrintEmail, | 113 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
99 std::string(), | 114 registry->RegisterBooleanPref( |
100 PrefRegistrySyncable::UNSYNCABLE_PREF); | 115 prefs::kEnableTranslate, |
101 registry->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, | 116 true, |
102 true, | 117 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
103 PrefRegistrySyncable::UNSYNCABLE_PREF); | 118 registry->RegisterStringPref( |
104 registry->RegisterBooleanPref(prefs::kCloudPrintSubmitEnabled, | 119 prefs::kCloudPrintEmail, |
105 true, | 120 std::string(), |
106 PrefRegistrySyncable::UNSYNCABLE_PREF); | 121 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
107 registry->RegisterBooleanPref(prefs::kDevToolsDisabled, | 122 registry->RegisterBooleanPref( |
108 false, | 123 prefs::kCloudPrintProxyEnabled, |
109 PrefRegistrySyncable::UNSYNCABLE_PREF); | 124 true, |
110 registry->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, | 125 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
111 -1, | 126 registry->RegisterBooleanPref( |
112 PrefRegistrySyncable::UNSYNCABLE_PREF); | 127 prefs::kCloudPrintSubmitEnabled, |
113 registry->RegisterIntegerPref(prefs::kDevToolsVSplitLocation, | 128 true, |
114 -1, | 129 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
115 PrefRegistrySyncable::UNSYNCABLE_PREF); | 130 registry->RegisterBooleanPref( |
116 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement, | 131 prefs::kDevToolsDisabled, |
117 PrefRegistrySyncable::UNSYNCABLE_PREF); | 132 false, |
118 registry->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement, | 133 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
119 PrefRegistrySyncable::UNSYNCABLE_PREF); | 134 registry->RegisterIntegerPref( |
120 registry->RegisterBooleanPref(prefs::kImportBookmarks, | 135 prefs::kDevToolsHSplitLocation, |
121 true, | 136 -1, |
122 PrefRegistrySyncable::UNSYNCABLE_PREF); | 137 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
123 registry->RegisterBooleanPref(prefs::kImportHistory, | 138 registry->RegisterIntegerPref( |
124 true, | 139 prefs::kDevToolsVSplitLocation, |
125 PrefRegistrySyncable::UNSYNCABLE_PREF); | 140 -1, |
126 registry->RegisterBooleanPref(prefs::kImportHomepage, | 141 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
127 true, | 142 registry->RegisterDictionaryPref( |
128 PrefRegistrySyncable::UNSYNCABLE_PREF); | 143 prefs::kBrowserWindowPlacement, |
129 registry->RegisterBooleanPref(prefs::kImportSearchEngine, | 144 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
130 true, | 145 registry->RegisterDictionaryPref( |
131 PrefRegistrySyncable::UNSYNCABLE_PREF); | 146 prefs::kPreferencesWindowPlacement, |
132 registry->RegisterBooleanPref(prefs::kImportSavedPasswords, | 147 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
133 true, | 148 registry->RegisterBooleanPref( |
134 PrefRegistrySyncable::UNSYNCABLE_PREF); | 149 prefs::kImportBookmarks, |
135 registry->RegisterBooleanPref(prefs::kEnableDoNotTrack, | 150 true, |
136 false, | 151 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
137 PrefRegistrySyncable::SYNCABLE_PREF); | 152 registry->RegisterBooleanPref( |
| 153 prefs::kImportHistory, |
| 154 true, |
| 155 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 156 registry->RegisterBooleanPref( |
| 157 prefs::kImportHomepage, |
| 158 true, |
| 159 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 160 registry->RegisterBooleanPref( |
| 161 prefs::kImportSearchEngine, |
| 162 true, |
| 163 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 164 registry->RegisterBooleanPref( |
| 165 prefs::kImportSavedPasswords, |
| 166 true, |
| 167 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 168 registry->RegisterBooleanPref( |
| 169 prefs::kEnableDoNotTrack, |
| 170 false, |
| 171 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
138 | 172 |
139 // Dictionaries to keep track of default tasks in the file browser. | 173 // Dictionaries to keep track of default tasks in the file browser. |
140 registry->RegisterDictionaryPref(prefs::kDefaultTasksByMimeType, | 174 registry->RegisterDictionaryPref( |
141 PrefRegistrySyncable::SYNCABLE_PREF); | 175 prefs::kDefaultTasksByMimeType, |
142 registry->RegisterDictionaryPref(prefs::kDefaultTasksBySuffix, | 176 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
143 PrefRegistrySyncable::SYNCABLE_PREF); | 177 registry->RegisterDictionaryPref( |
| 178 prefs::kDefaultTasksBySuffix, |
| 179 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
144 | 180 |
145 // We need to register the type of these preferences in order to query | 181 // We need to register the type of these preferences in order to query |
146 // them even though they're only typically controlled via policy. | 182 // them even though they're only typically controlled via policy. |
147 registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated, | 183 registry->RegisterBooleanPref( |
148 false, | 184 prefs::kPluginsAllowOutdated, |
149 PrefRegistrySyncable::UNSYNCABLE_PREF); | 185 false, |
150 registry->RegisterBooleanPref(prefs::kPluginsAlwaysAuthorize, | 186 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
151 false, | 187 registry->RegisterBooleanPref( |
152 PrefRegistrySyncable::UNSYNCABLE_PREF); | 188 prefs::kPluginsAlwaysAuthorize, |
153 registry->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, | 189 false, |
154 true, | 190 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
155 PrefRegistrySyncable::UNSYNCABLE_PREF); | 191 registry->RegisterBooleanPref( |
156 registry->RegisterBooleanPref(prefs::kHideWebStoreIcon, | 192 prefs::kClearPluginLSODataEnabled, |
157 false, | 193 true, |
158 PrefRegistrySyncable::UNSYNCABLE_PREF); | 194 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 195 registry->RegisterBooleanPref( |
| 196 prefs::kHideWebStoreIcon, |
| 197 false, |
| 198 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
159 } | 199 } |
160 | 200 |
161 void RegisterAppPrefs(const std::string& app_name, Profile* profile) { | 201 void RegisterAppPrefs(const std::string& app_name, Profile* profile) { |
162 // We need to register the window position pref. | 202 // We need to register the window position pref. |
163 // | 203 // |
164 // TODO(mnissler): Use a separate pref name pointing to a single | 204 // TODO(mnissler): Use a separate pref name pointing to a single |
165 // dictionary instead. Also tracked as http://crbug.com/167256 | 205 // dictionary instead. Also tracked as http://crbug.com/167256 |
166 std::string window_pref(prefs::kBrowserWindowPlacement); | 206 std::string window_pref(prefs::kBrowserWindowPlacement); |
167 window_pref.append("_"); | 207 window_pref.append("_"); |
168 window_pref.append(app_name); | 208 window_pref.append(app_name); |
169 PrefService* prefs = profile->GetPrefs(); | 209 PrefService* prefs = profile->GetPrefs(); |
170 if (!prefs->FindPreference(window_pref.c_str())) { | 210 if (!prefs->FindPreference(window_pref.c_str())) { |
171 // TODO(joi): Do all registration up front. | 211 // TODO(joi): Do all registration up front. |
172 scoped_refptr<PrefRegistrySyncable> registry( | 212 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
173 static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry())); | 213 static_cast<user_prefs::PrefRegistrySyncable*>( |
174 registry->RegisterDictionaryPref(window_pref.c_str(), | 214 prefs->DeprecatedGetPrefRegistry())); |
175 PrefRegistrySyncable::UNSYNCABLE_PREF); | 215 registry->RegisterDictionaryPref( |
| 216 window_pref.c_str(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
176 } | 217 } |
177 } | 218 } |
178 | 219 |
179 | 220 |
180 } // namespace chrome | 221 } // namespace chrome |
OLD | NEW |