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.
5 #ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_
6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "components/user_prefs/tracked/pref_hash_filter.h"
13 #include "components/user_prefs/tracked/tracked_preference.h"
14 #include "components/user_prefs/tracked/tracked_preference_helper.h"
16 class TrackedPreferenceValidationDelegate
;
18 // A TrackedSplitPreference must be tracking a dictionary pref. Each top-level
19 // entry in its dictionary is tracked and enforced independently. An optional
20 // delegate is notified of the status of the preference during enforcement.
21 // Note: preferences using this strategy must be kept in sync with
22 // TrackedSplitPreferences in histograms.xml.
23 class TrackedSplitPreference
: public TrackedPreference
{
25 // Constructs a TrackedSplitPreference. |pref_path| must be a dictionary pref.
26 TrackedSplitPreference(const std::string
& pref_path
,
28 size_t reporting_ids_count
,
29 PrefHashFilter::EnforcementLevel enforcement_level
,
30 PrefHashFilter::ValueType value_type
,
31 TrackedPreferenceValidationDelegate
* delegate
);
33 // TrackedPreference implementation.
34 void OnNewValue(const base::Value
* value
,
35 PrefHashStoreTransaction
* transaction
) const override
;
36 bool EnforceAndReport(base::DictionaryValue
* pref_store_contents
,
37 PrefHashStoreTransaction
* transaction
) const override
;
40 const std::string pref_path_
;
41 const TrackedPreferenceHelper helper_
;
42 TrackedPreferenceValidationDelegate
* delegate_
;
44 DISALLOW_COPY_AND_ASSIGN(TrackedSplitPreference
);
47 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_