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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 std::vector<std::string> invalid_keys; | 57 std::vector<std::string> invalid_keys; |
58 PrefHashStoreTransaction::ValueState value_state = | 58 PrefHashStoreTransaction::ValueState value_state = |
59 transaction->CheckSplitValue(pref_path_, dict_value, &invalid_keys); | 59 transaction->CheckSplitValue(pref_path_, dict_value, &invalid_keys); |
60 | 60 |
61 if (value_state == PrefHashStoreTransaction::CHANGED) | 61 if (value_state == PrefHashStoreTransaction::CHANGED) |
62 helper_.ReportSplitPreferenceChangedCount(invalid_keys.size()); | 62 helper_.ReportSplitPreferenceChangedCount(invalid_keys.size()); |
63 | 63 |
64 helper_.ReportValidationResult(value_state, transaction->GetStoreUMASuffix()); | 64 helper_.ReportValidationResult(value_state, transaction->GetStoreUMASuffix()); |
65 | 65 |
66 PrefHashStoreTransaction::ValueState external_validation_value_state = | 66 PrefHashStoreTransaction::ValueState external_validation_value_state = |
67 PrefHashStoreTransaction::UNCHANGED; | 67 PrefHashStoreTransaction::UNSUPPORTED; |
| 68 std::vector<std::string> external_validation_invalid_keys; |
68 if (external_validation_transaction) { | 69 if (external_validation_transaction) { |
69 std::vector<std::string> invalid_external_validation_keys; | |
70 external_validation_value_state = | 70 external_validation_value_state = |
71 external_validation_transaction->CheckSplitValue( | 71 external_validation_transaction->CheckSplitValue( |
72 pref_path_, dict_value, &invalid_external_validation_keys); | 72 pref_path_, dict_value, &external_validation_invalid_keys); |
73 helper_.ReportValidationResult( | 73 helper_.ReportValidationResult( |
74 external_validation_value_state, | 74 external_validation_value_state, |
75 external_validation_transaction->GetStoreUMASuffix()); | 75 external_validation_transaction->GetStoreUMASuffix()); |
76 | |
77 // TODO(proberge): Call delegate_->OnSplitPreferenceValidation. | |
78 } | 76 } |
79 | 77 |
80 if (delegate_) { | 78 if (delegate_) { |
81 delegate_->OnSplitPreferenceValidation(pref_path_, dict_value, invalid_keys, | 79 delegate_->OnSplitPreferenceValidation( |
82 value_state, helper_.IsPersonal()); | 80 pref_path_, dict_value, invalid_keys, external_validation_invalid_keys, |
| 81 value_state, external_validation_value_state, helper_.IsPersonal()); |
83 } | 82 } |
84 TrackedPreferenceHelper::ResetAction reset_action = | 83 TrackedPreferenceHelper::ResetAction reset_action = |
85 helper_.GetAction(value_state); | 84 helper_.GetAction(value_state); |
86 helper_.ReportAction(reset_action); | 85 helper_.ReportAction(reset_action); |
87 | 86 |
88 bool was_reset = false; | 87 bool was_reset = false; |
89 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 88 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
90 if (value_state == PrefHashStoreTransaction::CHANGED) { | 89 if (value_state == PrefHashStoreTransaction::CHANGED) { |
91 DCHECK(!invalid_keys.empty()); | 90 DCHECK(!invalid_keys.empty()); |
92 | 91 |
(...skipping 20 matching lines...) Expand all Loading... |
113 (was_reset || | 112 (was_reset || |
114 external_validation_value_state != | 113 external_validation_value_state != |
115 PrefHashStoreTransaction::UNCHANGED)) { | 114 PrefHashStoreTransaction::UNCHANGED)) { |
116 const base::DictionaryValue* new_dict_value = nullptr; | 115 const base::DictionaryValue* new_dict_value = nullptr; |
117 pref_store_contents->GetDictionary(pref_path_, &new_dict_value); | 116 pref_store_contents->GetDictionary(pref_path_, &new_dict_value); |
118 external_validation_transaction->StoreSplitHash(pref_path_, new_dict_value); | 117 external_validation_transaction->StoreSplitHash(pref_path_, new_dict_value); |
119 } | 118 } |
120 | 119 |
121 return was_reset; | 120 return was_reset; |
122 } | 121 } |
OLD | NEW |