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