| Index: base/values.cc
|
| diff --git a/base/values.cc b/base/values.cc
|
| index feff299dbe2a57a8d8061fb77ec342e1c94745db..507646c8fbe69b605a9eb8ba6bd1cc44bbdcaeb5 100644
|
| --- a/base/values.cc
|
| +++ b/base/values.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -674,6 +674,26 @@ DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() {
|
| return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue;
|
| }
|
|
|
| +void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) {
|
| + for (DictionaryValue::key_iterator key(dictionary->begin_keys());
|
| + key != dictionary->end_keys(); ++key) {
|
| + Value* merge_value;
|
| + if (dictionary->GetWithoutPathExpansion(*key, &merge_value)) {
|
| + // Check whether we have to merge dictionaries.
|
| + if (merge_value->IsType(Value::TYPE_DICTIONARY)) {
|
| + DictionaryValue* sub_dict;
|
| + if (GetDictionaryWithoutPathExpansion(*key, &sub_dict)) {
|
| + sub_dict->MergeDictionary(
|
| + static_cast<const DictionaryValue*>(merge_value));
|
| + continue;
|
| + }
|
| + }
|
| + // All other cases: Make a copy and hook it up.
|
| + SetWithoutPathExpansion(*key, merge_value->DeepCopy());
|
| + }
|
| + }
|
| +}
|
| +
|
| ///////////////////// ListValue ////////////////////
|
|
|
| ListValue::~ListValue() {
|
|
|