summaryrefslogtreecommitdiffstats
path: root/content/renderer/usb/web_usb_client_impl.h
blob: b3b504b9a22c7af1ce55ddc7e6be2441d0b198e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_USB_WEB_USB_CLIENT_IMPL_H_
#define CONTENT_RENDERER_USB_WEB_USB_CLIENT_IMPL_H_

#include "base/macros.h"
#include "device/usb/public/interfaces/chooser_service.mojom.h"
#include "device/usb/public/interfaces/device_manager.mojom.h"
#include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h"

namespace content {

class ServiceRegistry;

class WebUSBClientImpl : public blink::WebUSBClient {
 public:
  explicit WebUSBClientImpl(ServiceRegistry* service_registry);
  ~WebUSBClientImpl() override;

 private:
  // blink::WebUSBClient implementation:
  void getDevices(blink::WebUSBClientGetDevicesCallbacks* callbacks) override;
  void requestDevice(
      const blink::WebUSBDeviceRequestOptions& options,
      blink::WebUSBClientRequestDeviceCallbacks* callbacks) override;
  void setObserver(Observer* observer) override;

  device::usb::DeviceManager* GetDeviceManager();
  void OnDeviceChangeNotification(
      device::usb::DeviceChangeNotificationPtr notification);

  ServiceRegistry* const service_registry_;
  device::usb::DeviceManagerPtr device_manager_;
  device::usb::ChooserServicePtr chooser_service_;
  Observer* observer_ = nullptr;

  DISALLOW_COPY_AND_ASSIGN(WebUSBClientImpl);
};

}  // namespace content

#endif  // CONTENT_RENDERER_USB_WEB_USB_CLIENT_IMPL_H_