| 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 "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); | 312 for (RegistryDict::KeyMap::const_iterator entry(keys_.begin()); |
| 313 entry != keys_.end(); ++entry) { | 313 entry != keys_.end(); ++entry) { |
| 314 Schema subschema = | 314 Schema subschema = |
| 315 schema.valid() ? schema.GetProperty(entry->first) : Schema(); | 315 schema.valid() ? schema.GetProperty(entry->first) : Schema(); |
| 316 scoped_ptr<base::Value> converted = | 316 scoped_ptr<base::Value> converted = |
| 317 entry->second->ConvertToJSON(subschema); | 317 entry->second->ConvertToJSON(subschema); |
| 318 if (converted) | 318 if (converted) |
| 319 result->SetWithoutPathExpansion(entry->first, converted.release()); | 319 result->SetWithoutPathExpansion(entry->first, converted.release()); |
| 320 } | 320 } |
| 321 return result.Pass(); | 321 return result.PassAs<base::Value>(); |
| 322 } | 322 } |
| 323 case base::Value::TYPE_LIST: { | 323 case base::Value::TYPE_LIST: { |
| 324 scoped_ptr<base::ListValue> result(new base::ListValue()); | 324 scoped_ptr<base::ListValue> result(new base::ListValue()); |
| 325 Schema item_schema = schema.valid() ? schema.GetItems() : Schema(); | 325 Schema item_schema = schema.valid() ? schema.GetItems() : Schema(); |
| 326 for (int i = 1; ; ++i) { | 326 for (int i = 1; ; ++i) { |
| 327 const std::string name(base::IntToString(i)); | 327 const std::string name(base::IntToString(i)); |
| 328 const RegistryDict* key = GetKey(name); | 328 const RegistryDict* key = GetKey(name); |
| 329 if (key) { | 329 if (key) { |
| 330 scoped_ptr<base::Value> converted = key->ConvertToJSON(item_schema); | 330 scoped_ptr<base::Value> converted = key->ConvertToJSON(item_schema); |
| 331 if (converted) | 331 if (converted) |
| 332 result->Append(converted.release()); | 332 result->Append(converted.release()); |
| 333 continue; | 333 continue; |
| 334 } | 334 } |
| 335 const base::Value* value = GetValue(name); | 335 const base::Value* value = GetValue(name); |
| 336 if (value) { | 336 if (value) { |
| 337 scoped_ptr<base::Value> converted = ConvertValue(*value, item_schema); | 337 scoped_ptr<base::Value> converted = ConvertValue(*value, item_schema); |
| 338 if (converted) | 338 if (converted) |
| 339 result->Append(converted.release()); | 339 result->Append(converted.release()); |
| 340 continue; | 340 continue; |
| 341 } | 341 } |
| 342 break; | 342 break; |
| 343 } | 343 } |
| 344 return result.Pass(); | 344 return result.PassAs<base::Value>(); |
| 345 } | 345 } |
| 346 default: | 346 default: |
| 347 LOG(WARNING) << "Can't convert registry key to schema type " << type; | 347 LOG(WARNING) << "Can't convert registry key to schema type " << type; |
| 348 } | 348 } |
| 349 | 349 |
| 350 return scoped_ptr<base::Value>(); | 350 return scoped_ptr<base::Value>(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 } // namespace policy | 353 } // namespace policy |
| OLD | NEW |