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/prefs/chrome_pref_service_factory.h" | 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const size_t kTrackedPrefsReportingIDsCount = 16; | 178 const size_t kTrackedPrefsReportingIDsCount = 16; |
179 COMPILE_ASSERT(kTrackedPrefsReportingIDsCount >= arraysize(kTrackedPrefs), | 179 COMPILE_ASSERT(kTrackedPrefsReportingIDsCount >= arraysize(kTrackedPrefs), |
180 need_to_increment_ids_count); | 180 need_to_increment_ids_count); |
181 | 181 |
182 // Each group enforces a superset of the protection provided by the previous | 182 // Each group enforces a superset of the protection provided by the previous |
183 // one. | 183 // one. |
184 enum SettingsEnforcementGroup { | 184 enum SettingsEnforcementGroup { |
185 GROUP_NO_ENFORCEMENT, | 185 GROUP_NO_ENFORCEMENT, |
186 // Enforce protected settings on profile loads. | 186 // Enforce protected settings on profile loads. |
187 GROUP_ENFORCE_ALWAYS, | 187 GROUP_ENFORCE_ALWAYS, |
188 // Also enforce extension settings. | 188 // Also enforce extension default search. |
189 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS, | 189 GROUP_ENFORCE_ALWAYS_WITH_DSE, |
190 // Also enforce extension settings and default search. | 190 // Also enforce extension settings and default search. |
191 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE, | 191 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE, |
192 // The default enforcement group contains all protection features. | 192 // The default enforcement group contains all protection features. |
193 GROUP_ENFORCE_DEFAULT | 193 GROUP_ENFORCE_DEFAULT |
194 }; | 194 }; |
195 | 195 |
196 SettingsEnforcementGroup GetSettingsEnforcementGroup() { | 196 SettingsEnforcementGroup GetSettingsEnforcementGroup() { |
197 # if defined(OS_WIN) | 197 # if defined(OS_WIN) |
198 if (!g_disable_delays_and_domain_check_for_testing) { | 198 if (!g_disable_delays_and_domain_check_for_testing) { |
199 static bool first_call = true; | 199 static bool first_call = true; |
(...skipping 10 matching lines...) Expand all Loading... |
210 | 210 |
211 struct { | 211 struct { |
212 const char* group_name; | 212 const char* group_name; |
213 SettingsEnforcementGroup group; | 213 SettingsEnforcementGroup group; |
214 } static const kEnforcementLevelMap[] = { | 214 } static const kEnforcementLevelMap[] = { |
215 { chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, | 215 { chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, |
216 GROUP_NO_ENFORCEMENT }, | 216 GROUP_NO_ENFORCEMENT }, |
217 { chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, | 217 { chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, |
218 GROUP_ENFORCE_ALWAYS }, | 218 GROUP_ENFORCE_ALWAYS }, |
219 { chrome_prefs::internals:: | 219 { chrome_prefs::internals:: |
220 kSettingsEnforcementGroupEnforceAlwaysWithExtensions, | 220 kSettingsEnforcementGroupEnforceAlwaysWithDSE, |
221 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS }, | 221 GROUP_ENFORCE_ALWAYS_WITH_DSE }, |
222 { chrome_prefs::internals:: | 222 { chrome_prefs::internals:: |
223 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE, | 223 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE, |
224 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE }, | 224 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE }, |
225 }; | 225 }; |
226 | 226 |
227 // Use the no enforcement setting in the absence of a field trial | 227 // Use the no enforcement setting in the absence of a field trial |
228 // config. Remember to update the OFFICIAL_BUILD section of | 228 // config. Remember to update the OFFICIAL_BUILD section of |
229 // extension_startup_browsertest.cc when updating the default value below. | 229 // extension_startup_browsertest.cc when updating the default value below. |
230 // TODO(gab): Change this to the strongest enforcement on all platforms. | 230 // TODO(gab): Change this to the strongest enforcement on all platforms. |
231 SettingsEnforcementGroup enforcement_group = GROUP_NO_ENFORCEMENT; | 231 SettingsEnforcementGroup enforcement_group = GROUP_NO_ENFORCEMENT; |
(...skipping 28 matching lines...) Expand all Loading... |
260 | 260 |
261 std::vector<PrefHashFilter::TrackedPreferenceMetadata> result; | 261 std::vector<PrefHashFilter::TrackedPreferenceMetadata> result; |
262 for (size_t i = 0; i < arraysize(kTrackedPrefs); ++i) { | 262 for (size_t i = 0; i < arraysize(kTrackedPrefs); ++i) { |
263 PrefHashFilter::TrackedPreferenceMetadata data = kTrackedPrefs[i]; | 263 PrefHashFilter::TrackedPreferenceMetadata data = kTrackedPrefs[i]; |
264 | 264 |
265 if (GROUP_NO_ENFORCEMENT == enforcement_group) { | 265 if (GROUP_NO_ENFORCEMENT == enforcement_group) { |
266 // Remove enforcement for all tracked preferences. | 266 // Remove enforcement for all tracked preferences. |
267 data.enforcement_level = PrefHashFilter::NO_ENFORCEMENT; | 267 data.enforcement_level = PrefHashFilter::NO_ENFORCEMENT; |
268 } | 268 } |
269 | 269 |
270 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS && | 270 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_DSE && |
| 271 data.name == DefaultSearchManager::kDefaultSearchProviderDataPrefName) { |
| 272 // Specifically enable default search settings enforcement. |
| 273 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; |
| 274 } |
| 275 |
| 276 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE && |
271 (data.name == extensions::pref_names::kExtensions || | 277 (data.name == extensions::pref_names::kExtensions || |
272 data.name == extensions::pref_names::kKnownDisabled)) { | 278 data.name == extensions::pref_names::kKnownDisabled)) { |
273 // Specifically enable extension settings enforcement and ensure | 279 // Specifically enable extension settings enforcement and ensure |
274 // kKnownDisabled follows it in the Protected Preferences. | 280 // kKnownDisabled follows it in the Protected Preferences. |
275 // TODO(gab): Get rid of kKnownDisabled altogether. | 281 // TODO(gab): Get rid of kKnownDisabled altogether. |
276 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; | 282 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; |
277 } | 283 } |
278 | 284 |
279 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE && | |
280 data.name == DefaultSearchManager::kDefaultSearchProviderDataPrefName) { | |
281 // Specifically enable default search settings enforcement. | |
282 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; | |
283 } | |
284 | |
285 result.push_back(data); | 285 result.push_back(data); |
286 } | 286 } |
287 return result; | 287 return result; |
288 } | 288 } |
289 | 289 |
290 | 290 |
291 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 291 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
292 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 292 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
293 // Sample the histogram also for the successful case in order to get a | 293 // Sample the histogram also for the successful case in order to get a |
294 // baseline on the success rate in addition to the error distribution. | 294 // baseline on the success rate in addition to the error distribution. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 384 |
385 } // namespace | 385 } // namespace |
386 | 386 |
387 namespace chrome_prefs { | 387 namespace chrome_prefs { |
388 | 388 |
389 namespace internals { | 389 namespace internals { |
390 | 390 |
391 const char kSettingsEnforcementTrialName[] = "SettingsEnforcement"; | 391 const char kSettingsEnforcementTrialName[] = "SettingsEnforcement"; |
392 const char kSettingsEnforcementGroupNoEnforcement[] = "no_enforcement"; | 392 const char kSettingsEnforcementGroupNoEnforcement[] = "no_enforcement"; |
393 const char kSettingsEnforcementGroupEnforceAlways[] = "enforce_always"; | 393 const char kSettingsEnforcementGroupEnforceAlways[] = "enforce_always"; |
394 const char kSettingsEnforcementGroupEnforceAlwaysWithExtensions[] = | 394 const char kSettingsEnforcementGroupEnforceAlwaysWithDSE[] = |
395 "enforce_always_with_extensions"; | 395 "enforce_always_with_dse"; |
396 const char kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE[] = | 396 const char kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE[] = |
397 "enforce_always_with_extensions_and_dse"; | 397 "enforce_always_with_extensions_and_dse"; |
398 | 398 |
399 } // namespace internals | 399 } // namespace internals |
400 | 400 |
401 scoped_ptr<PrefService> CreateLocalState( | 401 scoped_ptr<PrefService> CreateLocalState( |
402 const base::FilePath& pref_filename, | 402 const base::FilePath& pref_filename, |
403 base::SequencedTaskRunner* pref_io_task_runner, | 403 base::SequencedTaskRunner* pref_io_task_runner, |
404 policy::PolicyService* policy_service, | 404 policy::PolicyService* policy_service, |
405 const scoped_refptr<PrefRegistry>& pref_registry, | 405 const scoped_refptr<PrefRegistry>& pref_registry, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 481 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
482 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 482 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
483 } | 483 } |
484 | 484 |
485 void RegisterPrefs(PrefRegistrySimple* registry) { | 485 void RegisterPrefs(PrefRegistrySimple* registry) { |
486 ProfilePrefStoreManager::RegisterPrefs(registry); | 486 ProfilePrefStoreManager::RegisterPrefs(registry); |
487 } | 487 } |
488 | 488 |
489 } // namespace chrome_prefs | 489 } // namespace chrome_prefs |
OLD | NEW |