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

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: Address tedchoc's comments 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
« no previous file with comments | « chrome/browser/ui/android/bluetooth_chooser_android.h ('k') | chrome/common/url_constants.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 "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 : web_contents_(content::WebContents::FromRenderFrameHost(frame)),
28 event_handler_(event_handler) {
27 const url::Origin origin = frame->GetLastCommittedOrigin(); 29 const url::Origin origin = frame->GetLastCommittedOrigin();
28 DCHECK(!origin.unique()); 30 DCHECK(!origin.unique());
29 content::WebContents* web_contents = 31
30 content::WebContents::FromRenderFrameHost(frame);
31 base::android::ScopedJavaLocalRef<jobject> window_android = 32 base::android::ScopedJavaLocalRef<jobject> window_android =
32 content::ContentViewCore::FromWebContents( 33 content::ContentViewCore::FromWebContents(web_contents_)
33 web_contents)->GetWindowAndroid()->GetJavaObject(); 34 ->GetWindowAndroid()
35 ->GetJavaObject();
34 36
35 ChromeSecurityStateModelClient* security_model_client = 37 ChromeSecurityStateModelClient* security_model_client =
36 ChromeSecurityStateModelClient::FromWebContents(web_contents); 38 ChromeSecurityStateModelClient::FromWebContents(web_contents_);
37 DCHECK(security_model_client); 39 DCHECK(security_model_client);
38 40
39 // Create (and show) the BluetoothChooser dialog. 41 // Create (and show) the BluetoothChooser dialog.
40 JNIEnv* env = AttachCurrentThread(); 42 JNIEnv* env = AttachCurrentThread();
41 ScopedJavaLocalRef<jstring> origin_string = 43 ScopedJavaLocalRef<jstring> origin_string =
42 ConvertUTF8ToJavaString(env, origin.Serialize()); 44 ConvertUTF8ToJavaString(env, origin.Serialize());
43 java_dialog_.Reset(Java_BluetoothChooserDialog_create( 45 java_dialog_.Reset(Java_BluetoothChooserDialog_create(
44 env, window_android.obj(), origin_string.obj(), 46 env, window_android.obj(), origin_string.obj(),
45 security_model_client->GetSecurityInfo().security_level, 47 security_model_client->GetSecurityInfo().security_level,
46 reinterpret_cast<intptr_t>(this))); 48 reinterpret_cast<intptr_t>(this)));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 128 }
127 129
128 void BluetoothChooserAndroid::RestartSearch(JNIEnv* env, 130 void BluetoothChooserAndroid::RestartSearch(JNIEnv* env,
129 const JavaParamRef<jobject>& obj) { 131 const JavaParamRef<jobject>& obj) {
130 event_handler_.Run(Event::RESCAN, ""); 132 event_handler_.Run(Event::RESCAN, "");
131 } 133 }
132 134
133 void BluetoothChooserAndroid::ShowBluetoothOverviewLink( 135 void BluetoothChooserAndroid::ShowBluetoothOverviewLink(
134 JNIEnv* env, 136 JNIEnv* env,
135 const JavaParamRef<jobject>& obj) { 137 const JavaParamRef<jobject>& obj) {
138 OpenURL(chrome::kChooserBluetoothOverviewURL);
136 event_handler_.Run(Event::SHOW_OVERVIEW_HELP, ""); 139 event_handler_.Run(Event::SHOW_OVERVIEW_HELP, "");
137 } 140 }
138 141
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( 142 void BluetoothChooserAndroid::ShowBluetoothAdapterOffLink(
146 JNIEnv* env, 143 JNIEnv* env,
147 const JavaParamRef<jobject>& obj) { 144 const JavaParamRef<jobject>& obj) {
145 OpenURL(chrome::kChooserBluetoothOverviewURL);
148 event_handler_.Run(Event::SHOW_ADAPTER_OFF_HELP, ""); 146 event_handler_.Run(Event::SHOW_ADAPTER_OFF_HELP, "");
149 } 147 }
150 148
151 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink( 149 void BluetoothChooserAndroid::ShowNeedLocationPermissionLink(
152 JNIEnv* env, 150 JNIEnv* env,
153 const JavaParamRef<jobject>& obj) { 151 const JavaParamRef<jobject>& obj) {
152 OpenURL(chrome::kChooserBluetoothOverviewURL);
154 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, ""); 153 event_handler_.Run(Event::SHOW_NEED_LOCATION_HELP, "");
155 } 154 }
156 155
157 // static 156 // static
158 bool BluetoothChooserAndroid::Register(JNIEnv* env) { 157 bool BluetoothChooserAndroid::Register(JNIEnv* env) {
159 return RegisterNativesImpl(env); 158 return RegisterNativesImpl(env);
160 } 159 }
160
161 void BluetoothChooserAndroid::OpenURL(const char* url) {
162 web_contents_->OpenURL(content::OpenURLParams(
163 GURL(url), content::Referrer(), NEW_FOREGROUND_TAB,
164 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false /* is_renderer_initiated */));
165 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/bluetooth_chooser_android.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698