| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/policy/core/common/registry_dict.h" | 5 #include "components/policy/core/common/registry_dict.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const base::DictionaryValue* dict = nullptr; | 47 const base::DictionaryValue* dict = nullptr; |
| 48 const base::ListValue* list = nullptr; | 48 const base::ListValue* list = nullptr; |
| 49 if (value.GetAsDictionary(&dict)) { | 49 if (value.GetAsDictionary(&dict)) { |
| 50 std::unique_ptr<base::DictionaryValue> result( | 50 std::unique_ptr<base::DictionaryValue> result( |
| 51 new base::DictionaryValue()); | 51 new base::DictionaryValue()); |
| 52 for (base::DictionaryValue::Iterator entry(*dict); !entry.IsAtEnd(); | 52 for (base::DictionaryValue::Iterator entry(*dict); !entry.IsAtEnd(); |
| 53 entry.Advance()) { | 53 entry.Advance()) { |
| 54 std::unique_ptr<base::Value> converted = | 54 std::unique_ptr<base::Value> converted = |
| 55 ConvertValue(entry.value(), schema.GetProperty(entry.key())); | 55 ConvertValue(entry.value(), schema.GetProperty(entry.key())); |
| 56 if (converted) | 56 if (converted) |
| 57 result->SetWithoutPathExpansion(entry.key(), converted.release()); | 57 result->SetWithoutPathExpansion(entry.key(), std::move(converted)); |
| 58 } | 58 } |
| 59 return std::move(result); | 59 return std::move(result); |
| 60 } else if (value.GetAsList(&list)) { | 60 } else if (value.GetAsList(&list)) { |
| 61 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 61 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 62 for (base::ListValue::const_iterator entry(list->begin()); | 62 for (base::ListValue::const_iterator entry(list->begin()); |
| 63 entry != list->end(); ++entry) { | 63 entry != list->end(); ++entry) { |
| 64 std::unique_ptr<base::Value> converted = | 64 std::unique_ptr<base::Value> converted = |
| 65 ConvertValue(*entry, schema.GetItems()); | 65 ConvertValue(*entry, schema.GetItems()); |
| 66 if (converted) | 66 if (converted) |
| 67 result->Append(std::move(converted)); | 67 result->Append(std::move(converted)); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 case base::Value::Type::DICTIONARY: { | 308 case base::Value::Type::DICTIONARY: { |
| 309 std::unique_ptr<base::DictionaryValue> result( | 309 std::unique_ptr<base::DictionaryValue> result( |
| 310 new base::DictionaryValue()); | 310 new base::DictionaryValue()); |
| 311 for (RegistryDict::ValueMap::const_iterator entry(values_.begin()); | 311 for (RegistryDict::ValueMap::const_iterator entry(values_.begin()); |
| 312 entry != values_.end(); ++entry) { | 312 entry != values_.end(); ++entry) { |
| 313 Schema subschema = | 313 Schema subschema = |
| 314 schema.valid() ? schema.GetProperty(entry->first) : Schema(); | 314 schema.valid() ? schema.GetProperty(entry->first) : Schema(); |
| 315 std::unique_ptr<base::Value> converted = | 315 std::unique_ptr<base::Value> converted = |
| 316 ConvertValue(*entry->second, subschema); | 316 ConvertValue(*entry->second, subschema); |
| 317 if (converted) | 317 if (converted) |
| 318 result->SetWithoutPathExpansion(entry->first, converted.release()); | 318 result->SetWithoutPathExpansion(entry->first, std::move(converted)); |
| 319 } | 319 } |
| 320 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); | 320 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); |
| 321 entry != keys_.end(); ++entry) { | 321 entry != keys_.end(); ++entry) { |
| 322 Schema subschema = | 322 Schema subschema = |
| 323 schema.valid() ? schema.GetProperty(entry->first) : Schema(); | 323 schema.valid() ? schema.GetProperty(entry->first) : Schema(); |
| 324 std::unique_ptr<base::Value> converted = | 324 std::unique_ptr<base::Value> converted = |
| 325 entry->second->ConvertToJSON(subschema); | 325 entry->second->ConvertToJSON(subschema); |
| 326 if (converted) | 326 if (converted) |
| 327 result->SetWithoutPathExpansion(entry->first, converted.release()); | 327 result->SetWithoutPathExpansion(entry->first, std::move(converted)); |
| 328 } | 328 } |
| 329 return std::move(result); | 329 return std::move(result); |
| 330 } | 330 } |
| 331 case base::Value::Type::LIST: { | 331 case base::Value::Type::LIST: { |
| 332 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 332 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 333 Schema item_schema = schema.valid() ? schema.GetItems() : Schema(); | 333 Schema item_schema = schema.valid() ? schema.GetItems() : Schema(); |
| 334 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); | 334 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); |
| 335 entry != keys_.end(); ++entry) { | 335 entry != keys_.end(); ++entry) { |
| 336 if (!IsKeyNumerical(entry->first)) | 336 if (!IsKeyNumerical(entry->first)) |
| 337 continue; | 337 continue; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 352 return std::move(result); | 352 return std::move(result); |
| 353 } | 353 } |
| 354 default: | 354 default: |
| 355 LOG(WARNING) << "Can't convert registry key to schema type " << type; | 355 LOG(WARNING) << "Can't convert registry key to schema type " << type; |
| 356 } | 356 } |
| 357 | 357 |
| 358 return nullptr; | 358 return nullptr; |
| 359 } | 359 } |
| 360 #endif // #if defined(OS_WIN) | 360 #endif // #if defined(OS_WIN) |
| 361 } // namespace policy | 361 } // namespace policy |
| OLD | NEW |