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
3 // found in the LICENSE file.
5 #include "chrome/browser/chrome_device_client.h"
7 #include "base/logging.h"
8 #include "base/macros.h"
9 #include "content/public/browser/browser_thread.h"
10 #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"
16 using content::BrowserThread
;
20 // DeviceManagerDelegate implementation which allows access to all devices.
21 class BrowserDeviceManagerDelegate
: public device::usb::DeviceManagerDelegate
{
23 BrowserDeviceManagerDelegate() {}
24 ~BrowserDeviceManagerDelegate() override
{}
27 bool IsDeviceAllowed(const device::usb::DeviceInfo
& device
) override
{
31 DISALLOW_COPY_AND_ASSIGN(BrowserDeviceManagerDelegate
);
36 ChromeDeviceClient::ChromeDeviceClient() {}
38 ChromeDeviceClient::~ChromeDeviceClient() {}
40 device::UsbService
* ChromeDeviceClient::GetUsbService() {
41 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
42 return device::UsbService::GetInstance(
43 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
46 void ChromeDeviceClient::ConnectToUSBDeviceManager(
47 mojo::InterfaceRequest
<device::usb::DeviceManager
> request
) {
48 device::usb::DeviceManagerFactory::Build(
50 scoped_ptr
<device::usb::DeviceManagerDelegate
>(
51 new BrowserDeviceManagerDelegate
));
54 device::HidService
* ChromeDeviceClient::GetHidService() {
55 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
56 return device::HidService::GetInstance(
57 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));