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