- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / serial / serial_port_enumerator_win.cc
1 // Copyright (c) 2012 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.
4
5 #include "chrome/browser/extensions/api/serial/serial_port_enumerator.h"
6
7 #include <windows.h>
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/win/registry.h"
13
14 namespace extensions {
15
16 SerialPortEnumerator::StringSet
17 SerialPortEnumerator::GenerateValidSerialPortNames() {
18   StringSet name_set;
19
20   base::win::RegistryValueIterator iter_key(HKEY_LOCAL_MACHINE,
21       L"HARDWARE\\DEVICEMAP\\SERIALCOMM\\");
22
23   for (; iter_key.Valid(); ++iter_key) {
24     string16 str(iter_key.Value());
25     std::string device_string(WideToASCII(str));
26     name_set.insert(device_string);
27   }
28   return name_set;
29 }
30
31 }  // namespace extensions