| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) { | 253 void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) { |
| 254 ClearKeys(); | 254 ClearKeys(); |
| 255 ClearValues(); | 255 ClearValues(); |
| 256 | 256 |
| 257 // First, read all the values of the key. | 257 // First, read all the values of the key. |
| 258 for (RegistryValueIterator it(hive, root.c_str()); it.Valid(); ++it) { | 258 for (RegistryValueIterator it(hive, root.c_str()); it.Valid(); ++it) { |
| 259 const std::string name = base::UTF16ToUTF8(it.Name()); | 259 const std::string name = base::UTF16ToUTF8(it.Name()); |
| 260 switch (it.Type()) { | 260 switch (it.Type()) { |
| 261 case REG_SZ: | 261 case REG_SZ: |
| 262 case REG_EXPAND_SZ: | 262 case REG_EXPAND_SZ: |
| 263 SetValue(name, std::unique_ptr<base::Value>(new base::StringValue( | 263 SetValue(name, std::unique_ptr<base::Value>( |
| 264 base::UTF16ToUTF8(it.Value())))); | 264 new base::Value(base::UTF16ToUTF8(it.Value())))); |
| 265 continue; | 265 continue; |
| 266 case REG_DWORD_LITTLE_ENDIAN: | 266 case REG_DWORD_LITTLE_ENDIAN: |
| 267 case REG_DWORD_BIG_ENDIAN: | 267 case REG_DWORD_BIG_ENDIAN: |
| 268 if (it.ValueSize() == sizeof(DWORD)) { | 268 if (it.ValueSize() == sizeof(DWORD)) { |
| 269 DWORD dword_value = *(reinterpret_cast<const DWORD*>(it.Value())); | 269 DWORD dword_value = *(reinterpret_cast<const DWORD*>(it.Value())); |
| 270 if (it.Type() == REG_DWORD_BIG_ENDIAN) | 270 if (it.Type() == REG_DWORD_BIG_ENDIAN) |
| 271 dword_value = base::NetToHost32(dword_value); | 271 dword_value = base::NetToHost32(dword_value); |
| 272 else | 272 else |
| 273 dword_value = base::ByteSwapToLE32(dword_value); | 273 dword_value = base::ByteSwapToLE32(dword_value); |
| 274 SetValue(name, std::unique_ptr<base::Value>( | 274 SetValue(name, std::unique_ptr<base::Value>( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |