Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 } | 25 } |
| 26 | 26 |
| 27 void TrackedAtomicPreference::OnNewValue( | 27 void TrackedAtomicPreference::OnNewValue( |
| 28 const base::Value* value, | 28 const base::Value* value, |
| 29 PrefHashStoreTransaction* transaction) const { | 29 PrefHashStoreTransaction* transaction) const { |
| 30 transaction->StoreHash(pref_path_, value); | 30 transaction->StoreHash(pref_path_, value); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool TrackedAtomicPreference::EnforceAndReport( | 33 bool TrackedAtomicPreference::EnforceAndReport( |
| 34 base::DictionaryValue* pref_store_contents, | 34 base::DictionaryValue* pref_store_contents, |
| 35 PrefHashStoreTransaction* transaction) const { | 35 PrefHashStoreTransaction* transaction, |
| 36 PrefHashStoreTransaction* registry_transaction) const { | |
| 36 const base::Value* value = NULL; | 37 const base::Value* value = NULL; |
| 37 pref_store_contents->Get(pref_path_, &value); | 38 pref_store_contents->Get(pref_path_, &value); |
| 38 PrefHashStoreTransaction::ValueState value_state = | 39 PrefHashStoreTransaction::ValueState value_state = |
| 39 transaction->CheckValue(pref_path_, value); | 40 transaction->CheckValue(pref_path_, value); |
| 41 helper_.ReportValidationResult(value_state, transaction->GetStoreType()); | |
| 40 | 42 |
| 41 helper_.ReportValidationResult(value_state); | 43 PrefHashStoreTransaction::ValueState registry_value_state = |
|
gab
2016/08/03 18:19:36
Unused outside of if scope below, move it in there
proberge
2016/08/04 00:13:46
Used on line 76 to decide whether to update the re
| |
| 44 PrefHashStoreTransaction::UNCHANGED; | |
| 45 if (registry_transaction) { | |
| 46 registry_value_state = registry_transaction->CheckValue(pref_path_, value); | |
| 47 helper_.ReportValidationResult(registry_value_state, | |
| 48 registry_transaction->GetStoreType()); | |
|
gab
2016/08/03 18:19:36
Instead of adding "StoreType", I'd prefer to make
proberge
2016/08/04 00:13:46
The issue with GetUMAPrefix is that it's odd for D
gab
2016/08/05 19:59:25
I think that's fine, there can be a comment on it
| |
| 42 | 49 |
| 43 TrackedPreferenceHelper::ResetAction reset_action = | 50 // TODO(proberge): Call delegate_->OnAtomicPreferenceValidation. |
| 44 helper_.GetAction(value_state); | 51 } |
| 52 | |
| 45 if (delegate_) { | 53 if (delegate_) { |
| 46 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, | 54 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, |
| 47 helper_.IsPersonal()); | 55 helper_.IsPersonal()); |
| 48 } | 56 } |
| 57 TrackedPreferenceHelper::ResetAction reset_action = | |
| 58 helper_.GetAction(value_state); | |
| 49 helper_.ReportAction(reset_action); | 59 helper_.ReportAction(reset_action); |
| 50 | 60 |
| 51 bool was_reset = false; | 61 bool was_reset = false; |
| 52 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 62 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
| 53 pref_store_contents->RemovePath(pref_path_, NULL); | 63 pref_store_contents->RemovePath(pref_path_, NULL); |
| 54 was_reset = true; | 64 was_reset = true; |
| 55 } | 65 } |
| 56 | 66 |
| 57 if (value_state != PrefHashStoreTransaction::UNCHANGED) { | 67 if (value_state != PrefHashStoreTransaction::UNCHANGED) { |
| 58 // Store the hash for the new value (whether it was reset or not). | 68 // Store the hash for the new value (whether it was reset or not). |
| 59 const base::Value* new_value = NULL; | 69 const base::Value* new_value = NULL; |
| 60 pref_store_contents->Get(pref_path_, &new_value); | 70 pref_store_contents->Get(pref_path_, &new_value); |
| 61 transaction->StoreHash(pref_path_, new_value); | 71 transaction->StoreHash(pref_path_, new_value); |
| 62 } | 72 } |
| 63 | 73 |
| 74 if (registry_transaction && | |
| 75 (value_state != PrefHashStoreTransaction::UNCHANGED || | |
|
gab
2016/08/03 18:19:36
Here I think what you want to check is |was_reset|
proberge
2016/08/04 00:13:46
Done.
| |
| 76 registry_value_state != PrefHashStoreTransaction::UNCHANGED)) { | |
| 77 const base::Value* new_value = NULL; | |
| 78 pref_store_contents->Get(pref_path_, &new_value); | |
| 79 registry_transaction->StoreHash(pref_path_, new_value); | |
| 80 } | |
| 81 | |
| 64 return was_reset; | 82 return was_reset; |
| 65 } | 83 } |
| OLD | NEW |