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

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

Issue 1710443002: bluetooth: Add URLs for Web Bluetooth help links. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Cleanup #2 Created 4 years, 10 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 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 "chrome/common/url_constants.h"
12 #include "content/public/browser/android/content_view_core.h" 13 #include "content/public/browser/android/content_view_core.h"
13 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
14 #include "jni/BluetoothChooserDialog_jni.h" 15 #include "jni/BluetoothChooserDialog_jni.h"
15 #include "ui/android/window_android.h" 16 #include "ui/android/window_android.h"
16 #include "url/origin.h" 17 #include "url/origin.h"
17 18
18 using base::android::AttachCurrentThread; 19 using base::android::AttachCurrentThread;
19 using base::android::ConvertUTF8ToJavaString; 20 using base::android::ConvertUTF8ToJavaString;
20 using base::android::ConvertUTF16ToJavaString; 21 using base::android::ConvertUTF16ToJavaString;
21 using base::android::ScopedJavaLocalRef; 22 using base::android::ScopedJavaLocalRef;
22 23
23 BluetoothChooserAndroid::BluetoothChooserAndroid( 24 BluetoothChooserAndroid::BluetoothChooserAndroid(
24 content::RenderFrameHost* frame, 25 content::RenderFrameHost* frame,
25 const EventHandler& event_handler) 26 const EventHandler& event_handler)
26 : event_handler_(event_handler) { 27 : event_handler_(event_handler) {
28 web_contents_ = content::WebContents::FromRenderFrameHost(frame);
Jeffrey Yasskin 2016/02/18 02:17:24 Use the constructor-initializer-list for this.
ortuno 2016/02/18 18:26:33 Done.
29
27 const url::Origin origin = frame->GetLastCommittedOrigin(); 30 const url::Origin origin = frame->GetLastCommittedOrigin();
28 DCHECK(!origin.unique()); 31 DCHECK(!origin.unique());
29 content::WebContents* web_contents = 32
30 content::WebContents::FromRenderFrameHost(frame);
31 base::android::ScopedJavaLocalRef<jobject> window_android = 33 base::android::ScopedJavaLocalRef<jobject> window_android =
32 content::ContentViewCore::FromWebContents( 34 content::ContentViewCore::FromWebContents(web_contents_)
33 web_contents)->GetWindowAndroid()->GetJavaObject(); 35 ->GetWindowAndroid()
36 ->GetJavaObject();
34 37
35 ChromeSecurityStateModelClient* security_model_client = 38 ChromeSecurityStateModelClient* security_model_client =
36 ChromeSecurityStateModelClient::FromWebContents(web_contents); 39 ChromeSecurityStateModelClient::FromWebContents(web_contents_);
37 DCHECK(security_model_client); 40 DCHECK(security_model_client);
38 41
39 // Create (and show) the BluetoothChooser dialog. 42 // Create (and show) the BluetoothChooser dialog.
40 JNIEnv* env = AttachCurrentThread(); 43 JNIEnv* env = AttachCurrentThread();
41 ScopedJavaLocalRef<jstring> origin_string = 44 ScopedJavaLocalRef<jstring> origin_string =
42 ConvertUTF8ToJavaString(env, origin.Serialize()); 45 ConvertUTF8ToJavaString(env, origin.Serialize());
43 java_dialog_.Reset(Java_BluetoothChooserDialog_create( 46 java_dialog_.Reset(Java_BluetoothChooserDialog_create(
44 env, window_android.obj(), origin_string.obj(), 47 env, window_android.obj(), origin_string.obj(),
45 security_model_client->GetSecurityInfo().security_level, 48 security_model_client->GetSecurityInfo().security_level,
46 reinterpret_cast<intptr_t>(this))); 49 reinterpret_cast<intptr_t>(this)));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 129 }
127 130
128 void BluetoothChooserAndroid::RestartSearch(JNIEnv* env, 131 void BluetoothChooserAndroid::RestartSearch(JNIEnv* env,
129 const JavaParamRef<jobject>& obj) { 132 const JavaParamRef<jobject>& obj) {
130 event_handler_.Run(Event::RESCAN, ""); 133 event_handler_.Run(Event::RESCAN, "");
131 } 134 }
132 135
133 void BluetoothChooserAndroid::ShowBluetoothOverviewLink( 136 void BluetoothChooserAndroid::ShowBluetoothOverviewLink(
134 JNIEnv* env, 137 JNIEnv* env,
135 const JavaParamRef<jobject>& obj) { 138 const JavaParamRef<jobject>& obj) {
139 OpenURL(chrome::kChooserBluetoothOverviewURL);
136 event_handler_.Run(Event::SHOW_OVERVIEW_HELP, ""); 140 event_handler_.Run(Event::SHOW_OVERVIEW_HELP, "");
137 } 141 }
138 142
139 void BluetoothChooserAndroid::ShowBluetoothPairingLink(
140 JNIEnv* env,
141 const JavaParamRef<jobject>& obj) {
142 event_handler_.Run(Event::SHOW_PAIRING_HELP, "");
143 }
144
145 void BluetoothChooserAndroid::ShowBluetoothAdapterOffLink( 143 void BluetoothChooserAndroid::ShowBluetoothAdapterOffLink(
146 JNIEnv* env, 144 JNIEnv* env,
147 const JavaParamRef<jobject>& obj) { 145 const JavaParamRef<jobject>& obj) {
146 OpenURL(chrome::kChooserBluetoothOverviewURL);
148 event_handler_.Run(Event::SHOW_ADAPTER_OFF_HELP, ""); 147 event_handler_.Run(Event::SHOW_ADAPTER_OFF_HELP, "");
149 } 148 }
150 149
151 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink( 150 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink(
152 JNIEnv* env, 151 JNIEnv* env,
153 const JavaParamRef<jobject>& obj) { 152 const JavaParamRef<jobject>& obj) {
153 OpenURL(chrome::kChooserBluetoothOverviewURL);
154 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, ""); 154 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, "");
155 } 155 }
156 156
157 // static 157 // static
158 bool BluetoothChooserAndroid::Register(JNIEnv* env) { 158 bool BluetoothChooserAndroid::Register(JNIEnv* env) {
159 return RegisterNativesImpl(env); 159 return RegisterNativesImpl(env);
160 } 160 }
161
162 void BluetoothChooserAndroid::OpenURL(const char url[]) {
Jeffrey Yasskin 2016/02/18 02:17:24 "const char*" here too (mentioning it because chan
ortuno 2016/02/18 18:26:33 Done.
163 web_contents_->OpenURL(content::OpenURLParams(
164 GURL(url), content::Referrer(), NEW_FOREGROUND_TAB,
165 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false /* is_renderer_initiated */));
166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698