OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/prefs/pref_hash_store_impl.h" | 5 #include "chrome/browser/prefs/pref_hash_store_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/prefs/pref_hash_store_transaction.h" | 10 #include "chrome/browser/prefs/pref_hash_store_transaction.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Constructs a PrefHashStoreTransactionImpl which can use the private | 33 // Constructs a PrefHashStoreTransactionImpl which can use the private |
34 // members of its |outer| PrefHashStoreImpl. | 34 // members of its |outer| PrefHashStoreImpl. |
35 explicit PrefHashStoreTransactionImpl(PrefHashStoreImpl* outer); | 35 explicit PrefHashStoreTransactionImpl(PrefHashStoreImpl* outer); |
36 virtual ~PrefHashStoreTransactionImpl(); | 36 virtual ~PrefHashStoreTransactionImpl(); |
37 | 37 |
38 // PrefHashStoreTransaction implementation. | 38 // PrefHashStoreTransaction implementation. |
39 virtual ValueState CheckValue(const std::string& path, | 39 virtual ValueState CheckValue(const std::string& path, |
40 const base::Value* value) const OVERRIDE; | 40 const base::Value* value) const OVERRIDE; |
41 virtual void StoreHash(const std::string& path, | 41 virtual void StoreHash(const std::string& path, |
42 const base::Value* value) OVERRIDE; | 42 const base::Value* value) OVERRIDE; |
| 43 virtual bool StampSuperMac() OVERRIDE; |
43 virtual ValueState CheckSplitValue( | 44 virtual ValueState CheckSplitValue( |
44 const std::string& path, | 45 const std::string& path, |
45 const base::DictionaryValue* initial_split_value, | 46 const base::DictionaryValue* initial_split_value, |
46 std::vector<std::string>* invalid_keys) const OVERRIDE; | 47 std::vector<std::string>* invalid_keys) const OVERRIDE; |
47 virtual void StoreSplitHash( | 48 virtual void StoreSplitHash( |
48 const std::string& path, | 49 const std::string& path, |
49 const base::DictionaryValue* split_value) OVERRIDE; | 50 const base::DictionaryValue* split_value) OVERRIDE; |
50 | 51 |
51 private: | 52 private: |
52 bool GetSplitMacs(const std::string& path, | 53 bool GetSplitMacs(const std::string& path, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 142 } |
142 | 143 |
143 void PrefHashStoreImpl::PrefHashStoreTransactionImpl::StoreHash( | 144 void PrefHashStoreImpl::PrefHashStoreTransactionImpl::StoreHash( |
144 const std::string& path, const base::Value* new_value) { | 145 const std::string& path, const base::Value* new_value) { |
145 const std::string mac = | 146 const std::string mac = |
146 outer_->pref_hash_calculator_.Calculate(path, new_value); | 147 outer_->pref_hash_calculator_.Calculate(path, new_value); |
147 (*outer_->contents_->GetMutableContents())->SetString(path, mac); | 148 (*outer_->contents_->GetMutableContents())->SetString(path, mac); |
148 has_changed_ = true; | 149 has_changed_ = true; |
149 } | 150 } |
150 | 151 |
| 152 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() { |
| 153 if (outer_->initial_hashes_dictionary_trusted_) |
| 154 return false; |
| 155 has_changed_ = true; |
| 156 return true; |
| 157 } |
| 158 |
151 PrefHashStoreTransaction::ValueState | 159 PrefHashStoreTransaction::ValueState |
152 PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( | 160 PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( |
153 const std::string& path, | 161 const std::string& path, |
154 const base::DictionaryValue* initial_split_value, | 162 const base::DictionaryValue* initial_split_value, |
155 std::vector<std::string>* invalid_keys) const { | 163 std::vector<std::string>* invalid_keys) const { |
156 DCHECK(invalid_keys && invalid_keys->empty()); | 164 DCHECK(invalid_keys && invalid_keys->empty()); |
157 | 165 |
158 std::map<std::string, std::string> split_macs; | 166 std::map<std::string, std::string> split_macs; |
159 const bool has_hashes = GetSplitMacs(path, &split_macs); | 167 const bool has_hashes = GetSplitMacs(path, &split_macs); |
160 | 168 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 it.Advance()) { | 270 it.Advance()) { |
263 std::string mac_string; | 271 std::string mac_string; |
264 if (!it.value().GetAsString(&mac_string)) { | 272 if (!it.value().GetAsString(&mac_string)) { |
265 NOTREACHED(); | 273 NOTREACHED(); |
266 continue; | 274 continue; |
267 } | 275 } |
268 split_macs->insert(make_pair(it.key(), mac_string)); | 276 split_macs->insert(make_pair(it.key(), mac_string)); |
269 } | 277 } |
270 return true; | 278 return true; |
271 } | 279 } |
OLD | NEW |