| 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 "chrome/browser/chrome_device_client.h" | 5 #include "chrome/browser/chrome_device_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "device/hid/hid_service.h" | 9 #include "device/hid/hid_service.h" |
| 10 #include "device/usb/public/cpp/device_manager_delegate.h" |
| 11 #include "device/usb/public/cpp/device_manager_factory.h" |
| 12 #include "device/usb/public/interfaces/device.mojom.h" |
| 10 #include "device/usb/usb_service.h" | 13 #include "device/usb/usb_service.h" |
| 11 | 14 |
| 12 using content::BrowserThread; | 15 using content::BrowserThread; |
| 13 | 16 |
| 17 namespace { |
| 18 |
| 19 // DeviceManagerDelegate implementation which allows access to all devices. |
| 20 class BrowserDeviceManagerDelegate : public device::usb::DeviceManagerDelegate { |
| 21 public: |
| 22 BrowserDeviceManagerDelegate() {} |
| 23 ~BrowserDeviceManagerDelegate() override {} |
| 24 |
| 25 private: |
| 26 bool IsDeviceAllowed(const device::usb::DeviceInfo& device) override { |
| 27 return true; |
| 28 } |
| 29 }; |
| 30 |
| 31 } // namespace |
| 32 |
| 14 ChromeDeviceClient::ChromeDeviceClient() {} | 33 ChromeDeviceClient::ChromeDeviceClient() {} |
| 15 | 34 |
| 16 ChromeDeviceClient::~ChromeDeviceClient() {} | 35 ChromeDeviceClient::~ChromeDeviceClient() {} |
| 17 | 36 |
| 18 device::UsbService* ChromeDeviceClient::GetUsbService() { | 37 device::UsbService* ChromeDeviceClient::GetUsbService() { |
| 19 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 38 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 20 return device::UsbService::GetInstance( | 39 return device::UsbService::GetInstance( |
| 21 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 40 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 22 } | 41 } |
| 23 | 42 |
| 43 void ChromeDeviceClient::ConnectToUSBDeviceManager( |
| 44 mojo::InterfaceRequest<device::usb::DeviceManager> request) { |
| 45 device::usb::DeviceManagerFactory::Build( |
| 46 request.Pass(), |
| 47 scoped_ptr<device::usb::DeviceManagerDelegate>( |
| 48 new BrowserDeviceManagerDelegate)); |
| 49 } |
| 50 |
| 24 device::HidService* ChromeDeviceClient::GetHidService() { | 51 device::HidService* ChromeDeviceClient::GetHidService() { |
| 25 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 52 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 26 return device::HidService::GetInstance( | 53 return device::HidService::GetInstance( |
| 27 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 54 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 28 } | 55 } |
| OLD | NEW |