| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/values.h" | 5 #include "base/values.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 delete entry; | 667 delete entry; |
| 668 dictionary_.erase(entry_iterator); | 668 dictionary_.erase(entry_iterator); |
| 669 return true; | 669 return true; |
| 670 } | 670 } |
| 671 | 671 |
| 672 DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() { | 672 DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() { |
| 673 Value* copy = CopyWithoutEmptyChildren(this); | 673 Value* copy = CopyWithoutEmptyChildren(this); |
| 674 return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; | 674 return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; |
| 675 } | 675 } |
| 676 | 676 |
| 677 void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { |
| 678 for (DictionaryValue::key_iterator key(dictionary->begin_keys()); |
| 679 key != dictionary->end_keys(); ++key) { |
| 680 Value* merge_value; |
| 681 if (dictionary->GetWithoutPathExpansion(*key, &merge_value)) { |
| 682 // Check whether we have to merge dictionaries. |
| 683 if (merge_value->IsType(Value::TYPE_DICTIONARY)) { |
| 684 DictionaryValue* sub_dict; |
| 685 if (GetDictionaryWithoutPathExpansion(*key, &sub_dict)) { |
| 686 sub_dict->MergeDictionary( |
| 687 static_cast<const DictionaryValue*>(merge_value)); |
| 688 continue; |
| 689 } |
| 690 } |
| 691 // All other cases: Make a copy and hook it up. |
| 692 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); |
| 693 } |
| 694 } |
| 695 } |
| 696 |
| 677 ///////////////////// ListValue //////////////////// | 697 ///////////////////// ListValue //////////////////// |
| 678 | 698 |
| 679 ListValue::~ListValue() { | 699 ListValue::~ListValue() { |
| 680 Clear(); | 700 Clear(); |
| 681 } | 701 } |
| 682 | 702 |
| 683 void ListValue::Clear() { | 703 void ListValue::Clear() { |
| 684 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) | 704 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) |
| 685 delete *i; | 705 delete *i; |
| 686 list_.clear(); | 706 list_.clear(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 lhs_it != end() && rhs_it != other_list->end(); | 891 lhs_it != end() && rhs_it != other_list->end(); |
| 872 ++lhs_it, ++rhs_it) { | 892 ++lhs_it, ++rhs_it) { |
| 873 if (!(*lhs_it)->Equals(*rhs_it)) | 893 if (!(*lhs_it)->Equals(*rhs_it)) |
| 874 return false; | 894 return false; |
| 875 } | 895 } |
| 876 if (lhs_it != end() || rhs_it != other_list->end()) | 896 if (lhs_it != end() || rhs_it != other_list->end()) |
| 877 return false; | 897 return false; |
| 878 | 898 |
| 879 return true; | 899 return true; |
| 880 } | 900 } |
| OLD | NEW |