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_command_line_pref_store.h> | 5 #include <chrome/browser/prefs/chrome_command_line_pref_store.h> |
6 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 6 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "components/prefs/pref_store.h" | 48 #include "components/prefs/pref_store.h" |
49 #include "components/prefs/pref_value_store.h" | 49 #include "components/prefs/pref_value_store.h" |
50 #include "components/search_engines/default_search_manager.h" | 50 #include "components/search_engines/default_search_manager.h" |
51 #include "components/search_engines/search_engines_pref_names.h" | 51 #include "components/search_engines/search_engines_pref_names.h" |
52 #include "components/signin/core/common/signin_pref_names.h" | 52 #include "components/signin/core/common/signin_pref_names.h" |
53 #include "components/sync/base/model_type.h" | 53 #include "components/sync/base/model_type.h" |
54 #include "components/sync/base/pref_names.h" | 54 #include "components/sync/base/pref_names.h" |
55 #include "components/sync_preferences/pref_model_associator.h" | 55 #include "components/sync_preferences/pref_model_associator.h" |
56 #include "components/sync_preferences/pref_service_syncable.h" | 56 #include "components/sync_preferences/pref_service_syncable.h" |
57 #include "components/sync_preferences/pref_service_syncable_factory.h" | 57 #include "components/sync_preferences/pref_service_syncable_factory.h" |
58 #include "components/user_prefs/tracked/pref_names.h" | |
59 #include "content/public/browser/browser_context.h" | 58 #include "content/public/browser/browser_context.h" |
60 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
61 #include "extensions/features/features.h" | 60 #include "extensions/features/features.h" |
62 #include "rlz/features/features.h" | 61 #include "rlz/features/features.h" |
| 62 #include "services/preferences/public/cpp/tracked/configuration.h" |
| 63 #include "services/preferences/public/cpp/tracked/pref_names.h" |
63 #include "sql/error_delegate_util.h" | 64 #include "sql/error_delegate_util.h" |
64 #include "ui/base/resource/resource_bundle.h" | 65 #include "ui/base/resource/resource_bundle.h" |
65 | 66 |
66 #if BUILDFLAG(ENABLE_EXTENSIONS) | 67 #if BUILDFLAG(ENABLE_EXTENSIONS) |
67 #include "extensions/browser/pref_names.h" | 68 #include "extensions/browser/pref_names.h" |
68 #endif | 69 #endif |
69 | 70 |
70 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 71 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
71 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" | 72 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
72 #endif | 73 #endif |
73 | 74 |
74 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
75 #include "base/win/win_util.h" | 76 #include "base/win/win_util.h" |
76 #if BUILDFLAG(ENABLE_RLZ) | 77 #if BUILDFLAG(ENABLE_RLZ) |
77 #include "rlz/lib/machine_id.h" | 78 #include "rlz/lib/machine_id.h" |
78 #endif // BUILDFLAG(ENABLE_RLZ) | 79 #endif // BUILDFLAG(ENABLE_RLZ) |
79 #endif // defined(OS_WIN) | 80 #endif // defined(OS_WIN) |
80 | 81 |
81 using content::BrowserContext; | 82 using content::BrowserContext; |
82 using content::BrowserThread; | 83 using content::BrowserThread; |
83 | 84 |
84 using EnforcementLevel = PrefHashFilter::EnforcementLevel; | 85 using EnforcementLevel = |
85 using PrefTrackingStrategy = PrefHashFilter::PrefTrackingStrategy; | 86 prefs::mojom::TrackedPreferenceMetadata::EnforcementLevel; |
86 using ValueType = PrefHashFilter::ValueType; | 87 using PrefTrackingStrategy = |
| 88 prefs::mojom::TrackedPreferenceMetadata::PrefTrackingStrategy; |
| 89 using ValueType = prefs::mojom::TrackedPreferenceMetadata::ValueType; |
87 | 90 |
88 namespace { | 91 namespace { |
89 | 92 |
90 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
91 // Whether we are in testing mode; can be enabled via | 94 // Whether we are in testing mode; can be enabled via |
92 // DisableDomainCheckForTesting(). Forces startup checks to ignore the presence | 95 // DisableDomainCheckForTesting(). Forces startup checks to ignore the presence |
93 // of a domain when determining the active SettingsEnforcement group. | 96 // of a domain when determining the active SettingsEnforcement group. |
94 bool g_disable_domain_check_for_testing = false; | 97 bool g_disable_domain_check_for_testing = false; |
95 #endif // OS_WIN | 98 #endif // OS_WIN |
96 | 99 |
97 // These preferences must be kept in sync with the TrackedPreference enum in | 100 // These preferences must be kept in sync with the TrackedPreference enum in |
98 // tools/metrics/histograms/histograms.xml. To add a new preference, append it | 101 // tools/metrics/histograms/histograms.xml. To add a new preference, append it |
99 // to the array and add a corresponding value to the histogram enum. Each | 102 // to the array and add a corresponding value to the histogram enum. Each |
100 // tracked preference must be given a unique reporting ID. | 103 // tracked preference must be given a unique reporting ID. |
101 // See CleanupDeprecatedTrackedPreferences() in pref_hash_filter.cc to remove a | 104 // See CleanupDeprecatedTrackedPreferences() in pref_hash_filter.cc to remove a |
102 // deprecated tracked preference. | 105 // deprecated tracked preference. |
103 const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = { | 106 const prefs::TrackedPreferenceMetadata kTrackedPrefs[] = { |
104 {0, prefs::kShowHomeButton, EnforcementLevel::ENFORCE_ON_LOAD, | 107 {0, prefs::kShowHomeButton, EnforcementLevel::ENFORCE_ON_LOAD, |
105 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, | 108 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, |
106 {1, prefs::kHomePageIsNewTabPage, EnforcementLevel::ENFORCE_ON_LOAD, | 109 {1, prefs::kHomePageIsNewTabPage, EnforcementLevel::ENFORCE_ON_LOAD, |
107 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, | 110 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, |
108 {2, prefs::kHomePage, EnforcementLevel::ENFORCE_ON_LOAD, | 111 {2, prefs::kHomePage, EnforcementLevel::ENFORCE_ON_LOAD, |
109 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, | 112 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, |
110 {3, prefs::kRestoreOnStartup, EnforcementLevel::ENFORCE_ON_LOAD, | 113 {3, prefs::kRestoreOnStartup, EnforcementLevel::ENFORCE_ON_LOAD, |
111 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, | 114 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, |
112 {4, prefs::kURLsToRestoreOnStartup, EnforcementLevel::ENFORCE_ON_LOAD, | 115 {4, prefs::kURLsToRestoreOnStartup, EnforcementLevel::ENFORCE_ON_LOAD, |
113 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, | 116 PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL}, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 break; | 253 break; |
251 } | 254 } |
252 } | 255 } |
253 } | 256 } |
254 UMA_HISTOGRAM_BOOLEAN("Settings.EnforcementGroupDeterminedFromTrial", | 257 UMA_HISTOGRAM_BOOLEAN("Settings.EnforcementGroupDeterminedFromTrial", |
255 group_determined_from_trial); | 258 group_determined_from_trial); |
256 return enforcement_group; | 259 return enforcement_group; |
257 } | 260 } |
258 | 261 |
259 // Returns the effective preference tracking configuration. | 262 // Returns the effective preference tracking configuration. |
260 std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 263 std::vector<prefs::mojom::TrackedPreferenceMetadataPtr> |
261 GetTrackingConfiguration() { | 264 GetTrackingConfiguration() { |
262 const SettingsEnforcementGroup enforcement_group = | 265 const SettingsEnforcementGroup enforcement_group = |
263 GetSettingsEnforcementGroup(); | 266 GetSettingsEnforcementGroup(); |
264 | 267 |
265 std::vector<PrefHashFilter::TrackedPreferenceMetadata> result; | 268 std::vector<prefs::mojom::TrackedPreferenceMetadataPtr> result; |
266 for (size_t i = 0; i < arraysize(kTrackedPrefs); ++i) { | 269 for (size_t i = 0; i < arraysize(kTrackedPrefs); ++i) { |
267 PrefHashFilter::TrackedPreferenceMetadata data = kTrackedPrefs[i]; | 270 prefs::mojom::TrackedPreferenceMetadataPtr data = |
| 271 prefs::ConstructTrackedMetadata(kTrackedPrefs[i]); |
268 | 272 |
269 if (GROUP_NO_ENFORCEMENT == enforcement_group) { | 273 if (GROUP_NO_ENFORCEMENT == enforcement_group) { |
270 // Remove enforcement for all tracked preferences. | 274 // Remove enforcement for all tracked preferences. |
271 data.enforcement_level = EnforcementLevel::NO_ENFORCEMENT; | 275 data->enforcement_level = EnforcementLevel::NO_ENFORCEMENT; |
272 } | 276 } |
273 | 277 |
274 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_DSE && | 278 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_DSE && |
275 data.name == DefaultSearchManager::kDefaultSearchProviderDataPrefName) { | 279 data->name == |
| 280 DefaultSearchManager::kDefaultSearchProviderDataPrefName) { |
276 // Specifically enable default search settings enforcement. | 281 // Specifically enable default search settings enforcement. |
277 data.enforcement_level = EnforcementLevel::ENFORCE_ON_LOAD; | 282 data->enforcement_level = EnforcementLevel::ENFORCE_ON_LOAD; |
278 } | 283 } |
279 | 284 |
280 #if BUILDFLAG(ENABLE_EXTENSIONS) | 285 #if BUILDFLAG(ENABLE_EXTENSIONS) |
281 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE && | 286 if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE && |
282 data.name == extensions::pref_names::kExtensions) { | 287 data->name == extensions::pref_names::kExtensions) { |
283 // Specifically enable extension settings enforcement. | 288 // Specifically enable extension settings enforcement. |
284 data.enforcement_level = EnforcementLevel::ENFORCE_ON_LOAD; | 289 data->enforcement_level = EnforcementLevel::ENFORCE_ON_LOAD; |
285 } | 290 } |
286 #endif | 291 #endif |
287 | 292 |
288 result.push_back(data); | 293 result.push_back(std::move(data)); |
289 } | 294 } |
290 return result; | 295 return result; |
291 } | 296 } |
292 | 297 |
293 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 298 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
294 void HandleReadError(const base::FilePath& pref_filename, | 299 void HandleReadError(const base::FilePath& pref_filename, |
295 PersistentPrefStore::PrefReadError error) { | 300 PersistentPrefStore::PrefReadError error) { |
296 // Sample the histogram also for the successful case in order to get a | 301 // Sample the histogram also for the successful case in order to get a |
297 // baseline on the success rate in addition to the error distribution. | 302 // baseline on the success rate in addition to the error distribution. |
298 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, | 303 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 483 |
479 void ClearResetTime(Profile* profile) { | 484 void ClearResetTime(Profile* profile) { |
480 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); | 485 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); |
481 } | 486 } |
482 | 487 |
483 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 488 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
484 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 489 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
485 } | 490 } |
486 | 491 |
487 } // namespace chrome_prefs | 492 } // namespace chrome_prefs |
OLD | NEW |