OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/android/usb_chooser_dialog_android.h" | 5 #include "chrome/browser/ui/android/usb_chooser_dialog_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 bool granted) { | 42 bool granted) { |
43 device::usb::DeviceInfoPtr device_info; | 43 device::usb::DeviceInfoPtr device_info; |
44 if (granted) | 44 if (granted) |
45 device_info = device::usb::DeviceInfo::From(*device); | 45 device_info = device::usb::DeviceInfo::From(*device); |
46 callback.Run(std::move(device_info)); | 46 callback.Run(std::move(device_info)); |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 UsbChooserDialogAndroid::UsbChooserDialogAndroid( | 51 UsbChooserDialogAndroid::UsbChooserDialogAndroid( |
52 std::vector<device::usb::DeviceFilterPtr> filters, | 52 const std::vector<device::UsbDeviceFilter>& filters, |
53 content::RenderFrameHost* render_frame_host, | 53 content::RenderFrameHost* render_frame_host, |
54 const device::usb::ChooserService::GetPermissionCallback& callback) | 54 const device::usb::ChooserService::GetPermissionCallback& callback) |
55 : render_frame_host_(render_frame_host), | 55 : render_frame_host_(render_frame_host), |
56 callback_(callback), | 56 callback_(callback), |
57 usb_service_observer_(this), | 57 usb_service_observer_(this), |
58 filters_(mojo::ConvertTo<std::vector<device::UsbDeviceFilter>>(filters)), | 58 filters_(filters), |
59 weak_factory_(this) { | 59 weak_factory_(this) { |
60 device::UsbService* usb_service = | 60 device::UsbService* usb_service = |
61 device::DeviceClient::Get()->GetUsbService(); | 61 device::DeviceClient::Get()->GetUsbService(); |
62 if (!usb_service) | 62 if (!usb_service) |
63 return; | 63 return; |
64 | 64 |
65 if (!usb_service_observer_.IsObserving(usb_service)) | 65 if (!usb_service_observer_.IsObserving(usb_service)) |
66 usb_service_observer_.Add(usb_service); | 66 usb_service_observer_.Add(usb_service); |
67 | 67 |
68 // Create (and show) the UsbChooser dialog. | 68 // Create (and show) the UsbChooser dialog. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 return device::FindInWebUsbAllowedOrigins( | 237 return device::FindInWebUsbAllowedOrigins( |
238 device->webusb_allowed_origins(), | 238 device->webusb_allowed_origins(), |
239 render_frame_host_->GetLastCommittedURL().GetOrigin()); | 239 render_frame_host_->GetLastCommittedURL().GetOrigin()); |
240 } | 240 } |
241 | 241 |
242 // static | 242 // static |
243 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { | 243 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { |
244 return RegisterNativesImpl(env); | 244 return RegisterNativesImpl(env); |
245 } | 245 } |
OLD | NEW |