| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ | 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ |
| 6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ | 6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <unordered_map> | 13 #include <unordered_map> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/optional.h" | 20 #include "base/optional.h" |
| 21 #include "components/user_prefs/tracked/hash_store_contents.h" | 21 #include "components/user_prefs/tracked/hash_store_contents.h" |
| 22 #include "components/user_prefs/tracked/interceptable_pref_filter.h" | 22 #include "components/user_prefs/tracked/interceptable_pref_filter.h" |
| 23 #include "components/user_prefs/tracked/tracked_preference.h" | 23 #include "components/user_prefs/tracked/tracked_preference.h" |
| 24 #include "services/preferences/public/interfaces/preferences.mojom-shared.h" |
| 24 | 25 |
| 25 class PrefHashStore; | 26 class PrefHashStore; |
| 26 class PrefService; | 27 class PrefService; |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| 29 class DictionaryValue; | 30 class DictionaryValue; |
| 30 class Time; | 31 class Time; |
| 31 } // namespace base | 32 } // namespace base |
| 32 | 33 |
| 33 namespace prefs { | 34 namespace prefs { |
| 34 namespace mojom { | 35 namespace mojom { |
| 35 class TrackedPreferenceValidationDelegate; | 36 class TrackedPreferenceValidationDelegate; |
| 36 } | 37 } |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace user_prefs { | 40 namespace user_prefs { |
| 40 class PrefRegistrySyncable; | 41 class PrefRegistrySyncable; |
| 41 } // namespace user_prefs | 42 } // namespace user_prefs |
| 42 | 43 |
| 43 // Intercepts preference values as they are loaded from disk and verifies them | 44 // Intercepts preference values as they are loaded from disk and verifies them |
| 44 // using a PrefHashStore. Keeps the PrefHashStore contents up to date as values | 45 // using a PrefHashStore. Keeps the PrefHashStore contents up to date as values |
| 45 // are changed. | 46 // are changed. |
| 46 class PrefHashFilter : public InterceptablePrefFilter { | 47 class PrefHashFilter : public InterceptablePrefFilter { |
| 47 public: | 48 public: |
| 48 enum EnforcementLevel { NO_ENFORCEMENT, ENFORCE_ON_LOAD }; | 49 using EnforcementLevel = |
| 49 | 50 prefs::mojom::TrackedPreferenceMetadata_EnforcementLevel; |
| 50 enum PrefTrackingStrategy { | 51 using PrefTrackingStrategy = |
| 51 // Atomic preferences are tracked as a whole. | 52 prefs::mojom::TrackedPreferenceMetadata_PrefTrackingStrategy; |
| 52 TRACKING_STRATEGY_ATOMIC, | 53 using ValueType = prefs::mojom::TrackedPreferenceMetadata_ValueType; |
| 53 // Split preferences are dictionaries for which each top-level entry is | |
| 54 // tracked independently. Note: preferences using this strategy must be kept | |
| 55 // in sync with TrackedSplitPreferences in histograms.xml. | |
| 56 TRACKING_STRATEGY_SPLIT, | |
| 57 }; | |
| 58 | |
| 59 enum ValueType { | |
| 60 VALUE_IMPERSONAL, | |
| 61 // The preference value may contain personal information. | |
| 62 VALUE_PERSONAL, | |
| 63 }; | |
| 64 | 54 |
| 65 struct TrackedPreferenceMetadata { | 55 struct TrackedPreferenceMetadata { |
| 66 size_t reporting_id; | 56 size_t reporting_id; |
| 67 const char* name; | 57 const char* name; |
| 68 EnforcementLevel enforcement_level; | 58 EnforcementLevel enforcement_level; |
| 69 PrefTrackingStrategy strategy; | 59 PrefTrackingStrategy strategy; |
| 70 ValueType value_type; | 60 ValueType value_type; |
| 71 }; | 61 }; |
| 72 | 62 |
| 73 using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>, | 63 using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 using ChangedPathsMap = std::map<std::string, const TrackedPreference*>; | 147 using ChangedPathsMap = std::map<std::string, const TrackedPreference*>; |
| 158 | 148 |
| 159 std::unique_ptr<PrefHashStore> pref_hash_store_; | 149 std::unique_ptr<PrefHashStore> pref_hash_store_; |
| 160 | 150 |
| 161 // A store and contents on which to perform extra validations without | 151 // A store and contents on which to perform extra validations without |
| 162 // triggering resets. | 152 // triggering resets. |
| 163 // Will be null if the platform does not support external validation. | 153 // Will be null if the platform does not support external validation. |
| 164 const base::Optional<StoreContentsPair> external_validation_hash_store_pair_; | 154 const base::Optional<StoreContentsPair> external_validation_hash_store_pair_; |
| 165 | 155 |
| 166 // Invoked if a reset occurs in a call to FilterOnLoad. | 156 // Invoked if a reset occurs in a call to FilterOnLoad. |
| 167 const base::Closure on_reset_on_load_; | 157 base::Closure on_reset_on_load_; |
| 168 | 158 |
| 169 TrackedPreferencesMap tracked_paths_; | 159 TrackedPreferencesMap tracked_paths_; |
| 170 | 160 |
| 171 // The set of all paths whose value has changed since the last call to | 161 // The set of all paths whose value has changed since the last call to |
| 172 // FilterSerializeData. | 162 // FilterSerializeData. |
| 173 ChangedPathsMap changed_paths_; | 163 ChangedPathsMap changed_paths_; |
| 174 | 164 |
| 175 // Whether to report the validity of the super MAC at load time (via UMA). | 165 // Whether to report the validity of the super MAC at load time (via UMA). |
| 176 bool report_super_mac_validity_; | 166 bool report_super_mac_validity_; |
| 177 | 167 |
| 178 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); | 168 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); |
| 179 }; | 169 }; |
| 180 | 170 |
| 181 #endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_FILTER_H_ | 171 #endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_FILTER_H_ |
| OLD | NEW |