Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: chrome/browser/ui/android/usb_chooser_dialog_android.cc

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Profile* profile = 129 Profile* profile =
130 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 130 Profile::FromBrowserContext(web_contents->GetBrowserContext());
131 UsbChooserContext* chooser_context = 131 UsbChooserContext* chooser_context =
132 UsbChooserContextFactory::GetForProfile(profile); 132 UsbChooserContextFactory::GetForProfile(profile);
133 chooser_context->GrantDevicePermission( 133 chooser_context->GrantDevicePermission(
134 render_frame_host_->GetLastCommittedURL().GetOrigin(), 134 render_frame_host_->GetLastCommittedURL().GetOrigin(),
135 embedding_origin, device->guid()); 135 embedding_origin, device->guid());
136 136
137 device->RequestPermission( 137 device->RequestPermission(
138 base::Bind(&OnDevicePermissionRequestComplete, device, callback_)); 138 base::Bind(&OnDevicePermissionRequestComplete, device, callback_));
139 callback_.reset(); // Reset |callback_| so that it is only run once. 139 callback_.Reset(); // Reset |callback_| so that it is only run once.
140 140
141 Java_UsbChooserDialog_closeDialog(base::android::AttachCurrentThread(), 141 Java_UsbChooserDialog_closeDialog(base::android::AttachCurrentThread(),
142 java_dialog_.obj()); 142 java_dialog_.obj());
143 RecordWebUsbChooserClosure( 143 RecordWebUsbChooserClosure(
144 device->serial_number().empty() 144 device->serial_number().empty()
145 ? WEBUSB_CHOOSER_CLOSED_EPHEMERAL_PERMISSION_GRANTED 145 ? WEBUSB_CHOOSER_CLOSED_EPHEMERAL_PERMISSION_GRANTED
146 : WEBUSB_CHOOSER_CLOSED_PERMISSION_GRANTED); 146 : WEBUSB_CHOOSER_CLOSED_PERMISSION_GRANTED);
147 return; 147 return;
148 } 148 }
149 } 149 }
150 } 150 }
151 151
152 void UsbChooserDialogAndroid::Cancel() { 152 void UsbChooserDialogAndroid::Cancel() {
153 DCHECK(!callback_.is_null());
153 callback_.Run(nullptr); 154 callback_.Run(nullptr);
154 callback_.reset(); // Reset |callback_| so that it is only run once. 155 callback_.Reset(); // Reset |callback_| so that it is only run once.
155 Java_UsbChooserDialog_closeDialog(base::android::AttachCurrentThread(), 156 Java_UsbChooserDialog_closeDialog(base::android::AttachCurrentThread(),
156 java_dialog_.obj()); 157 java_dialog_.obj());
157 158
158 RecordWebUsbChooserClosure(devices_.size() == 0 159 RecordWebUsbChooserClosure(devices_.size() == 0
159 ? WEBUSB_CHOOSER_CLOSED_CANCELLED_NO_DEVICES 160 ? WEBUSB_CHOOSER_CLOSED_CANCELLED_NO_DEVICES
160 : WEBUSB_CHOOSER_CLOSED_CANCELLED); 161 : WEBUSB_CHOOSER_CLOSED_CANCELLED);
161 } 162 }
162 163
163 void UsbChooserDialogAndroid::OnItemSelected( 164 void UsbChooserDialogAndroid::OnItemSelected(
164 JNIEnv* env, 165 JNIEnv* env,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 239
239 return device::FindInWebUsbAllowedOrigins( 240 return device::FindInWebUsbAllowedOrigins(
240 device->webusb_allowed_origins(), 241 device->webusb_allowed_origins(),
241 render_frame_host_->GetLastCommittedURL().GetOrigin()); 242 render_frame_host_->GetLastCommittedURL().GetOrigin());
242 } 243 }
243 244
244 // static 245 // static
245 bool UsbChooserDialogAndroid::Register(JNIEnv* env) { 246 bool UsbChooserDialogAndroid::Register(JNIEnv* env) {
246 return RegisterNativesImpl(env); 247 return RegisterNativesImpl(env);
247 } 248 }
OLDNEW
« no previous file with comments | « chrome/browser/media/router/mojo/media_router_mojo_impl_unittest.cc ('k') | chrome/browser/usb/usb_chooser_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698