OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/prefs/tracked/tracked_atomic_preference.h" | |
6 | |
7 #include "base/values.h" | |
8 #include "chrome/browser/prefs/pref_hash_store.h" | |
9 | |
10 TrackedAtomicPreference::TrackedAtomicPreference( | |
11 const std::string& pref_path, | |
12 size_t reporting_id, | |
13 size_t reporting_ids_count, | |
14 PrefHashFilter::EnforcementLevel enforcement_level, | |
15 PrefHashStore* pref_hash_store) | |
16 : pref_path_(pref_path), pref_hash_store_(pref_hash_store), | |
erikwright (departed)
2014/01/30 15:32:18
Initialize in the declaration order.
gab
2014/01/30 15:57:18
Done.
| |
17 helper_(pref_path, reporting_id, reporting_ids_count, enforcement_level) { | |
18 } | |
19 | |
20 void TrackedAtomicPreference::OnNewValue( | |
21 const base::Value* value) const { | |
22 pref_hash_store_->StoreHash(pref_path_, value); | |
23 } | |
24 | |
25 void TrackedAtomicPreference::EnforceAndReport( | |
26 base::DictionaryValue* pref_store_contents) const { | |
27 const base::Value* value = NULL; | |
28 pref_store_contents->Get(pref_path_, &value); | |
29 PrefHashStore::ValueState value_state = | |
30 pref_hash_store_->CheckValue(pref_path_, value); | |
31 | |
32 helper_.ReportValidationResult(value_state); | |
33 | |
34 TrackedPreferenceHelper::ResetAction reset_action = | |
35 helper_.GetAction(value_state); | |
36 helper_.ReportAction(reset_action); | |
37 | |
38 if (reset_action == TrackedPreferenceHelper::DO_RESET) | |
39 pref_store_contents->RemovePath(pref_path_, NULL); | |
40 | |
41 if (value_state != PrefHashStore::UNCHANGED) { | |
42 // Store the hash for the new value (whether it was reset or not). | |
43 const base::Value* new_value = NULL; | |
44 pref_store_contents->Get(pref_path_, &new_value); | |
45 pref_hash_store_->StoreHash(pref_path_, new_value); | |
46 } | |
47 } | |
OLD | NEW |