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

Side by Side Diff: android_webview/native/aw_contents_client_bridge.cc

Issue 330143002: Simplify geolocation permission request in the Content API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "android_webview/native/aw_contents_client_bridge.h" 5 #include "android_webview/native/aw_contents_client_bridge.h"
6 6
7 #include "android_webview/common/devtools_instrumentation.h" 7 #include "android_webview/common/devtools_instrumentation.h"
8 #include "android_webview/native/aw_contents.h"
8 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
9 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
10 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
11 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h"
13 #include "jni/AwContentsClientBridge_jni.h" 17 #include "jni/AwContentsClientBridge_jni.h"
14 #include "net/android/keystore_openssl.h" 18 #include "net/android/keystore_openssl.h"
15 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
16 #include "net/ssl/openssl_client_key_store.h" 20 #include "net/ssl/openssl_client_key_store.h"
17 #include "net/ssl/ssl_cert_request_info.h" 21 #include "net/ssl/ssl_cert_request_info.h"
18 #include "net/ssl/ssl_client_cert_type.h" 22 #include "net/ssl/ssl_client_cert_type.h"
19 #include "url/gurl.h" 23 #include "url/gurl.h"
20 24
21 using base::android::AttachCurrentThread; 25 using base::android::AttachCurrentThread;
22 using base::android::ConvertJavaStringToUTF16; 26 using base::android::ConvertJavaStringToUTF16;
(...skipping 12 matching lines...) Expand all
35 // Must be called on the I/O thread to record a client certificate 39 // Must be called on the I/O thread to record a client certificate
36 // and its private key in the OpenSSLClientKeyStore. 40 // and its private key in the OpenSSLClientKeyStore.
37 void RecordClientCertificateKey( 41 void RecordClientCertificateKey(
38 const scoped_refptr<net::X509Certificate>& client_cert, 42 const scoped_refptr<net::X509Certificate>& client_cert,
39 ScopedEVP_PKEY private_key) { 43 ScopedEVP_PKEY private_key) {
40 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 44 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
41 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey( 45 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey(
42 client_cert.get(), private_key.get()); 46 client_cert.get(), private_key.get());
43 } 47 }
44 48
49 void CancelGeolocationPermission(int render_process_id,
50 int render_view_id,
51 const GURL& requesting_frame) {
52 AwContents* aw_contents = AwContents::FromID(
53 render_process_id, render_view_id);
54 if (aw_contents)
55 aw_contents->HideGeolocationPrompt(requesting_frame);
56 }
57
45 } // namespace 58 } // namespace
46 59
47 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, jobject obj) 60 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, jobject obj)
48 : java_ref_(env, obj) { 61 : java_ref_(env, obj) {
49 DCHECK(obj); 62 DCHECK(obj);
50 Java_AwContentsClientBridge_setNativeContentsClientBridge( 63 Java_AwContentsClientBridge_setNativeContentsClientBridge(
51 env, obj, reinterpret_cast<intptr_t>(this)); 64 env, obj, reinterpret_cast<intptr_t>(this));
52 } 65 }
53 66
54 AwContentsClientBridge::~AwContentsClientBridge() { 67 AwContentsClientBridge::~AwContentsClientBridge() {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (obj.is_null()) 342 if (obj.is_null())
330 return false; 343 return false;
331 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url); 344 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url);
332 devtools_instrumentation::ScopedEmbedderCallbackTask( 345 devtools_instrumentation::ScopedEmbedderCallbackTask(
333 "shouldOverrideUrlLoading"); 346 "shouldOverrideUrlLoading");
334 return Java_AwContentsClientBridge_shouldOverrideUrlLoading( 347 return Java_AwContentsClientBridge_shouldOverrideUrlLoading(
335 env, obj.obj(), 348 env, obj.obj(),
336 jurl.obj()); 349 jurl.obj());
337 } 350 }
338 351
352 void AwContentsClientBridge::RequestGeolocationPermission(
353 content::WebContents* web_contents,
354 const GURL& requesting_frame,
355 base::Callback<void(bool)> result_callback,
356 base::Closure* cancel_callback) {
357 AwContents* aw_contents = AwContents::FromWebContents(web_contents);
358 if (!aw_contents) {
359 result_callback.Run(false);
360 return;
361 }
362
363 if (cancel_callback) {
364 *cancel_callback = base::Bind(
365 CancelGeolocationPermission,
366 web_contents->GetRenderProcessHost()->GetID(),
367 web_contents->GetRenderViewHost()->GetRoutingID(),
368 requesting_frame);
369 }
370
371 aw_contents->ShowGeolocationPrompt(requesting_frame, result_callback);
372 }
373
339 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, 374 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env,
340 jobject, 375 jobject,
341 int id, 376 int id,
342 jstring prompt) { 377 jstring prompt) {
343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
344 content::JavaScriptDialogManager::DialogClosedCallback* callback = 379 content::JavaScriptDialogManager::DialogClosedCallback* callback =
345 pending_js_dialog_callbacks_.Lookup(id); 380 pending_js_dialog_callbacks_.Lookup(id);
346 if (!callback) { 381 if (!callback) {
347 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; 382 LOG(WARNING) << "Unexpected JS dialog confirm. " << id;
348 return; 383 return;
(...skipping 25 matching lines...) Expand all
374 pending_client_cert_request_callbacks_.Lookup(request_id); 409 pending_client_cert_request_callbacks_.Lookup(request_id);
375 callback->Run(scoped_refptr<net::X509Certificate>()); 410 callback->Run(scoped_refptr<net::X509Certificate>());
376 pending_client_cert_request_callbacks_.Remove(request_id); 411 pending_client_cert_request_callbacks_.Remove(request_id);
377 } 412 }
378 413
379 bool RegisterAwContentsClientBridge(JNIEnv* env) { 414 bool RegisterAwContentsClientBridge(JNIEnv* env) {
380 return RegisterNativesImpl(env); 415 return RegisterNativesImpl(env);
381 } 416 }
382 417
383 } // namespace android_webview 418 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents_client_bridge.h ('k') | android_webview/native/aw_geolocation_permission_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698