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
3 // found in the LICENSE file.
5 #include "device/serial/serial_device_enumerator_win.h"
9 #include "base/memory/linked_ptr.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "base/win/registry.h"
19 scoped_ptr
<SerialDeviceEnumerator
> SerialDeviceEnumerator::Create() {
20 return scoped_ptr
<SerialDeviceEnumerator
>(new SerialDeviceEnumeratorWin());
23 SerialDeviceEnumeratorWin::SerialDeviceEnumeratorWin() {}
25 SerialDeviceEnumeratorWin::~SerialDeviceEnumeratorWin() {}
27 // TODO(rockot): Query the system for more information than just device paths.
28 // This may or may not require using a different strategy than scanning the
29 // registry location below.
30 void SerialDeviceEnumeratorWin::GetDevices(SerialDeviceInfoList
* devices
) {
33 base::win::RegistryValueIterator
iter_key(
34 HKEY_LOCAL_MACHINE
, L
"HARDWARE\\DEVICEMAP\\SERIALCOMM\\");
35 for (; iter_key
.Valid(); ++iter_key
) {
36 base::string16
value(iter_key
.Value());
37 linked_ptr
<SerialDeviceInfo
> info(new SerialDeviceInfo
);
38 info
->path
= base::UTF16ToASCII(value
);
39 devices
->push_back(info
);