| 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 "chrome/browser/prefs/pref_model_associator.h" | 5 #include "chrome/browser/prefs/pref_model_associator.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 DCHECK_EQ(from_value.GetType(), Value::TYPE_DICTIONARY); | 247 DCHECK_EQ(from_value.GetType(), Value::TYPE_DICTIONARY); |
| 248 DCHECK_EQ(to_value.GetType(), Value::TYPE_DICTIONARY); | 248 DCHECK_EQ(to_value.GetType(), Value::TYPE_DICTIONARY); |
| 249 const DictionaryValue& from_dict_value = | 249 const DictionaryValue& from_dict_value = |
| 250 static_cast<const DictionaryValue&>(from_value); | 250 static_cast<const DictionaryValue&>(from_value); |
| 251 const DictionaryValue& to_dict_value = | 251 const DictionaryValue& to_dict_value = |
| 252 static_cast<const DictionaryValue&>(to_value); | 252 static_cast<const DictionaryValue&>(to_value); |
| 253 DictionaryValue* result = to_dict_value.DeepCopy(); | 253 DictionaryValue* result = to_dict_value.DeepCopy(); |
| 254 | 254 |
| 255 for (DictionaryValue::key_iterator key = from_dict_value.begin_keys(); | 255 for (DictionaryValue::key_iterator key = from_dict_value.begin_keys(); |
| 256 key != from_dict_value.end_keys(); ++key) { | 256 key != from_dict_value.end_keys(); ++key) { |
| 257 Value* from_value; | 257 const Value* from_value; |
| 258 bool success = from_dict_value.GetWithoutPathExpansion(*key, &from_value); | 258 bool success = from_dict_value.GetWithoutPathExpansion(*key, &from_value); |
| 259 DCHECK(success); | 259 DCHECK(success); |
| 260 | 260 |
| 261 Value* to_key_value; | 261 Value* to_key_value; |
| 262 if (result->GetWithoutPathExpansion(*key, &to_key_value)) { | 262 if (result->GetWithoutPathExpansion(*key, &to_key_value)) { |
| 263 if (to_key_value->GetType() == Value::TYPE_DICTIONARY) { | 263 if (to_key_value->GetType() == Value::TYPE_DICTIONARY) { |
| 264 Value* merged_value = MergeDictionaryValues(*from_value, *to_key_value); | 264 Value* merged_value = MergeDictionaryValues(*from_value, *to_key_value); |
| 265 result->SetWithoutPathExpansion(*key, merged_value); | 265 result->SetWithoutPathExpansion(*key, merged_value); |
| 266 } | 266 } |
| 267 // Note that for all other types we want to preserve the "to" | 267 // Note that for all other types we want to preserve the "to" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 | 439 |
| 440 syncer::SyncError error = | 440 syncer::SyncError error = |
| 441 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 441 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { | 444 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { |
| 445 DCHECK(pref_service_ == NULL); | 445 DCHECK(pref_service_ == NULL); |
| 446 pref_service_ = pref_service; | 446 pref_service_ = pref_service; |
| 447 } | 447 } |
| OLD | NEW |