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_SUPERVISED_USERS) | 64 #if defined(ENABLE_SUPERVISED_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) && defined(ENABLE_RLZ) | 68 #if defined(OS_WIN) |
| 69 #include "base/win/win_util.h" |
| 70 #if defined(ENABLE_RLZ) |
69 #include "rlz/lib/machine_id.h" | 71 #include "rlz/lib/machine_id.h" |
70 #endif // defined(ENABLE_RLZ) && defined(OS_WIN) | 72 #endif // defined(ENABLE_RLZ) |
| 73 #endif // defined(OS_WIN) |
71 | 74 |
72 using content::BrowserContext; | 75 using content::BrowserContext; |
73 using content::BrowserThread; | 76 using content::BrowserThread; |
74 | 77 |
75 namespace { | 78 namespace { |
76 | 79 |
| 80 #if defined(OS_WIN) |
| 81 // Whether we are in testing mode; can be enabled via |
| 82 // DisableDomainCheckForTesting(). Forces startup checks to ignore the presence |
| 83 // of a domain when determining the active SettingsEnforcement group. |
| 84 bool g_disable_domain_check_for_testing = false; |
| 85 #endif // OS_WIN |
| 86 |
77 // These preferences must be kept in sync with the TrackedPreference enum in | 87 // These preferences must be kept in sync with the TrackedPreference enum in |
78 // tools/metrics/histograms/histograms.xml. To add a new preference, append it | 88 // tools/metrics/histograms/histograms.xml. To add a new preference, append it |
79 // to the array and add a corresponding value to the histogram enum. Each | 89 // to the array and add a corresponding value to the histogram enum. Each |
80 // tracked preference must be given a unique reporting ID. | 90 // tracked preference must be given a unique reporting ID. |
81 // See CleanupDeprecatedTrackedPreferences() in pref_hash_filter.cc to remove a | 91 // See CleanupDeprecatedTrackedPreferences() in pref_hash_filter.cc to remove a |
82 // deprecated tracked preference. | 92 // deprecated tracked preference. |
83 const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = { | 93 const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = { |
84 { | 94 { |
85 0, prefs::kShowHomeButton, | 95 0, prefs::kShowHomeButton, |
86 PrefHashFilter::ENFORCE_ON_LOAD, | 96 PrefHashFilter::ENFORCE_ON_LOAD, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 GROUP_ENFORCE_ALWAYS, | 251 GROUP_ENFORCE_ALWAYS, |
242 // Also enforce extension default search. | 252 // Also enforce extension default search. |
243 GROUP_ENFORCE_ALWAYS_WITH_DSE, | 253 GROUP_ENFORCE_ALWAYS_WITH_DSE, |
244 // Also enforce extension settings and default search. | 254 // Also enforce extension settings and default search. |
245 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE, | 255 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE, |
246 // The default enforcement group contains all protection features. | 256 // The default enforcement group contains all protection features. |
247 GROUP_ENFORCE_DEFAULT | 257 GROUP_ENFORCE_DEFAULT |
248 }; | 258 }; |
249 | 259 |
250 SettingsEnforcementGroup GetSettingsEnforcementGroup() { | 260 SettingsEnforcementGroup GetSettingsEnforcementGroup() { |
| 261 # if defined(OS_WIN) |
| 262 if (!g_disable_domain_check_for_testing) { |
| 263 static bool first_call = true; |
| 264 static const bool is_enrolled_to_domain = base::win::IsEnrolledToDomain(); |
| 265 if (first_call) { |
| 266 UMA_HISTOGRAM_BOOLEAN("Settings.TrackedPreferencesNoEnforcementOnDomain", |
| 267 is_enrolled_to_domain); |
| 268 first_call = false; |
| 269 } |
| 270 if (is_enrolled_to_domain) |
| 271 return GROUP_NO_ENFORCEMENT; |
| 272 } |
| 273 #endif |
| 274 |
251 struct { | 275 struct { |
252 const char* group_name; | 276 const char* group_name; |
253 SettingsEnforcementGroup group; | 277 SettingsEnforcementGroup group; |
254 } static const kEnforcementLevelMap[] = { | 278 } static const kEnforcementLevelMap[] = { |
255 { chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, | 279 { chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, |
256 GROUP_NO_ENFORCEMENT }, | 280 GROUP_NO_ENFORCEMENT }, |
257 { chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, | 281 { chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, |
258 GROUP_ENFORCE_ALWAYS }, | 282 GROUP_ENFORCE_ALWAYS }, |
259 { chrome_prefs::internals:: | 283 { chrome_prefs::internals:: |
260 kSettingsEnforcementGroupEnforceAlwaysWithDSE, | 284 kSettingsEnforcementGroupEnforceAlwaysWithDSE, |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 const int kVerifyPrefsFileDelaySeconds = 60; | 538 const int kVerifyPrefsFileDelaySeconds = 60; |
515 BrowserThread::GetBlockingPool()->PostDelayedTask( | 539 BrowserThread::GetBlockingPool()->PostDelayedTask( |
516 FROM_HERE, | 540 FROM_HERE, |
517 base::Bind(&VerifyPreferencesFile, | 541 base::Bind(&VerifyPreferencesFile, |
518 ProfilePrefStoreManager::GetPrefFilePathFromProfilePath( | 542 ProfilePrefStoreManager::GetPrefFilePathFromProfilePath( |
519 profile_path)), | 543 profile_path)), |
520 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); | 544 base::TimeDelta::FromSeconds(kVerifyPrefsFileDelaySeconds)); |
521 #endif | 545 #endif |
522 } | 546 } |
523 | 547 |
| 548 void DisableDomainCheckForTesting() { |
| 549 #if defined(OS_WIN) |
| 550 g_disable_domain_check_for_testing = true; |
| 551 #endif // OS_WIN |
| 552 } |
| 553 |
524 bool InitializePrefsFromMasterPrefs( | 554 bool InitializePrefsFromMasterPrefs( |
525 const base::FilePath& profile_path, | 555 const base::FilePath& profile_path, |
526 const base::DictionaryValue& master_prefs) { | 556 const base::DictionaryValue& master_prefs) { |
527 return CreateProfilePrefStoreManager(profile_path) | 557 return CreateProfilePrefStoreManager(profile_path) |
528 ->InitializePrefsFromMasterPrefs(master_prefs); | 558 ->InitializePrefsFromMasterPrefs(master_prefs); |
529 } | 559 } |
530 | 560 |
531 base::Time GetResetTime(Profile* profile) { | 561 base::Time GetResetTime(Profile* profile) { |
532 return ProfilePrefStoreManager::GetResetTime(profile->GetPrefs()); | 562 return ProfilePrefStoreManager::GetResetTime(profile->GetPrefs()); |
533 } | 563 } |
534 | 564 |
535 void ClearResetTime(Profile* profile) { | 565 void ClearResetTime(Profile* profile) { |
536 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); | 566 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); |
537 } | 567 } |
538 | 568 |
539 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 569 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
540 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 570 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
541 } | 571 } |
542 | 572 |
543 void RegisterPrefs(PrefRegistrySimple* registry) { | 573 void RegisterPrefs(PrefRegistrySimple* registry) { |
544 ProfilePrefStoreManager::RegisterPrefs(registry); | 574 ProfilePrefStoreManager::RegisterPrefs(registry); |
545 } | 575 } |
546 | 576 |
547 } // namespace chrome_prefs | 577 } // namespace chrome_prefs |
OLD | NEW |