summaryrefslogtreecommitdiffstats
path: root/base/values.cc
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 13:17:40 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 13:17:40 +0000
commitc378cca3b4c7f2c48184283f3ab2ac5818233037 (patch)
treeae94b40eb8fb1432307a80818f6ee04437e149cf /base/values.cc
parent70c19a930beddde0e382777cb8799e7c8ebb1625 (diff)
downloadchromium_src-c378cca3b4c7f2c48184283f3ab2ac5818233037.zip
chromium_src-c378cca3b4c7f2c48184283f3ab2ac5818233037.tar.gz
chromium_src-c378cca3b4c7f2c48184283f3ab2ac5818233037.tar.bz2
Preference provider implementation backed by JSON files in a directory.
BUG=42412 TEST=Unit tests in chrome/browser/value_tree_policy_decoder.cc and base/values_unittest.cc Review URL: http://codereview.chromium.org/2027010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.cc')
-rw-r--r--base/values.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/base/values.cc b/base/values.cc
index feff299..507646c 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() {