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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 content::WebContents::FromRenderFrameHost(render_frame_host_) | 218 content::WebContents::FromRenderFrameHost(render_frame_host_) |
219 ->OpenURL( | 219 ->OpenURL( |
220 content::OpenURLParams(GURL(url), content::Referrer(), | 220 content::OpenURLParams(GURL(url), content::Referrer(), |
221 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 221 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
222 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 222 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
223 false)); // is_renderer_initiated | 223 false)); // is_renderer_initiated |
224 } | 224 } |
225 | 225 |
226 bool UsbChooserDialogAndroid::DisplayDevice( | 226 bool UsbChooserDialogAndroid::DisplayDevice( |
227 scoped_refptr<UsbDevice> device) const { | 227 scoped_refptr<UsbDevice> device) const { |
228 if (!device::UsbDeviceFilter::MatchesAny(device, filters_)) | 228 if (!device::UsbDeviceFilter::MatchesAny(*device, filters_)) |
229 return false; | 229 return false; |
230 | 230 |
231 // On Android it is not possible to read the WebUSB descriptors until Chrome | 231 // On Android it is not possible to read the WebUSB descriptors until Chrome |
232 // has been granted permission to open it. Instead we must list all devices | 232 // has been granted permission to open it. Instead we must list all devices |
233 // and perform the allowed origins check after the device has been selected. | 233 // and perform the allowed origins check after the device has been selected. |
234 if (!device->permission_granted()) | 234 if (!device->permission_granted()) |
235 return true; | 235 return true; |
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(), base::nullopt, | 239 render_frame_host_->GetLastCommittedURL().GetOrigin(), base::nullopt, |
240 base::nullopt); | 240 base::nullopt); |
241 } | 241 } |
242 | 242 |
243 // static | 243 // static |
244 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { | 244 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { |
245 return RegisterNativesImpl(env); | 245 return RegisterNativesImpl(env); |
246 } | 246 } |
OLD | NEW |