| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void RegistryDict::Swap(RegistryDict* other) { | 236 void RegistryDict::Swap(RegistryDict* other) { |
| 237 keys_.swap(other->keys_); | 237 keys_.swap(other->keys_); |
| 238 values_.swap(other->values_); | 238 values_.swap(other->values_); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) { | 241 void RegistryDict::ReadRegistry(HKEY hive, const base::string16& root) { |
| 242 ClearKeys(); | 242 ClearKeys(); |
| 243 ClearValues(); | 243 ClearValues(); |
| 244 | 244 |
| 245 // First, read all the values of the key. | 245 // First, read all the values of the key. |
| 246 for (RegistryValueIterator it(hive, root.c_str()); it.Valid(); ++it) { | 246 for (RegistryValueIterator it(hive, root.c_str(), 0); it.Valid(); ++it) { |
| 247 const std::string name = base::UTF16ToUTF8(it.Name()); | 247 const std::string name = base::UTF16ToUTF8(it.Name()); |
| 248 switch (it.Type()) { | 248 switch (it.Type()) { |
| 249 case REG_SZ: | 249 case REG_SZ: |
| 250 case REG_EXPAND_SZ: | 250 case REG_EXPAND_SZ: |
| 251 SetValue(name, | 251 SetValue(name, |
| 252 scoped_ptr<base::Value>( | 252 scoped_ptr<base::Value>( |
| 253 new base::StringValue(base::UTF16ToUTF8(it.Value())))); | 253 new base::StringValue(base::UTF16ToUTF8(it.Value())))); |
| 254 continue; | 254 continue; |
| 255 case REG_DWORD_LITTLE_ENDIAN: | 255 case REG_DWORD_LITTLE_ENDIAN: |
| 256 case REG_DWORD_BIG_ENDIAN: | 256 case REG_DWORD_BIG_ENDIAN: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 275 // Unsupported type, message gets logged below. | 275 // Unsupported type, message gets logged below. |
| 276 break; | 276 break; |
| 277 } | 277 } |
| 278 | 278 |
| 279 LOG(WARNING) << "Failed to read hive " << hive << " at " | 279 LOG(WARNING) << "Failed to read hive " << hive << " at " |
| 280 << root << "\\" << name | 280 << root << "\\" << name |
| 281 << " type " << it.Type(); | 281 << " type " << it.Type(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // Recurse for all subkeys. | 284 // Recurse for all subkeys. |
| 285 for (RegistryKeyIterator it(hive, root.c_str()); it.Valid(); ++it) { | 285 for (RegistryKeyIterator it(hive, root.c_str(), 0); it.Valid(); ++it) { |
| 286 std::string name(base::UTF16ToUTF8(it.Name())); | 286 std::string name(base::UTF16ToUTF8(it.Name())); |
| 287 scoped_ptr<RegistryDict> subdict(new RegistryDict()); | 287 scoped_ptr<RegistryDict> subdict(new RegistryDict()); |
| 288 subdict->ReadRegistry(hive, root + L"\\" + it.Name()); | 288 subdict->ReadRegistry(hive, root + L"\\" + it.Name()); |
| 289 SetKey(name, subdict.Pass()); | 289 SetKey(name, subdict.Pass()); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 | 292 |
| 293 scoped_ptr<base::Value> RegistryDict::ConvertToJSON( | 293 scoped_ptr<base::Value> RegistryDict::ConvertToJSON( |
| 294 const Schema& schema) const { | 294 const Schema& schema) const { |
| 295 base::Value::Type type = | 295 base::Value::Type type = |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 return result.PassAs<base::Value>(); | 341 return result.PassAs<base::Value>(); |
| 342 } | 342 } |
| 343 default: | 343 default: |
| 344 LOG(WARNING) << "Can't convert registry key to schema type " << type; | 344 LOG(WARNING) << "Can't convert registry key to schema type " << type; |
| 345 } | 345 } |
| 346 | 346 |
| 347 return scoped_ptr<base::Value>(); | 347 return scoped_ptr<base::Value>(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 } // namespace policy | 350 } // namespace policy |
| OLD | NEW |