OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/usb/usb_device_android.h" | 5 #include "device/usb/usb_device_android.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "device/usb/usb_configuration_android.h" | 12 #include "device/usb/usb_configuration_android.h" |
13 #include "device/usb/usb_descriptors.h" | 13 #include "device/usb/usb_descriptors.h" |
14 #include "device/usb/usb_device_handle_android.h" | 14 #include "device/usb/usb_device_handle_android.h" |
15 #include "device/usb/usb_interface_android.h" | 15 #include "device/usb/usb_interface_android.h" |
16 #include "device/usb/usb_service_android.h" | 16 #include "device/usb/usb_service_android.h" |
17 #include "device/usb/webusb_descriptors.h" | 17 #include "device/usb/webusb_descriptors.h" |
18 #include "jni/ChromeUsbDevice_jni.h" | 18 #include "jni/ChromeUsbDevice_jni.h" |
19 | 19 |
20 using base::android::ConvertJavaStringToUTF16; | 20 using base::android::ConvertJavaStringToUTF16; |
21 using base::android::JavaRef; | 21 using base::android::JavaRef; |
22 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
23 | 23 |
24 namespace device { | 24 namespace device { |
25 | 25 |
26 // static | 26 // static |
27 bool UsbDeviceAndroid::RegisterJNI(JNIEnv* env) { | |
28 return RegisterNativesImpl(env); // Generated in ChromeUsbDevice_jni.h | |
29 } | |
30 | |
31 // static | |
32 scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create( | 27 scoped_refptr<UsbDeviceAndroid> UsbDeviceAndroid::Create( |
33 JNIEnv* env, | 28 JNIEnv* env, |
34 base::WeakPtr<UsbServiceAndroid> service, | 29 base::WeakPtr<UsbServiceAndroid> service, |
35 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 30 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
36 const JavaRef<jobject>& usb_device) { | 31 const JavaRef<jobject>& usb_device) { |
37 ScopedJavaLocalRef<jobject> wrapper = | 32 ScopedJavaLocalRef<jobject> wrapper = |
38 Java_ChromeUsbDevice_create(env, usb_device.obj()); | 33 Java_ChromeUsbDevice_create(env, usb_device.obj()); |
39 uint16_t device_version = 0; | 34 uint16_t device_version = 0; |
40 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 23) | 35 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 23) |
41 device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper.obj()); | 36 device_version = Java_ChromeUsbDevice_getDeviceVersion(env, wrapper.obj()); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (allowed_origins) | 203 if (allowed_origins) |
209 webusb_allowed_origins_ = std::move(allowed_origins); | 204 webusb_allowed_origins_ = std::move(allowed_origins); |
210 if (landing_page.is_valid()) | 205 if (landing_page.is_valid()) |
211 webusb_landing_page_ = landing_page; | 206 webusb_landing_page_ = landing_page; |
212 | 207 |
213 device_handle->Close(); | 208 device_handle->Close(); |
214 CallRequestPermissionCallbacks(true); | 209 CallRequestPermissionCallbacks(true); |
215 } | 210 } |
216 | 211 |
217 } // namespace device | 212 } // namespace device |
OLD | NEW |