| 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_atomic_preference.h" | 5 #include "components/user_prefs/tracked/tracked_atomic_preference.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" | 8 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
| 9 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h
" | 9 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h
" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 base::DictionaryValue* pref_store_contents, | 38 base::DictionaryValue* pref_store_contents, |
| 39 PrefHashStoreTransaction* transaction, | 39 PrefHashStoreTransaction* transaction, |
| 40 PrefHashStoreTransaction* external_validation_transaction) const { | 40 PrefHashStoreTransaction* external_validation_transaction) const { |
| 41 const base::Value* value = NULL; | 41 const base::Value* value = NULL; |
| 42 pref_store_contents->Get(pref_path_, &value); | 42 pref_store_contents->Get(pref_path_, &value); |
| 43 PrefHashStoreTransaction::ValueState value_state = | 43 PrefHashStoreTransaction::ValueState value_state = |
| 44 transaction->CheckValue(pref_path_, value); | 44 transaction->CheckValue(pref_path_, value); |
| 45 helper_.ReportValidationResult(value_state, transaction->GetStoreUMASuffix()); | 45 helper_.ReportValidationResult(value_state, transaction->GetStoreUMASuffix()); |
| 46 | 46 |
| 47 PrefHashStoreTransaction::ValueState external_validation_value_state = | 47 PrefHashStoreTransaction::ValueState external_validation_value_state = |
| 48 PrefHashStoreTransaction::UNCHANGED; | 48 PrefHashStoreTransaction::UNSUPPORTED; |
| 49 if (external_validation_transaction) { | 49 if (external_validation_transaction) { |
| 50 external_validation_value_state = | 50 external_validation_value_state = |
| 51 external_validation_transaction->CheckValue(pref_path_, value); | 51 external_validation_transaction->CheckValue(pref_path_, value); |
| 52 helper_.ReportValidationResult( | 52 helper_.ReportValidationResult( |
| 53 external_validation_value_state, | 53 external_validation_value_state, |
| 54 external_validation_transaction->GetStoreUMASuffix()); | 54 external_validation_transaction->GetStoreUMASuffix()); |
| 55 | |
| 56 // TODO(proberge): Call delegate_->OnAtomicPreferenceValidation. | |
| 57 } | 55 } |
| 58 | 56 |
| 59 if (delegate_) { | 57 if (delegate_) { |
| 60 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, | 58 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, |
| 59 external_validation_value_state, |
| 61 helper_.IsPersonal()); | 60 helper_.IsPersonal()); |
| 62 } | 61 } |
| 63 TrackedPreferenceHelper::ResetAction reset_action = | 62 TrackedPreferenceHelper::ResetAction reset_action = |
| 64 helper_.GetAction(value_state); | 63 helper_.GetAction(value_state); |
| 65 helper_.ReportAction(reset_action); | 64 helper_.ReportAction(reset_action); |
| 66 | 65 |
| 67 bool was_reset = false; | 66 bool was_reset = false; |
| 68 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 67 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
| 69 pref_store_contents->RemovePath(pref_path_, NULL); | 68 pref_store_contents->RemovePath(pref_path_, NULL); |
| 70 was_reset = true; | 69 was_reset = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 83 (was_reset || | 82 (was_reset || |
| 84 external_validation_value_state != | 83 external_validation_value_state != |
| 85 PrefHashStoreTransaction::UNCHANGED)) { | 84 PrefHashStoreTransaction::UNCHANGED)) { |
| 86 const base::Value* new_value = nullptr; | 85 const base::Value* new_value = nullptr; |
| 87 pref_store_contents->Get(pref_path_, &new_value); | 86 pref_store_contents->Get(pref_path_, &new_value); |
| 88 external_validation_transaction->StoreHash(pref_path_, new_value); | 87 external_validation_transaction->StoreHash(pref_path_, new_value); |
| 89 } | 88 } |
| 90 | 89 |
| 91 return was_reset; | 90 return was_reset; |
| 92 } | 91 } |
| OLD | NEW |