Chromium Code Reviews| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 void UsbChooserDialogAndroid::OnDialogCancelled( | 159 void UsbChooserDialogAndroid::OnDialogCancelled( |
| 160 JNIEnv* env, | 160 JNIEnv* env, |
| 161 const base::android::JavaParamRef<jobject>& obj) { | 161 const base::android::JavaParamRef<jobject>& obj) { |
| 162 Cancel(); | 162 Cancel(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void UsbChooserDialogAndroid::LoadUsbHelpPage( | 165 void UsbChooserDialogAndroid::LoadUsbHelpPage( |
| 166 JNIEnv* env, | 166 JNIEnv* env, |
| 167 const base::android::JavaParamRef<jobject>& obj) { | 167 const base::android::JavaParamRef<jobject>& obj) { |
| 168 OpenUrl(chrome::kChooserUsbOverviewURL); | 168 OpenUrl(chrome::kChooserUsbOverviewURL); |
| 169 callback_.Run(nullptr); | |
|
Yaron
2016/04/21 21:45:37
Just call |Cancel|?
juncai
2016/04/21 21:55:07
Done.
| |
| 170 callback_.reset(); // Reset |callback_| so that it is only run once. | |
| 171 Java_UsbChooserDialog_closeDialog(base::android::AttachCurrentThread(), | |
| 172 java_dialog_.obj()); | |
| 173 RecordWebUsbChooserClosure(WEBUSB_CHOOSER_CLOSED_CANCELLED); | |
| 169 } | 174 } |
| 170 | 175 |
| 171 // Get a list of devices that can be shown in the chooser bubble UI for | 176 // Get a list of devices that can be shown in the chooser bubble UI for |
| 172 // user to grant permsssion. | 177 // user to grant permsssion. |
| 173 void UsbChooserDialogAndroid::GotUsbDeviceList( | 178 void UsbChooserDialogAndroid::GotUsbDeviceList( |
| 174 const std::vector<scoped_refptr<device::UsbDevice>>& devices) { | 179 const std::vector<scoped_refptr<device::UsbDevice>>& devices) { |
| 175 for (const auto& device : devices) { | 180 for (const auto& device : devices) { |
| 176 if (device::UsbDeviceFilter::MatchesAny(device, filters_) && | 181 if (device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 177 FindInWebUsbAllowedOrigins( | 182 FindInWebUsbAllowedOrigins( |
| 178 device->webusb_allowed_origins(), | 183 device->webusb_allowed_origins(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 ->OpenURL(content::OpenURLParams(GURL(url), content::Referrer(), | 218 ->OpenURL(content::OpenURLParams(GURL(url), content::Referrer(), |
| 214 NEW_FOREGROUND_TAB, | 219 NEW_FOREGROUND_TAB, |
| 215 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 220 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 216 false)); // is_renderer_initiated | 221 false)); // is_renderer_initiated |
| 217 } | 222 } |
| 218 | 223 |
| 219 // static | 224 // static |
| 220 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { | 225 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { |
| 221 return RegisterNativesImpl(env); | 226 return RegisterNativesImpl(env); |
| 222 } | 227 } |
| OLD | NEW |