| 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::UNSUPPORTED; | 67 PrefHashStoreTransaction::UNCHANGED; |
| 68 if (external_validation_transaction) { | 68 if (external_validation_transaction) { |
| 69 std::vector<std::string> invalid_external_validation_keys; | 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, &invalid_external_validation_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. |
| 76 } | 78 } |
| 77 | 79 |
| 78 if (delegate_) { | 80 if (delegate_) { |
| 79 delegate_->OnSplitPreferenceValidation( | 81 delegate_->OnSplitPreferenceValidation(pref_path_, dict_value, invalid_keys, |
| 80 pref_path_, dict_value, invalid_keys, value_state, | 82 value_state, helper_.IsPersonal()); |
| 81 external_validation_value_state, helper_.IsPersonal()); | |
| 82 } | 83 } |
| 83 TrackedPreferenceHelper::ResetAction reset_action = | 84 TrackedPreferenceHelper::ResetAction reset_action = |
| 84 helper_.GetAction(value_state); | 85 helper_.GetAction(value_state); |
| 85 helper_.ReportAction(reset_action); | 86 helper_.ReportAction(reset_action); |
| 86 | 87 |
| 87 bool was_reset = false; | 88 bool was_reset = false; |
| 88 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 89 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
| 89 if (value_state == PrefHashStoreTransaction::CHANGED) { | 90 if (value_state == PrefHashStoreTransaction::CHANGED) { |
| 90 DCHECK(!invalid_keys.empty()); | 91 DCHECK(!invalid_keys.empty()); |
| 91 | 92 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 (was_reset || | 113 (was_reset || |
| 113 external_validation_value_state != | 114 external_validation_value_state != |
| 114 PrefHashStoreTransaction::UNCHANGED)) { | 115 PrefHashStoreTransaction::UNCHANGED)) { |
| 115 const base::DictionaryValue* new_dict_value = nullptr; | 116 const base::DictionaryValue* new_dict_value = nullptr; |
| 116 pref_store_contents->GetDictionary(pref_path_, &new_dict_value); | 117 pref_store_contents->GetDictionary(pref_path_, &new_dict_value); |
| 117 external_validation_transaction->StoreSplitHash(pref_path_, new_dict_value); | 118 external_validation_transaction->StoreSplitHash(pref_path_, new_dict_value); |
| 118 } | 119 } |
| 119 | 120 |
| 120 return was_reset; | 121 return was_reset; |
| 121 } | 122 } |
| OLD | NEW |