OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_ANDROID_USB_CHOOSER_ANDROID_H_ | |
6 #define CHROME_BROWSER_UI_ANDROID_USB_CHOOSER_ANDROID_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/macros.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "base/scoped_observer.h" | |
16 #include "base/strings/string16.h" | |
17 #include "components/webusb/public/interfaces/webusb_permission_bubble.mojom.h" | |
18 #include "device/usb/usb_service.h" | |
19 #include "mojo/public/cpp/bindings/array.h" | |
20 | |
21 namespace content { | |
22 class RenderFrameHost; | |
23 class WebContents; | |
24 } | |
25 | |
26 namespace device { | |
27 class UsbDevice; | |
28 class UsbDeviceFilter; | |
29 } | |
30 | |
31 // Represents a way to ask the user to select a Usb device from a list of | |
Reilly Grant (use Gerrit)
2016/03/03 01:57:56
s/Usb/USB/
juncai
2016/03/04 01:36:39
Done.
| |
32 // options. | |
33 class UsbChooserAndroid : public device::UsbService::Observer { | |
34 public: | |
35 UsbChooserAndroid( | |
36 mojo::Array<device::usb::DeviceFilterPtr> device_filters, | |
37 content::RenderFrameHost* render_frame_host, | |
38 const webusb::WebUsbPermissionBubble::GetPermissionCallback& callback); | |
39 ~UsbChooserAndroid() override; | |
40 | |
41 // device::UsbService::Observer: | |
42 void OnDeviceAdded(scoped_refptr<device::UsbDevice> device) override; | |
43 void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override; | |
44 | |
45 void Select(const std::string& guid); | |
46 void Cancel(); | |
47 | |
48 void GotUsbDeviceList( | |
49 const std::vector<scoped_refptr<device::UsbDevice>>& devices); | |
50 | |
51 // Report the dialog's result. | |
52 void OnDialogFinished(JNIEnv* env, | |
53 const base::android::JavaParamRef<jobject>& obj, | |
54 jint event_type, | |
55 const base::android::JavaParamRef<jstring>& device_id); | |
56 | |
57 void ShowUsbOverviewLink(JNIEnv* env, | |
58 const base::android::JavaParamRef<jobject>& obj); | |
59 | |
60 static bool Register(JNIEnv* env); | |
61 | |
62 private: | |
63 void UpdateChooserDialog() const; | |
64 | |
65 void OpenUrl(const std::string& url); | |
66 | |
67 content::RenderFrameHost* const render_frame_host_; | |
68 content::WebContents* web_contents_; | |
69 webusb::WebUsbPermissionBubble::GetPermissionCallback callback_; | |
70 ScopedObserver<device::UsbService, device::UsbService::Observer> | |
71 usb_service_observer_; | |
72 std::vector<device::UsbDeviceFilter> filters_; | |
73 std::vector<scoped_refptr<device::UsbDevice>> devices_; | |
74 std::vector<std::string> device_guids_; | |
75 std::vector<base::string16> device_names_; | |
76 base::android::ScopedJavaGlobalRef<jobject> java_dialog_; | |
77 base::WeakPtrFactory<UsbChooserAndroid> weak_factory_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(UsbChooserAndroid); | |
80 }; | |
81 | |
82 #endif // CHROME_BROWSER_UI_ANDROID_USB_CHOOSER_ANDROID_H_ | |
OLD | NEW |