OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ATOMIC_PREFERENCE_H_ | 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ |
6 #define COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ | 6 #define COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "components/user_prefs/tracked/pref_hash_filter.h" | 14 #include "components/user_prefs/tracked/pref_hash_filter.h" |
15 #include "components/user_prefs/tracked/tracked_preference.h" | 15 #include "components/user_prefs/tracked/tracked_preference.h" |
16 #include "components/user_prefs/tracked/tracked_preference_helper.h" | 16 #include "components/user_prefs/tracked/tracked_preference_helper.h" |
17 | 17 |
| 18 namespace prefs { |
| 19 namespace mojom { |
18 class TrackedPreferenceValidationDelegate; | 20 class TrackedPreferenceValidationDelegate; |
| 21 } |
| 22 } |
19 | 23 |
20 // A TrackedAtomicPreference is tracked as a whole. A hash is stored for its | 24 // A TrackedAtomicPreference is tracked as a whole. A hash is stored for its |
21 // entire value and it is entirely reset on mismatch. An optional delegate is | 25 // entire value and it is entirely reset on mismatch. An optional delegate is |
22 // notified of the status of the preference during enforcement. | 26 // notified of the status of the preference during enforcement. |
23 class TrackedAtomicPreference : public TrackedPreference { | 27 class TrackedAtomicPreference : public TrackedPreference { |
24 public: | 28 public: |
25 TrackedAtomicPreference(const std::string& pref_path, | 29 TrackedAtomicPreference( |
26 size_t reporting_id, | 30 const std::string& pref_path, |
27 size_t reporting_ids_count, | 31 size_t reporting_id, |
28 PrefHashFilter::EnforcementLevel enforcement_level, | 32 size_t reporting_ids_count, |
29 PrefHashFilter::ValueType value_type, | 33 PrefHashFilter::EnforcementLevel enforcement_level, |
30 TrackedPreferenceValidationDelegate* delegate); | 34 PrefHashFilter::ValueType value_type, |
| 35 prefs::mojom::TrackedPreferenceValidationDelegate* delegate); |
31 | 36 |
32 // TrackedPreference implementation. | 37 // TrackedPreference implementation. |
33 TrackedPreferenceType GetType() const override; | 38 TrackedPreferenceType GetType() const override; |
34 void OnNewValue(const base::Value* value, | 39 void OnNewValue(const base::Value* value, |
35 PrefHashStoreTransaction* transaction) const override; | 40 PrefHashStoreTransaction* transaction) const override; |
36 bool EnforceAndReport( | 41 bool EnforceAndReport( |
37 base::DictionaryValue* pref_store_contents, | 42 base::DictionaryValue* pref_store_contents, |
38 PrefHashStoreTransaction* transaction, | 43 PrefHashStoreTransaction* transaction, |
39 PrefHashStoreTransaction* external_validation_transaction) const override; | 44 PrefHashStoreTransaction* external_validation_transaction) const override; |
40 | 45 |
41 private: | 46 private: |
42 const std::string pref_path_; | 47 const std::string pref_path_; |
43 const TrackedPreferenceHelper helper_; | 48 const TrackedPreferenceHelper helper_; |
44 TrackedPreferenceValidationDelegate* delegate_; | 49 prefs::mojom::TrackedPreferenceValidationDelegate* delegate_; |
45 | 50 |
46 DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference); | 51 DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference); |
47 }; | 52 }; |
48 | 53 |
49 #endif // COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ | 54 #endif // COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ |
OLD | NEW |