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 "chrome/browser/prefs/tracked/tracked_preferences_migration.h" | 5 #include "chrome/browser/prefs/tracked/tracked_preferences_migration.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 old_hash_store_contents->Get(pref_name, &old_hash); | 185 old_hash_store_contents->Get(pref_name, &old_hash); |
186 if (!old_hash && legacy_hash_store_contents) { | 186 if (!old_hash && legacy_hash_store_contents) { |
187 legacy_hash_store_contents->Get(pref_name, &old_hash); | 187 legacy_hash_store_contents->Get(pref_name, &old_hash); |
188 if (old_hash) | 188 if (old_hash) |
189 *used_legacy_pref_hashes = true; | 189 *used_legacy_pref_hashes = true; |
190 } | 190 } |
191 if (old_hash) { | 191 if (old_hash) { |
192 new_hash_store_transaction->ImportHash(pref_name, old_hash); | 192 new_hash_store_transaction->ImportHash(pref_name, old_hash); |
193 *new_store_altered = true; | 193 *new_store_altered = true; |
194 } else if (!destination_hash_missing) { | 194 } else if (!destination_hash_missing) { |
195 new_hash_store_transaction->ClearHash(pref_name); | 195 // Do not allow values to be migrated without MACs if the destination |
| 196 // already has a MAC (http://crbug.com/414554). Remove the migrated |
| 197 // value in order to provide the same no-op behaviour as if the pref was |
| 198 // added to the wrong file when there was already a value for |
| 199 // |pref_name| in |new_store|. |
| 200 new_store->Remove(pref_name, NULL); |
196 *new_store_altered = true; | 201 *new_store_altered = true; |
197 } | 202 } |
198 } | 203 } |
199 } | 204 } |
200 } | 205 } |
201 | 206 |
202 TrackedPreferencesMigrator::TrackedPreferencesMigrator( | 207 TrackedPreferencesMigrator::TrackedPreferencesMigrator( |
203 const std::set<std::string>& unprotected_pref_names, | 208 const std::set<std::string>& unprotected_pref_names, |
204 const std::set<std::string>& protected_pref_names, | 209 const std::set<std::string>& protected_pref_names, |
205 const base::Callback<void(const std::string& key)>& | 210 const base::Callback<void(const std::string& key)>& |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 unprotected_store_cleaner, | 361 unprotected_store_cleaner, |
357 protected_store_cleaner, | 362 protected_store_cleaner, |
358 register_on_successful_unprotected_store_write_callback, | 363 register_on_successful_unprotected_store_write_callback, |
359 register_on_successful_protected_store_write_callback, | 364 register_on_successful_protected_store_write_callback, |
360 unprotected_pref_hash_store.Pass(), | 365 unprotected_pref_hash_store.Pass(), |
361 protected_pref_hash_store.Pass(), | 366 protected_pref_hash_store.Pass(), |
362 legacy_pref_hash_store.Pass(), | 367 legacy_pref_hash_store.Pass(), |
363 unprotected_pref_filter, | 368 unprotected_pref_filter, |
364 protected_pref_filter)); | 369 protected_pref_filter)); |
365 } | 370 } |
OLD | NEW |