| 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 "services/preferences/tracked/tracked_atomic_preference.h" | 5 #include "services/preferences/tracked/tracked_atomic_preference.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "services/preferences/public/interfaces/tracked_preference_validation_d
elegate.mojom.h" | 8 #include "services/preferences/public/interfaces/tracked_preference_validation_d
elegate.mojom.h" |
| 9 #include "services/preferences/tracked/pref_hash_store_transaction.h" | 9 #include "services/preferences/tracked/pref_hash_store_transaction.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } | 55 } |
| 56 | 56 |
| 57 if (delegate_) { | 57 if (delegate_) { |
| 58 delegate_->OnAtomicPreferenceValidation( | 58 delegate_->OnAtomicPreferenceValidation( |
| 59 pref_path_, value ? value->CreateDeepCopy() : nullptr, value_state, | 59 pref_path_, value ? base::Optional<base::Value>(*value) : base::nullopt, |
| 60 external_validation_value_state, helper_.IsPersonal()); | 60 value_state, external_validation_value_state, helper_.IsPersonal()); |
| 61 } | 61 } |
| 62 TrackedPreferenceHelper::ResetAction reset_action = | 62 TrackedPreferenceHelper::ResetAction reset_action = |
| 63 helper_.GetAction(value_state); | 63 helper_.GetAction(value_state); |
| 64 helper_.ReportAction(reset_action); | 64 helper_.ReportAction(reset_action); |
| 65 | 65 |
| 66 bool was_reset = false; | 66 bool was_reset = false; |
| 67 if (reset_action == TrackedPreferenceHelper::DO_RESET) { | 67 if (reset_action == TrackedPreferenceHelper::DO_RESET) { |
| 68 pref_store_contents->RemovePath(pref_path_, NULL); | 68 pref_store_contents->RemovePath(pref_path_, NULL); |
| 69 was_reset = true; | 69 was_reset = true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 if (value_state != ValueState::UNCHANGED) { | 72 if (value_state != ValueState::UNCHANGED) { |
| 73 // Store the hash for the new value (whether it was reset or not). | 73 // Store the hash for the new value (whether it was reset or not). |
| 74 const base::Value* new_value = NULL; | 74 const base::Value* new_value = NULL; |
| 75 pref_store_contents->Get(pref_path_, &new_value); | 75 pref_store_contents->Get(pref_path_, &new_value); |
| 76 transaction->StoreHash(pref_path_, new_value); | 76 transaction->StoreHash(pref_path_, new_value); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Update MACs in the external store if there is one and there either was a | 79 // Update MACs in the external store if there is one and there either was a |
| 80 // reset or external validation failed. | 80 // reset or external validation failed. |
| 81 if (external_validation_transaction && | 81 if (external_validation_transaction && |
| 82 (was_reset || external_validation_value_state != ValueState::UNCHANGED)) { | 82 (was_reset || external_validation_value_state != ValueState::UNCHANGED)) { |
| 83 const base::Value* new_value = nullptr; | 83 const base::Value* new_value = nullptr; |
| 84 pref_store_contents->Get(pref_path_, &new_value); | 84 pref_store_contents->Get(pref_path_, &new_value); |
| 85 external_validation_transaction->StoreHash(pref_path_, new_value); | 85 external_validation_transaction->StoreHash(pref_path_, new_value); |
| 86 } | 86 } |
| 87 | 87 |
| 88 return was_reset; | 88 return was_reset; |
| 89 } | 89 } |
| OLD | NEW |