OLD | NEW |
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 #include "url/origin.h" |
16 | 16 |
17 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
18 using base::android::ConvertUTF8ToJavaString; | 18 using base::android::ConvertUTF8ToJavaString; |
19 using base::android::ConvertUTF16ToJavaString; | 19 using base::android::ConvertUTF16ToJavaString; |
20 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
21 | 21 |
22 BluetoothChooserAndroid::BluetoothChooserAndroid( | 22 BluetoothChooserAndroid::BluetoothChooserAndroid( |
23 content::WebContents* web_contents, | 23 content::RenderFrameHost* frame, |
24 const EventHandler& event_handler, | 24 const EventHandler& event_handler, |
25 const url::Origin& origin) | 25 const url::Origin& origin) |
26 : event_handler_(event_handler) { | 26 : event_handler_(event_handler) { |
27 DCHECK(!origin.unique()); | 27 DCHECK(!origin.unique()); |
| 28 content::WebContents* web_contents = |
| 29 content::WebContents::FromRenderFrameHost(frame); |
28 base::android::ScopedJavaLocalRef<jobject> window_android = | 30 base::android::ScopedJavaLocalRef<jobject> window_android = |
29 content::ContentViewCore::FromWebContents( | 31 content::ContentViewCore::FromWebContents( |
30 web_contents)->GetWindowAndroid()->GetJavaObject(); | 32 web_contents)->GetWindowAndroid()->GetJavaObject(); |
31 | 33 |
32 ChromeSecurityStateModelClient* security_model_client = | 34 ChromeSecurityStateModelClient* security_model_client = |
33 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 35 ChromeSecurityStateModelClient::FromWebContents(web_contents); |
34 DCHECK(security_model_client); | 36 DCHECK(security_model_client); |
35 | 37 |
36 // Create (and show) the BluetoothChooser dialog. | 38 // Create (and show) the BluetoothChooser dialog. |
37 JNIEnv* env = AttachCurrentThread(); | 39 JNIEnv* env = AttachCurrentThread(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink( | 150 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink( |
149 JNIEnv* env, | 151 JNIEnv* env, |
150 const JavaParamRef<jobject>& obj) { | 152 const JavaParamRef<jobject>& obj) { |
151 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, ""); | 153 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, ""); |
152 } | 154 } |
153 | 155 |
154 // static | 156 // static |
155 bool BluetoothChooserAndroid::Register(JNIEnv* env) { | 157 bool BluetoothChooserAndroid::Register(JNIEnv* env) { |
156 return RegisterNativesImpl(env); | 158 return RegisterNativesImpl(env); |
157 } | 159 } |
OLD | NEW |