OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync_preferences/pref_model_associator.h" | 5 #include "components/sync_preferences/pref_model_associator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 static_cast<const base::DictionaryValue&>(to_value); | 312 static_cast<const base::DictionaryValue&>(to_value); |
313 base::DictionaryValue* result = to_dict_value.DeepCopy(); | 313 base::DictionaryValue* result = to_dict_value.DeepCopy(); |
314 | 314 |
315 for (base::DictionaryValue::Iterator it(from_dict_value); !it.IsAtEnd(); | 315 for (base::DictionaryValue::Iterator it(from_dict_value); !it.IsAtEnd(); |
316 it.Advance()) { | 316 it.Advance()) { |
317 const base::Value* from_key_value = &it.value(); | 317 const base::Value* from_key_value = &it.value(); |
318 base::Value* to_key_value; | 318 base::Value* to_key_value; |
319 if (result->GetWithoutPathExpansion(it.key(), &to_key_value)) { | 319 if (result->GetWithoutPathExpansion(it.key(), &to_key_value)) { |
320 if (from_key_value->GetType() == base::Value::Type::DICTIONARY && | 320 if (from_key_value->GetType() == base::Value::Type::DICTIONARY && |
321 to_key_value->GetType() == base::Value::Type::DICTIONARY) { | 321 to_key_value->GetType() == base::Value::Type::DICTIONARY) { |
322 base::Value* merged_value = | 322 std::unique_ptr<base::Value> merged_value( |
323 MergeDictionaryValues(*from_key_value, *to_key_value); | 323 MergeDictionaryValues(*from_key_value, *to_key_value)); |
324 result->SetWithoutPathExpansion(it.key(), merged_value); | 324 result->SetWithoutPathExpansion(it.key(), std::move(merged_value)); |
325 } | 325 } |
326 // Note that for all other types we want to preserve the "to" | 326 // Note that for all other types we want to preserve the "to" |
327 // values so we do nothing here. | 327 // values so we do nothing here. |
328 } else { | 328 } else { |
329 result->SetWithoutPathExpansion(it.key(), from_key_value->DeepCopy()); | 329 result->SetWithoutPathExpansion(it.key(), |
| 330 from_key_value->CreateDeepCopy()); |
330 } | 331 } |
331 } | 332 } |
332 return result; | 333 return result; |
333 } | 334 } |
334 | 335 |
335 // Note: This will build a model of all preferences registered as syncable | 336 // Note: This will build a model of all preferences registered as syncable |
336 // with user controlled data. We do not track any information for preferences | 337 // with user controlled data. We do not track any information for preferences |
337 // not registered locally as syncable and do not inform the syncer of | 338 // not registered locally as syncable and do not inform the syncer of |
338 // non-user controlled preferences. | 339 // non-user controlled preferences. |
339 syncer::SyncDataList PrefModelAssociator::GetAllSyncData( | 340 syncer::SyncDataList PrefModelAssociator::GetAllSyncData( |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 bool from_sync) const { | 525 bool from_sync) const { |
525 auto observer_iter = synced_pref_observers_.find(path); | 526 auto observer_iter = synced_pref_observers_.find(path); |
526 if (observer_iter == synced_pref_observers_.end()) | 527 if (observer_iter == synced_pref_observers_.end()) |
527 return; | 528 return; |
528 SyncedPrefObserverList* observers = observer_iter->second.get(); | 529 SyncedPrefObserverList* observers = observer_iter->second.get(); |
529 for (auto& observer : *observers) | 530 for (auto& observer : *observers) |
530 observer.OnSyncedPrefChanged(path, from_sync); | 531 observer.OnSyncedPrefChanged(path, from_sync); |
531 } | 532 } |
532 | 533 |
533 } // namespace sync_preferences | 534 } // namespace sync_preferences |
OLD | NEW |