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

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

Issue 1601323002: Use GetLastCommittedOrigin instead of GetLastCommittedURL in bluetooth chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use GetLastCommittedOrigin instead of GetLastCommittedURL Created 4 years, 11 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
« no previous file with comments | « chrome/browser/ui/android/bluetooth_chooser_android.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/android/bluetooth_chooser_android.h" 5 #include "chrome/browser/ui/android/bluetooth_chooser_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ssl/chrome_security_state_model_client.h" 10 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
11 #include "chrome/browser/ui/android/view_android_helper.h" 11 #include "chrome/browser/ui/android/view_android_helper.h"
12 #include "content/public/browser/android/content_view_core.h" 12 #include "content/public/browser/android/content_view_core.h"
13 #include "jni/BluetoothChooserDialog_jni.h" 13 #include "jni/BluetoothChooserDialog_jni.h"
14 #include "ui/android/window_android.h" 14 #include "ui/android/window_android.h"
15 #include "url/origin.h"
15 16
16 using base::android::AttachCurrentThread; 17 using base::android::AttachCurrentThread;
17 using base::android::ConvertUTF8ToJavaString; 18 using base::android::ConvertUTF8ToJavaString;
18 using base::android::ConvertUTF16ToJavaString; 19 using base::android::ConvertUTF16ToJavaString;
19 using base::android::ScopedJavaLocalRef; 20 using base::android::ScopedJavaLocalRef;
20 21
21 BluetoothChooserAndroid::BluetoothChooserAndroid( 22 BluetoothChooserAndroid::BluetoothChooserAndroid(
22 content::WebContents* web_contents, 23 content::WebContents* web_contents,
23 const EventHandler& event_handler, 24 const EventHandler& event_handler,
24 const GURL& origin) 25 const url::Origin& origin)
25 : event_handler_(event_handler) { 26 : event_handler_(event_handler) {
26 base::android::ScopedJavaLocalRef<jobject> window_android = 27 base::android::ScopedJavaLocalRef<jobject> window_android =
27 content::ContentViewCore::FromWebContents( 28 content::ContentViewCore::FromWebContents(
28 web_contents)->GetWindowAndroid()->GetJavaObject(); 29 web_contents)->GetWindowAndroid()->GetJavaObject();
29 30
30 ChromeSecurityStateModelClient* security_model_client = 31 ChromeSecurityStateModelClient* security_model_client =
31 ChromeSecurityStateModelClient::FromWebContents(web_contents); 32 ChromeSecurityStateModelClient::FromWebContents(web_contents);
32 DCHECK(security_model_client); 33 DCHECK(security_model_client);
33 34
34 // Create (and show) the BluetoothChooser dialog. 35 // Create (and show) the BluetoothChooser dialog.
35 JNIEnv* env = AttachCurrentThread(); 36 JNIEnv* env = AttachCurrentThread();
36 ScopedJavaLocalRef<jstring> origin_string = 37 ScopedJavaLocalRef<jstring> origin_string =
37 ConvertUTF8ToJavaString(env, origin.spec()); 38 ConvertUTF8ToJavaString(env, origin.Serialize());
ncarter (slow) 2016/01/20 20:59:44 What if the origin is unique? Do we still want to
Jeffrey Yasskin 2016/01/20 21:29:58 Good point. We don't want to show the user the str
ncarter (slow) 2016/01/20 22:00:20 Thanks for the spec link, that was good reading.
juncai 2016/01/21 17:47:42 Done.
38 java_dialog_.Reset(Java_BluetoothChooserDialog_create( 39 java_dialog_.Reset(Java_BluetoothChooserDialog_create(
39 env, window_android.obj(), origin_string.obj(), 40 env, window_android.obj(), origin_string.obj(),
40 security_model_client->GetSecurityInfo().security_level, 41 security_model_client->GetSecurityInfo().security_level,
41 reinterpret_cast<intptr_t>(this))); 42 reinterpret_cast<intptr_t>(this)));
42 } 43 }
43 44
44 BluetoothChooserAndroid::~BluetoothChooserAndroid() { 45 BluetoothChooserAndroid::~BluetoothChooserAndroid() {
45 if (!java_dialog_.is_null()) { 46 if (!java_dialog_.is_null()) {
46 Java_BluetoothChooserDialog_closeDialog(AttachCurrentThread(), 47 Java_BluetoothChooserDialog_closeDialog(AttachCurrentThread(),
47 java_dialog_.obj()); 48 java_dialog_.obj());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink( 147 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink(
147 JNIEnv* env, 148 JNIEnv* env,
148 const JavaParamRef<jobject>& obj) { 149 const JavaParamRef<jobject>& obj) {
149 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, ""); 150 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, "");
150 } 151 }
151 152
152 // static 153 // static
153 bool BluetoothChooserAndroid::Register(JNIEnv* env) { 154 bool BluetoothChooserAndroid::Register(JNIEnv* env) {
154 return RegisterNativesImpl(env); 155 return RegisterNativesImpl(env);
155 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/bluetooth_chooser_android.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698