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