OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/serial/serial_device_enumerator_win.h" | 5 #include "device/serial/serial_device_enumerator_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/win/registry.h" | 14 #include "base/win/registry.h" |
14 | 15 |
15 namespace device { | 16 namespace device { |
16 | 17 |
17 // static | 18 // static |
18 scoped_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() { | 19 scoped_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() { |
19 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorWin()); | 20 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorWin()); |
20 } | 21 } |
21 | 22 |
22 SerialDeviceEnumeratorWin::SerialDeviceEnumeratorWin() {} | 23 SerialDeviceEnumeratorWin::SerialDeviceEnumeratorWin() {} |
23 | 24 |
24 SerialDeviceEnumeratorWin::~SerialDeviceEnumeratorWin() {} | 25 SerialDeviceEnumeratorWin::~SerialDeviceEnumeratorWin() {} |
25 | 26 |
26 // TODO(rockot): Query the system for more information than just device paths. | 27 // TODO(rockot): Query the system for more information than just device paths. |
27 // This may or may not require using a different strategy than scanning the | 28 // This may or may not require using a different strategy than scanning the |
28 // registry location below. | 29 // registry location below. |
29 void SerialDeviceEnumeratorWin::GetDevices(SerialDeviceInfoList* devices) { | 30 void SerialDeviceEnumeratorWin::GetDevices(SerialDeviceInfoList* devices) { |
30 devices->clear(); | 31 devices->clear(); |
31 | 32 |
32 base::win::RegistryValueIterator iter_key( | 33 base::win::RegistryValueIterator iter_key( |
33 HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM\\"); | 34 HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM\\"); |
34 for (; iter_key.Valid(); ++iter_key) { | 35 for (; iter_key.Valid(); ++iter_key) { |
35 base::string16 value(iter_key.Value()); | 36 base::string16 value(iter_key.Value()); |
36 linked_ptr<SerialDeviceInfo> info(new SerialDeviceInfo); | 37 linked_ptr<SerialDeviceInfo> info(new SerialDeviceInfo); |
37 info->path = WideToASCII(value); | 38 info->path = base::UTF16ToASCII(value); |
38 devices->push_back(info); | 39 devices->push_back(info); |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 } // namespace device | 43 } // namespace device |
OLD | NEW |