Chromium Code Reviews| 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_win.h" | 5 #include "components/policy/core/common/registry_dict_win.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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 return std::unique_ptr<base::Value>( | 96 return std::unique_ptr<base::Value>( |
| 97 new base::FundamentalValue(double_value)); | 97 new base::FundamentalValue(double_value)); |
| 98 } | 98 } |
| 99 break; | 99 break; |
| 100 } | 100 } |
| 101 case base::Value::TYPE_LIST: { | 101 case base::Value::TYPE_LIST: { |
| 102 // Lists are encoded as subkeys with numbered value in the registry. | 102 // Lists are encoded as subkeys with numbered value in the registry. |
| 103 const base::DictionaryValue* dict = nullptr; | 103 const base::DictionaryValue* dict = nullptr; |
| 104 if (value.GetAsDictionary(&dict)) { | 104 if (value.GetAsDictionary(&dict)) { |
| 105 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 105 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 106 for (int i = 1; ; ++i) { | 106 for (int i = 1; ; ++i) { |
|
pastarmovj
2016/11/03 16:27:47
Don't you need to fix this part too?
Georges Khalil
2016/11/03 18:16:16
Oops, will fix it.
| |
| 107 const base::Value* entry = nullptr; | 107 const base::Value* entry = nullptr; |
| 108 if (!dict->Get(base::IntToString(i), &entry)) | 108 if (!dict->Get(base::IntToString(i), &entry)) |
| 109 break; | 109 break; |
| 110 std::unique_ptr<base::Value> converted = | 110 std::unique_ptr<base::Value> converted = |
| 111 ConvertValue(*entry, schema.GetItems()); | 111 ConvertValue(*entry, schema.GetItems()); |
| 112 if (converted) | 112 if (converted) |
| 113 result->Append(converted.release()); | 113 result->Append(converted.release()); |
| 114 } | 114 } |
| 115 return std::move(result); | 115 return std::move(result); |
| 116 } | 116 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 std::unique_ptr<base::Value> converted = | 315 std::unique_ptr<base::Value> converted = |
| 316 entry->second->ConvertToJSON(subschema); | 316 entry->second->ConvertToJSON(subschema); |
| 317 if (converted) | 317 if (converted) |
| 318 result->SetWithoutPathExpansion(entry->first, converted.release()); | 318 result->SetWithoutPathExpansion(entry->first, converted.release()); |
| 319 } | 319 } |
| 320 return std::move(result); | 320 return std::move(result); |
| 321 } | 321 } |
| 322 case base::Value::TYPE_LIST: { | 322 case base::Value::TYPE_LIST: { |
| 323 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 323 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 324 Schema item_schema = schema.valid() ? schema.GetItems() : Schema(); | 324 Schema item_schema = schema.valid() ? schema.GetItems() : Schema(); |
| 325 for (int i = 1; ; ++i) { | 325 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); |
| 326 const std::string name(base::IntToString(i)); | 326 entry != keys_.end(); ++entry) { |
|
pastarmovj
2016/11/03 16:27:47
I think it still makes sense to only parse numbere
Georges Khalil
2016/11/03 18:16:16
Skipping over non-integer names makes sense.
We w
Georges Khalil
2016/11/03 20:24:54
I just realized that a dictionary uses a map inste
| |
| 327 const RegistryDict* key = GetKey(name); | 327 std::unique_ptr<base::Value> converted = |
| 328 if (key) { | 328 entry->second->ConvertToJSON(item_schema); |
| 329 std::unique_ptr<base::Value> converted = | 329 if (converted) |
| 330 key->ConvertToJSON(item_schema); | 330 result->Append(converted.release()); |
| 331 if (converted) | 331 } |
| 332 result->Append(converted.release()); | 332 for (RegistryDict::ValueMap::const_iterator entry(values_.begin()); |
| 333 continue; | 333 entry != values_.end(); ++entry) { |
| 334 } | 334 std::unique_ptr<base::Value> converted = |
| 335 const base::Value* value = GetValue(name); | 335 ConvertValue(*entry->second, item_schema); |
| 336 if (value) { | 336 if (converted) |
| 337 std::unique_ptr<base::Value> converted = | 337 result->Append(converted.release()); |
| 338 ConvertValue(*value, item_schema); | |
| 339 if (converted) | |
| 340 result->Append(converted.release()); | |
| 341 continue; | |
| 342 } | |
| 343 break; | |
| 344 } | 338 } |
| 345 return std::move(result); | 339 return std::move(result); |
| 346 } | 340 } |
| 347 default: | 341 default: |
| 348 LOG(WARNING) << "Can't convert registry key to schema type " << type; | 342 LOG(WARNING) << "Can't convert registry key to schema type " << type; |
| 349 } | 343 } |
| 350 | 344 |
| 351 return nullptr; | 345 return nullptr; |
| 352 } | 346 } |
| 353 | 347 |
| 354 } // namespace policy | 348 } // namespace policy |
| OLD | NEW |