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_TRACKED_SPLIT_PREFERENCE_H_ | |
6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_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 TrackedSplitPreference must be tracking a dictionary pref. Each top-level | |
25 // entry in its dictionary is tracked and enforced independently. An optional | |
26 // delegate is notified of the status of the preference during enforcement. | |
27 // Note: preferences using this strategy must be kept in sync with | |
28 // TrackedSplitPreferences in histograms.xml. | |
29 class TrackedSplitPreference : public TrackedPreference { | |
30 public: | |
31 // Constructs a TrackedSplitPreference. |pref_path| must be a dictionary pref. | |
32 TrackedSplitPreference( | |
33 const std::string& pref_path, | |
34 size_t reporting_id, | |
35 size_t reporting_ids_count, | |
36 PrefHashFilter::EnforcementLevel enforcement_level, | |
37 PrefHashFilter::ValueType value_type, | |
38 prefs::mojom::TrackedPreferenceValidationDelegate* delegate); | |
39 | |
40 // TrackedPreference implementation. | |
41 TrackedPreferenceType GetType() const override; | |
42 void OnNewValue(const base::Value* value, | |
43 PrefHashStoreTransaction* transaction) const override; | |
44 bool EnforceAndReport( | |
45 base::DictionaryValue* pref_store_contents, | |
46 PrefHashStoreTransaction* transaction, | |
47 PrefHashStoreTransaction* external_validation_transaction) const override; | |
48 | |
49 private: | |
50 const std::string pref_path_; | |
51 const TrackedPreferenceHelper helper_; | |
52 prefs::mojom::TrackedPreferenceValidationDelegate* delegate_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(TrackedSplitPreference); | |
55 }; | |
56 | |
57 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ | |
OLD | NEW |