summaryrefslogtreecommitdiffstats
path: root/chrome/browser/android/usb/web_usb_chooser_service_android.h
blob: d83345a97de04446cb9797db9c2689cf3591b471 (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
45
46
47
// 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 CHROME_BROWSER_ANDROID_USB_WEB_USB_CHOOSER_SERVICE_ANDROID_H_
#define CHROME_BROWSER_ANDROID_USB_WEB_USB_CHOOSER_SERVICE_ANDROID_H_

#include <vector>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "device/usb/public/interfaces/chooser_service.mojom.h"
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_request.h"

class UsbChooserDialogAndroid;

namespace content {
class RenderFrameHost;
}

// Implementation of the public device::usb::ChooserService interface.
// This interface can be used by a webpage to request permission from user
// to access a certain device.
class WebUsbChooserServiceAndroid : public device::usb::ChooserService {
 public:
  explicit WebUsbChooserServiceAndroid(
      content::RenderFrameHost* render_frame_host);

  ~WebUsbChooserServiceAndroid() override;

  // device::usb::ChooserService:
  void GetPermission(mojo::Array<device::usb::DeviceFilterPtr> device_filters,
                     const GetPermissionCallback& callback) override;

  void Bind(mojo::InterfaceRequest<device::usb::ChooserService> request);

 private:
  content::RenderFrameHost* const render_frame_host_;
  mojo::BindingSet<device::usb::ChooserService> bindings_;
  std::vector<scoped_ptr<UsbChooserDialogAndroid>> usb_chooser_dialog_android_;

  DISALLOW_COPY_AND_ASSIGN(WebUsbChooserServiceAndroid);
};

#endif  // CHROME_BROWSER_ANDROID_USB_WEB_USB_CHOOSER_SERVICE_ANDROID_H_