Chromium Code Reviews| Index: components/user_prefs/tracked/tracked_atomic_preference.cc |
| diff --git a/components/user_prefs/tracked/tracked_atomic_preference.cc b/components/user_prefs/tracked/tracked_atomic_preference.cc |
| index fe49826dc45f0016ede4e32b495ddb4cc4584ce3..2415d7f844a909a3ebbdcbd70741b05c8dff52ae 100644 |
| --- a/components/user_prefs/tracked/tracked_atomic_preference.cc |
| +++ b/components/user_prefs/tracked/tracked_atomic_preference.cc |
| @@ -24,6 +24,10 @@ TrackedAtomicPreference::TrackedAtomicPreference( |
| delegate_(delegate) { |
| } |
| +TrackedPreferenceType TrackedAtomicPreference::GetType() const { |
| + return TrackedPreferenceType::ATOMIC; |
| +} |
| + |
| void TrackedAtomicPreference::OnNewValue( |
| const base::Value* value, |
| PrefHashStoreTransaction* transaction) const { |
| @@ -32,20 +36,32 @@ void TrackedAtomicPreference::OnNewValue( |
| bool TrackedAtomicPreference::EnforceAndReport( |
| base::DictionaryValue* pref_store_contents, |
| - PrefHashStoreTransaction* transaction) const { |
| + PrefHashStoreTransaction* transaction, |
| + PrefHashStoreTransaction* external_validation_transaction) const { |
| const base::Value* value = NULL; |
| pref_store_contents->Get(pref_path_, &value); |
| PrefHashStoreTransaction::ValueState value_state = |
| transaction->CheckValue(pref_path_, value); |
| - |
| helper_.ReportValidationResult(value_state, transaction->GetStoreUMASuffix()); |
| - TrackedPreferenceHelper::ResetAction reset_action = |
| - helper_.GetAction(value_state); |
| + PrefHashStoreTransaction::ValueState external_validation_value_state = |
| + PrefHashStoreTransaction::UNCHANGED; |
| + if (external_validation_transaction) { |
| + external_validation_value_state = |
| + external_validation_transaction->CheckValue(pref_path_, value); |
| + helper_.ReportValidationResult( |
| + external_validation_value_state, |
| + external_validation_transaction->GetStoreUMASuffix()); |
| + |
| + // TODO(proberge): Call delegate_->OnAtomicPreferenceValidation. |
| + } |
| + |
| if (delegate_) { |
| delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, |
| helper_.IsPersonal()); |
| } |
| + TrackedPreferenceHelper::ResetAction reset_action = |
| + helper_.GetAction(value_state); |
| helper_.ReportAction(reset_action); |
| bool was_reset = false; |
| @@ -61,5 +77,16 @@ bool TrackedAtomicPreference::EnforceAndReport( |
| transaction->StoreHash(pref_path_, new_value); |
| } |
| + // Update MACs in the external store if there is one and there either was a |
| + // reset or external validation failed. |
| + if (external_validation_transaction && |
| + (was_reset || |
| + external_validation_value_state != |
| + PrefHashStoreTransaction::UNCHANGED)) { |
| + const base::Value* new_value = nullptr; |
| + pref_store_contents->Get(pref_path_, &new_value); |
| + external_validation_transaction->StoreHash(pref_path_, new_value); |
|
gab
2016/09/16 19:47:33
This is fine in practice because it runs as part o
proberge
2016/09/20 21:35:45
This is similar logic to line 77. Also, in theory
gab
2016/09/21 17:55:30
It's different than 77 because 77 writes to |trans
proberge
2016/09/21 21:09:24
Hmm, you're right. Your original comment said "it'
gab
2016/09/22 18:38:28
I think just adding to TrackedPreference::EnforceA
proberge
2016/09/22 19:10:15
Done.
|
| + } |
| + |
| return was_reset; |
| } |