| 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/usb/usb_service_impl.h" | 5 #include "device/usb/usb_service_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "components/device_event_log/device_event_log.h" | 23 #include "components/device_event_log/device_event_log.h" |
| 24 #include "device/usb/usb_device_handle.h" | 24 #include "device/usb/usb_device_handle.h" |
| 25 #include "device/usb/usb_error.h" | 25 #include "device/usb/usb_error.h" |
| 26 #include "device/usb/webusb_descriptors.h" | 26 #include "device/usb/webusb_descriptors.h" |
| 27 #include "net/base/io_buffer.h" | 27 #include "net/base/io_buffer.h" |
| 28 #include "third_party/libusb/src/libusb/libusb.h" | 28 #include "third_party/libusb/src/libusb/libusb.h" |
| 29 | 29 |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 #define INITGUID |
| 32 #include <devpkey.h> |
| 31 #include <setupapi.h> | 33 #include <setupapi.h> |
| 32 #include <usbiodef.h> | 34 #include <usbiodef.h> |
| 33 | 35 |
| 34 #include "base/strings/string_util.h" | 36 #include "base/strings/string_util.h" |
| 35 #include "device/base/device_info_query_win.h" | 37 #include "device/base/device_info_query_win.h" |
| 36 #endif // OS_WIN | 38 #endif // OS_WIN |
| 37 | 39 |
| 38 using net::IOBufferWithSize; | 40 using net::IOBufferWithSize; |
| 39 | 41 |
| 40 namespace device { | 42 namespace device { |
| 41 | 43 |
| 42 namespace { | 44 namespace { |
| 43 | 45 |
| 44 // Standard USB requests and descriptor types: | 46 // Standard USB requests and descriptor types: |
| 45 const uint16_t kUsbVersion2_1 = 0x0210; | 47 const uint16_t kUsbVersion2_1 = 0x0210; |
| 46 | 48 |
| 47 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 48 | 50 |
| 49 bool IsWinUsbInterface(const std::string& device_path) { | 51 bool IsWinUsbInterface(const std::string& device_path) { |
| 50 DeviceInfoQueryWin device_info_query; | 52 DeviceInfoQueryWin device_info_query; |
| 51 if (!device_info_query.device_info_list_valid()) { | 53 if (!device_info_query.device_info_list_valid()) { |
| 52 USB_PLOG(ERROR) << "Failed to create a device information set"; | 54 USB_PLOG(ERROR) << "Failed to create a device information set"; |
| 53 return false; | 55 return false; |
| 54 } | 56 } |
| 55 | 57 |
| 56 // This will add the device so we can query driver info. | 58 // This will add the device so we can query driver info. |
| 57 if (!device_info_query.AddDevice(device_path.c_str())) { | 59 if (!device_info_query.AddDevice(device_path)) { |
| 58 USB_PLOG(ERROR) << "Failed to get device interface data for " | 60 USB_PLOG(ERROR) << "Failed to get device interface data for " |
| 59 << device_path; | 61 << device_path; |
| 60 return false; | 62 return false; |
| 61 } | 63 } |
| 62 | 64 |
| 63 if (!device_info_query.GetDeviceInfo()) { | 65 if (!device_info_query.GetDeviceInfo()) { |
| 64 USB_PLOG(ERROR) << "Failed to get device info for " << device_path; | 66 USB_PLOG(ERROR) << "Failed to get device info for " << device_path; |
| 65 return false; | 67 return false; |
| 66 } | 68 } |
| 67 | 69 |
| 68 std::string buffer; | 70 std::string buffer; |
| 69 if (!device_info_query.GetDeviceStringProperty(SPDRP_SERVICE, &buffer)) { | 71 if (!device_info_query.GetDeviceStringProperty(DEVPKEY_Device_Service, |
| 72 &buffer)) { |
| 70 USB_PLOG(ERROR) << "Failed to get device service property"; | 73 USB_PLOG(ERROR) << "Failed to get device service property"; |
| 71 return false; | 74 return false; |
| 72 } | 75 } |
| 73 | 76 |
| 74 USB_LOG(DEBUG) << "Driver for " << device_path << " is " << buffer << "."; | 77 USB_LOG(DEBUG) << "Driver for " << device_path << " is " << buffer << "."; |
| 75 if (base::StartsWith(buffer, "WinUSB", base::CompareCase::INSENSITIVE_ASCII)) | 78 if (base::StartsWith(buffer, "WinUSB", base::CompareCase::INSENSITIVE_ASCII)) |
| 76 return true; | 79 return true; |
| 77 return false; | 80 return false; |
| 78 } | 81 } |
| 79 | 82 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 551 } |
| 549 | 552 |
| 550 void UsbServiceImpl::EnumerationFailed(PlatformUsbDevice platform_device, | 553 void UsbServiceImpl::EnumerationFailed(PlatformUsbDevice platform_device, |
| 551 const base::Closure& refresh_complete) { | 554 const base::Closure& refresh_complete) { |
| 552 libusb_ref_device(platform_device); | 555 libusb_ref_device(platform_device); |
| 553 ignored_devices_.insert(platform_device); | 556 ignored_devices_.insert(platform_device); |
| 554 refresh_complete.Run(); | 557 refresh_complete.Run(); |
| 555 } | 558 } |
| 556 | 559 |
| 557 } // namespace device | 560 } // namespace device |
| OLD | NEW |