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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 #endif | 58 #endif |
59 | 59 |
60 #if defined(ENABLE_EXTENSIONS) | 60 #if defined(ENABLE_EXTENSIONS) |
61 #include "extensions/browser/pref_names.h" | 61 #include "extensions/browser/pref_names.h" |
62 #endif | 62 #endif |
63 | 63 |
64 #if defined(ENABLE_MANAGED_USERS) | 64 #if defined(ENABLE_MANAGED_USERS) |
65 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" | 65 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
66 #endif | 66 #endif |
67 | 67 |
68 #if defined(OS_WIN) | 68 #if defined(OS_WIN) && defined(ENABLE_RLZ) |
69 #include "base/win/win_util.h" | |
70 #if defined(ENABLE_RLZ) | |
71 #include "rlz/lib/machine_id.h" | 69 #include "rlz/lib/machine_id.h" |
72 #endif // defined(ENABLE_RLZ) | 70 #endif // defined(ENABLE_RLZ) && defined(OS_WIN) |
73 #endif // defined(OS_WIN) | |
74 | 71 |
75 using content::BrowserContext; | 72 using content::BrowserContext; |
76 using content::BrowserThread; | 73 using content::BrowserThread; |
77 | 74 |
78 namespace { | 75 namespace { |
79 | 76 |
80 // Whether we are in testing mode; can be enabled via | |
81 // DisableDelaysAndDomainCheckForTesting(). Forces startup checks to occur | |
82 // with no delay and ignores the presence of a domain when determining the | |
83 // active SettingsEnforcement group. | |
84 bool g_disable_delays_and_domain_check_for_testing = false; | |
85 | |
86 // These preferences must be kept in sync with the TrackedPreference enum in | 77 // These preferences must be kept in sync with the TrackedPreference enum in |
87 // tools/metrics/histograms/histograms.xml. To add a new preference, append it | 78 // tools/metrics/histograms/histograms.xml. To add a new preference, append it |
88 // to the array and add a corresponding value to the histogram enum. Each | 79 // to the array and add a corresponding value to the histogram enum. Each |
89 // tracked preference must be given a unique reporting ID. | 80 // tracked preference must be given a unique reporting ID. |
90 // See CleanupDeprecatedTrackedPreferences() in pref_hash_filter.cc to remove a | 81 // See CleanupDeprecatedTrackedPreferences() in pref_hash_filter.cc to remove a |
91 // deprecated tracked preference. | 82 // deprecated tracked preference. |
92 const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = { | 83 const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = { |
93 { | 84 { |
94 0, prefs::kShowHomeButton, | 85 0, prefs::kShowHomeButton, |
95 PrefHashFilter::ENFORCE_ON_LOAD, | 86 PrefHashFilter::ENFORCE_ON_LOAD, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 GROUP_ENFORCE_ALWAYS, | 199 GROUP_ENFORCE_ALWAYS, |
209 // Also enforce extension default search. | 200 // Also enforce extension default search. |
210 GROUP_ENFORCE_ALWAYS_WITH_DSE, | 201 GROUP_ENFORCE_ALWAYS_WITH_DSE, |
211 // Also enforce extension settings and default search. | 202 // Also enforce extension settings and default search. |
212 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE, | 203 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE, |
213 // The default enforcement group contains all protection features. | 204 // The default enforcement group contains all protection features. |
214 GROUP_ENFORCE_DEFAULT | 205 GROUP_ENFORCE_DEFAULT |
215 }; | 206 }; |
216 | 207 |
217 SettingsEnforcementGroup GetSettingsEnforcementGroup() { | 208 SettingsEnforcementGroup GetSettingsEnforcementGroup() { |
218 # if defined(OS_WIN) | |
219 if (!g_disable_delays_and_domain_check_for_testing) { | |
220 static bool first_call = true; | |
221 static const bool is_enrolled_to_domain = base::win::IsEnrolledToDomain(); | |
222 if (first_call) { | |
223 UMA_HISTOGRAM_BOOLEAN("Settings.TrackedPreferencesNoEnforcementOnDomain", | |
224 is_enrolled_to_domain); | |
225 first_call = false; | |
226 } | |
227 if (is_enrolled_to_domain) | |
228 return GROUP_NO_ENFORCEMENT; | |
229 } | |
230 #endif | |
231 | |
232 struct { | 209 struct { |
233 const char* group_name; | 210 const char* group_name; |
234 SettingsEnforcementGroup group; | 211 SettingsEnforcementGroup group; |
235 } static const kEnforcementLevelMap[] = { | 212 } static const kEnforcementLevelMap[] = { |
236 { chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, | 213 { chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, |
237 GROUP_NO_ENFORCEMENT }, | 214 GROUP_NO_ENFORCEMENT }, |
238 { chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, | 215 { chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, |
239 GROUP_ENFORCE_ALWAYS }, | 216 GROUP_ENFORCE_ALWAYS }, |
240 { chrome_prefs::internals:: | 217 { chrome_prefs::internals:: |
241 kSettingsEnforcementGroupEnforceAlwaysWithDSE, | 218 kSettingsEnforcementGroupEnforceAlwaysWithDSE, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 | 476 |
500 void SchedulePrefsFilePathVerification(const base::FilePath& profile_path) { | 477 void SchedulePrefsFilePathVerification(const base::FilePath& profile_path) { |
501 #if defined(OS_WIN) | 478 #if defined(OS_WIN) |
502 // Only do prefs file verification on Windows. | 479 // Only do prefs file verification on Windows. |
503 const int kVerifyPrefsFileDelaySeconds = 60; | 480 const int kVerifyPrefsFileDelaySeconds = 60; |
504 BrowserThread::GetBlockingPool()->PostDelayedTask( | 481 BrowserThread::GetBlockingPool()->PostDelayedTask( |
505 FROM_HERE, | 482 FROM_HERE, |
506 base::Bind(&VerifyPreferencesFile, | 483 base::Bind(&VerifyPreferencesFile, |
507 ProfilePrefStoreManager::GetPrefFilePathFromProfilePath( | 484 ProfilePrefStoreManager::GetPrefFilePathFromProfilePath( |
508 profile_path)), | 485 profile_path)), |
509 base::TimeDelta::FromSeconds(g_disable_delays_and_domain_check_for_testing | 486 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); |
robertshield
2014/10/02 21:40:43
do you not still desire to be able to disable the
gab
2014/10/02 21:46:00
It wasn't used (i.e. nothing tests this -- removin
robertshield
2014/10/02 21:53:03
Not overly, no. I think this CL is fine as is.
| |
510 ? 0 | |
511 : kVerifyPrefsFileDelaySeconds)); | |
512 #endif | 487 #endif |
513 } | 488 } |
514 | 489 |
515 void DisableDelaysAndDomainCheckForTesting() { | |
516 g_disable_delays_and_domain_check_for_testing = true; | |
517 } | |
518 | |
519 bool InitializePrefsFromMasterPrefs( | 490 bool InitializePrefsFromMasterPrefs( |
520 const base::FilePath& profile_path, | 491 const base::FilePath& profile_path, |
521 const base::DictionaryValue& master_prefs) { | 492 const base::DictionaryValue& master_prefs) { |
522 return CreateProfilePrefStoreManager(profile_path) | 493 return CreateProfilePrefStoreManager(profile_path) |
523 ->InitializePrefsFromMasterPrefs(master_prefs); | 494 ->InitializePrefsFromMasterPrefs(master_prefs); |
524 } | 495 } |
525 | 496 |
526 base::Time GetResetTime(Profile* profile) { | 497 base::Time GetResetTime(Profile* profile) { |
527 return ProfilePrefStoreManager::GetResetTime(profile->GetPrefs()); | 498 return ProfilePrefStoreManager::GetResetTime(profile->GetPrefs()); |
528 } | 499 } |
529 | 500 |
530 void ClearResetTime(Profile* profile) { | 501 void ClearResetTime(Profile* profile) { |
531 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); | 502 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); |
532 } | 503 } |
533 | 504 |
534 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 505 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
535 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 506 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
536 } | 507 } |
537 | 508 |
538 void RegisterPrefs(PrefRegistrySimple* registry) { | 509 void RegisterPrefs(PrefRegistrySimple* registry) { |
539 ProfilePrefStoreManager::RegisterPrefs(registry); | 510 ProfilePrefStoreManager::RegisterPrefs(registry); |
540 } | 511 } |
541 | 512 |
542 } // namespace chrome_prefs | 513 } // namespace chrome_prefs |
OLD | NEW |