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::UNSUPPORTED; | 48 PrefHashStoreTransaction::UNCHANGED; |
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. |
55 } | 57 } |
56 | 58 |
57 if (delegate_) { | 59 if (delegate_) { |
58 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, | 60 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, |
59 external_validation_value_state, | |
60 helper_.IsPersonal()); | 61 helper_.IsPersonal()); |
61 } | 62 } |
62 TrackedPreferenceHelper::ResetAction reset_action = | 63 TrackedPreferenceHelper::ResetAction reset_action = |
63 helper_.GetAction(value_state); | 64 helper_.GetAction(value_state); |
64 helper_.ReportAction(reset_action); | 65 helper_.ReportAction(reset_action); |
65 | 66 |
66 bool was_reset = false; | 67 bool was_reset = false; |
67 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 68 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
68 pref_store_contents->RemovePath(pref_path_, NULL); | 69 pref_store_contents->RemovePath(pref_path_, NULL); |
69 was_reset = true; | 70 was_reset = true; |
(...skipping 12 matching lines...) Expand all Loading... |
82 (was_reset || | 83 (was_reset || |
83 external_validation_value_state != | 84 external_validation_value_state != |
84 PrefHashStoreTransaction::UNCHANGED)) { | 85 PrefHashStoreTransaction::UNCHANGED)) { |
85 const base::Value* new_value = nullptr; | 86 const base::Value* new_value = nullptr; |
86 pref_store_contents->Get(pref_path_, &new_value); | 87 pref_store_contents->Get(pref_path_, &new_value); |
87 external_validation_transaction->StoreHash(pref_path_, new_value); | 88 external_validation_transaction->StoreHash(pref_path_, new_value); |
88 } | 89 } |
89 | 90 |
90 return was_reset; | 91 return was_reset; |
91 } | 92 } |
OLD | NEW |