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 #include "components/user_prefs/tracked/tracked_split_preference.h" | 5 #include "components/user_prefs/tracked/tracked_split_preference.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" | 11 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
12 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h
" | 12 #include "services/preferences/public/interfaces/tracked_preference_validation_d
elegate.mojom.h" |
13 | 13 |
14 TrackedSplitPreference::TrackedSplitPreference( | 14 TrackedSplitPreference::TrackedSplitPreference( |
15 const std::string& pref_path, | 15 const std::string& pref_path, |
16 size_t reporting_id, | 16 size_t reporting_id, |
17 size_t reporting_ids_count, | 17 size_t reporting_ids_count, |
18 PrefHashFilter::EnforcementLevel enforcement_level, | 18 PrefHashFilter::EnforcementLevel enforcement_level, |
19 PrefHashFilter::ValueType value_type, | 19 PrefHashFilter::ValueType value_type, |
20 TrackedPreferenceValidationDelegate* delegate) | 20 prefs::mojom::TrackedPreferenceValidationDelegate* delegate) |
21 : pref_path_(pref_path), | 21 : pref_path_(pref_path), |
22 helper_(pref_path, | 22 helper_(pref_path, |
23 reporting_id, | 23 reporting_id, |
24 reporting_ids_count, | 24 reporting_ids_count, |
25 enforcement_level, | 25 enforcement_level, |
26 value_type), | 26 value_type), |
27 delegate_(delegate) { | 27 delegate_(delegate) {} |
28 } | |
29 | 28 |
30 TrackedPreferenceType TrackedSplitPreference::GetType() const { | 29 TrackedPreferenceType TrackedSplitPreference::GetType() const { |
31 return TrackedPreferenceType::SPLIT; | 30 return TrackedPreferenceType::SPLIT; |
32 } | 31 } |
33 | 32 |
34 void TrackedSplitPreference::OnNewValue( | 33 void TrackedSplitPreference::OnNewValue( |
35 const base::Value* value, | 34 const base::Value* value, |
36 PrefHashStoreTransaction* transaction) const { | 35 PrefHashStoreTransaction* transaction) const { |
37 const base::DictionaryValue* dict_value = NULL; | 36 const base::DictionaryValue* dict_value = NULL; |
38 if (value && !value->GetAsDictionary(&dict_value)) { | 37 if (value && !value->GetAsDictionary(&dict_value)) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 external_validation_value_state = | 69 external_validation_value_state = |
71 external_validation_transaction->CheckSplitValue( | 70 external_validation_transaction->CheckSplitValue( |
72 pref_path_, dict_value, &external_validation_invalid_keys); | 71 pref_path_, dict_value, &external_validation_invalid_keys); |
73 helper_.ReportValidationResult( | 72 helper_.ReportValidationResult( |
74 external_validation_value_state, | 73 external_validation_value_state, |
75 external_validation_transaction->GetStoreUMASuffix()); | 74 external_validation_transaction->GetStoreUMASuffix()); |
76 } | 75 } |
77 | 76 |
78 if (delegate_) { | 77 if (delegate_) { |
79 delegate_->OnSplitPreferenceValidation( | 78 delegate_->OnSplitPreferenceValidation( |
80 pref_path_, dict_value, invalid_keys, external_validation_invalid_keys, | 79 pref_path_, invalid_keys, external_validation_invalid_keys, value_state, |
81 value_state, external_validation_value_state, helper_.IsPersonal()); | 80 external_validation_value_state, helper_.IsPersonal()); |
82 } | 81 } |
83 TrackedPreferenceHelper::ResetAction reset_action = | 82 TrackedPreferenceHelper::ResetAction reset_action = |
84 helper_.GetAction(value_state); | 83 helper_.GetAction(value_state); |
85 helper_.ReportAction(reset_action); | 84 helper_.ReportAction(reset_action); |
86 | 85 |
87 bool was_reset = false; | 86 bool was_reset = false; |
88 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 87 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
89 if (value_state == PrefHashStoreTransaction::CHANGED) { | 88 if (value_state == PrefHashStoreTransaction::CHANGED) { |
90 DCHECK(!invalid_keys.empty()); | 89 DCHECK(!invalid_keys.empty()); |
91 | 90 |
(...skipping 20 matching lines...) Expand all Loading... |
112 (was_reset || | 111 (was_reset || |
113 external_validation_value_state != | 112 external_validation_value_state != |
114 PrefHashStoreTransaction::UNCHANGED)) { | 113 PrefHashStoreTransaction::UNCHANGED)) { |
115 const base::DictionaryValue* new_dict_value = nullptr; | 114 const base::DictionaryValue* new_dict_value = nullptr; |
116 pref_store_contents->GetDictionary(pref_path_, &new_dict_value); | 115 pref_store_contents->GetDictionary(pref_path_, &new_dict_value); |
117 external_validation_transaction->StoreSplitHash(pref_path_, new_dict_value); | 116 external_validation_transaction->StoreSplitHash(pref_path_, new_dict_value); |
118 } | 117 } |
119 | 118 |
120 return was_reset; | 119 return was_reset; |
121 } | 120 } |
OLD | NEW |