| 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 CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ |
| 6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | 6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/prefs/tracked/pref_hash_filter.h" | 11 #include "components/user_prefs/tracked/pref_hash_filter.h" |
| 12 #include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" | 12 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
| 13 | 13 |
| 14 // A TrackedPreferenceHelper is a helper class for TrackedPreference which | 14 // A TrackedPreferenceHelper is a helper class for TrackedPreference which |
| 15 // handles decision making and reporting for TrackedPreference's | 15 // handles decision making and reporting for TrackedPreference's |
| 16 // implementations. | 16 // implementations. |
| 17 class TrackedPreferenceHelper { | 17 class TrackedPreferenceHelper { |
| 18 public: | 18 public: |
| 19 enum ResetAction { | 19 enum ResetAction { |
| 20 DONT_RESET, | 20 DONT_RESET, |
| 21 // WANTED_RESET is reported when DO_RESET would have been reported but the | 21 // WANTED_RESET is reported when DO_RESET would have been reported but the |
| 22 // current |enforcement_level| doesn't allow a reset for the detected state. | 22 // current |enforcement_level| doesn't allow a reset for the detected state. |
| 23 WANTED_RESET, | 23 WANTED_RESET, |
| 24 DO_RESET, | 24 DO_RESET, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 TrackedPreferenceHelper(const std::string& pref_path, | 27 TrackedPreferenceHelper(const std::string& pref_path, |
| 28 size_t reporting_id, | 28 size_t reporting_id, |
| 29 size_t reporting_ids_count, | 29 size_t reporting_ids_count, |
| 30 PrefHashFilter::EnforcementLevel enforcement_level, | 30 PrefHashFilter::EnforcementLevel enforcement_level, |
| 31 PrefHashFilter::ValueType value_type); | 31 PrefHashFilter::ValueType value_type); |
| 32 | 32 |
| 33 // Returns a ResetAction stating whether a reset is desired (DO_RESET) or not | 33 // Returns a ResetAction stating whether a reset is desired (DO_RESET) or not |
| 34 // (DONT_RESET) based on observing |value_state|. Can also return WANTED_RESET | 34 // (DONT_RESET) based on observing |value_state|. Can also return WANTED_RESET |
| 35 // if a reset would have been desired but the current |enforcement_level| | 35 // if a reset would have been desired but the current |enforcement_level| |
| 36 // doesn't allow it. | 36 // doesn't allow it. |
| 37 ResetAction GetAction( | 37 ResetAction GetAction(PrefHashStoreTransaction::ValueState value_state) const; |
| 38 PrefHashStoreTransaction::ValueState value_state) const; | |
| 39 | 38 |
| 40 // Returns true if the preference value may contain personal information. | 39 // Returns true if the preference value may contain personal information. |
| 41 bool IsPersonal() const; | 40 bool IsPersonal() const; |
| 42 | 41 |
| 43 // Reports |value_state| via UMA under |reporting_id_|. | 42 // Reports |value_state| via UMA under |reporting_id_|. |
| 44 void ReportValidationResult( | 43 void ReportValidationResult( |
| 45 PrefHashStoreTransaction::ValueState value_state) const; | 44 PrefHashStoreTransaction::ValueState value_state) const; |
| 46 | 45 |
| 47 // Reports |reset_action| via UMA under |reporting_id_|. | 46 // Reports |reset_action| via UMA under |reporting_id_|. |
| 48 void ReportAction(ResetAction reset_action) const; | 47 void ReportAction(ResetAction reset_action) const; |
| 49 | 48 |
| 50 // Reports, via UMA, the |count| of split preference entries that were | 49 // Reports, via UMA, the |count| of split preference entries that were |
| 51 // considered invalid in a CHANGED event. | 50 // considered invalid in a CHANGED event. |
| 52 void ReportSplitPreferenceChangedCount(size_t count) const; | 51 void ReportSplitPreferenceChangedCount(size_t count) const; |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 const std::string pref_path_; | 54 const std::string pref_path_; |
| 56 | 55 |
| 57 const size_t reporting_id_; | 56 const size_t reporting_id_; |
| 58 const size_t reporting_ids_count_; | 57 const size_t reporting_ids_count_; |
| 59 | 58 |
| 60 // Deny setting changes and hash seeding/migration. | 59 // Deny setting changes and hash seeding/migration. |
| 61 const bool enforce_; | 60 const bool enforce_; |
| 62 | 61 |
| 63 const bool personal_; | 62 const bool personal_; |
| 64 | 63 |
| 65 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); | 64 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 #endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | 67 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ |
| OLD | NEW |