Chromium Code Reviews| Index: base/values.cc |
| diff --git a/base/values.cc b/base/values.cc |
| index 2d3984e0d4247ddb2b82aed3758771fa19bf8e31..97f5ffae80ab4f8cac4711dde189a9d76ed0277c 100644 |
| --- a/base/values.cc |
| +++ b/base/values.cc |
| @@ -462,8 +462,8 @@ void DictionaryValue::SetStringWithoutPathExpansion( |
| SetWithoutPathExpansion(path, CreateStringValue(in_value)); |
| } |
| -bool DictionaryValue::Get( |
| - const std::string& path, const Value** out_value) const { |
| +bool DictionaryValue::Get(const std::string& path, |
| + const Value** out_value) const { |
| DCHECK(IsStringUTF8(path)); |
| // LOG(WARNING) << "\n1\n"; |
| std::string current_path(path); |
| @@ -755,6 +755,25 @@ bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key, |
| return true; |
| } |
| +bool DictionaryValue::RemovePath(const std::string& path, |
| + scoped_ptr<Value>* out_value) { |
| + bool result = false; |
| + size_t delimiter_position = path.find('.'); |
| + if (delimiter_position == std::string::npos) { |
| + return RemoveWithoutPathExpansion(path, out_value); |
| + } else { |
| + const std::string subdict_path = path.substr(0, delimiter_position); |
| + DictionaryValue* subdict = NULL; |
| + if (!GetDictionary(subdict_path, &subdict)) |
| + return false; |
| + result = subdict->RemovePath(path.substr(delimiter_position + 1), |
| + out_value); |
| + if (result && subdict->empty()) |
| + Remove(subdict_path, NULL); |
|
Mattias Nissler (ping if slow)
2013/11/22 08:03:38
RemoveWithoutPathExpansion for clarity.
gab
2013/11/22 23:24:21
Done.
|
| + } |
| + return result; |
| +} |
| + |
| DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() const { |
| Value* copy = CopyWithoutEmptyChildren(this); |
| return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; |