| 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 <devguid.h> | 7 #include <devguid.h> |
| 8 #include <setupapi.h> | 8 #include <setupapi.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 !GetCOMPort(friendly_name, &com_port)) | 106 !GetCOMPort(friendly_name, &com_port)) |
| 107 // In Windows, the COM port is the path used to uniquely identify the | 107 // In Windows, the COM port is the path used to uniquely identify the |
| 108 // serial device. If the COM can't be found, ignore the device. | 108 // serial device. If the COM can't be found, ignore the device. |
| 109 continue; | 109 continue; |
| 110 | 110 |
| 111 serial::DeviceInfoPtr info(serial::DeviceInfo::New()); | 111 serial::DeviceInfoPtr info(serial::DeviceInfo::New()); |
| 112 info->path = com_port; | 112 info->path = com_port; |
| 113 | 113 |
| 114 std::string display_name; | 114 std::string display_name; |
| 115 if (GetDisplayName(friendly_name, &display_name)) | 115 if (GetDisplayName(friendly_name, &display_name)) |
| 116 info->display_name = display_name; | 116 info->display_name = std::move(display_name); |
| 117 | 117 |
| 118 std::string hardware_id; | 118 std::string hardware_id; |
| 119 // SPDRP_HARDWAREID looks like "FTDIBUS\COMPORT&VID_0403&PID_6001". | 119 // SPDRP_HARDWAREID looks like "FTDIBUS\COMPORT&VID_0403&PID_6001". |
| 120 if (GetProperty(dev_info, dev_info_data, SPDRP_HARDWAREID, &hardware_id)) { | 120 if (GetProperty(dev_info, dev_info_data, SPDRP_HARDWAREID, &hardware_id)) { |
| 121 uint32_t vendor_id, product_id; | 121 uint32_t vendor_id, product_id; |
| 122 if (GetVendorID(hardware_id, &vendor_id)) { | 122 if (GetVendorID(hardware_id, &vendor_id)) { |
| 123 info->has_vendor_id = true; | 123 info->has_vendor_id = true; |
| 124 info->vendor_id = vendor_id; | 124 info->vendor_id = vendor_id; |
| 125 } | 125 } |
| 126 if (GetProductID(hardware_id, &product_id)) { | 126 if (GetProductID(hardware_id, &product_id)) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 | 186 |
| 187 mojo::Array<mojo::String> paths; | 187 mojo::Array<mojo::String> paths; |
| 188 mojo::Array<serial::DeviceInfoPtr> devices; | 188 mojo::Array<serial::DeviceInfoPtr> devices; |
| 189 deviceMap.DecomposeMapTo(&paths, &devices); | 189 deviceMap.DecomposeMapTo(&paths, &devices); |
| 190 | 190 |
| 191 return devices; | 191 return devices; |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace device | 194 } // namespace device |
| OLD | NEW |