OLD | NEW |
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 "android_webview/native/aw_contents.h" |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "net/ssl/openssl_client_key_store.h" | 24 #include "net/ssl/openssl_client_key_store.h" |
25 #include "net/ssl/ssl_cert_request_info.h" | 25 #include "net/ssl/ssl_cert_request_info.h" |
26 #include "net/ssl/ssl_client_cert_type.h" | 26 #include "net/ssl/ssl_client_cert_type.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
29 | 29 |
30 using base::android::AttachCurrentThread; | 30 using base::android::AttachCurrentThread; |
31 using base::android::ConvertJavaStringToUTF16; | 31 using base::android::ConvertJavaStringToUTF16; |
32 using base::android::ConvertUTF8ToJavaString; | 32 using base::android::ConvertUTF8ToJavaString; |
33 using base::android::ConvertUTF16ToJavaString; | 33 using base::android::ConvertUTF16ToJavaString; |
| 34 using base::android::HasException; |
34 using base::android::JavaRef; | 35 using base::android::JavaRef; |
35 using base::android::ScopedJavaLocalRef; | 36 using base::android::ScopedJavaLocalRef; |
36 using content::BrowserThread; | 37 using content::BrowserThread; |
37 | 38 |
38 namespace android_webview { | 39 namespace android_webview { |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 // Must be called on the I/O thread to record a client certificate | 43 // Must be called on the I/O thread to record a client certificate |
43 // and its private key in the OpenSSLClientKeyStore. | 44 // and its private key in the OpenSSLClientKeyStore. |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 bool has_user_gesture, | 350 bool has_user_gesture, |
350 bool is_redirect, | 351 bool is_redirect, |
351 bool is_main_frame) { | 352 bool is_main_frame) { |
352 JNIEnv* env = AttachCurrentThread(); | 353 JNIEnv* env = AttachCurrentThread(); |
353 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 354 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
354 if (obj.is_null()) | 355 if (obj.is_null()) |
355 return false; | 356 return false; |
356 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url); | 357 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url); |
357 devtools_instrumentation::ScopedEmbedderCallbackTask( | 358 devtools_instrumentation::ScopedEmbedderCallbackTask( |
358 "shouldOverrideUrlLoading"); | 359 "shouldOverrideUrlLoading"); |
359 return Java_AwContentsClientBridge_shouldOverrideUrlLoading( | 360 bool did_override = Java_AwContentsClientBridge_shouldOverrideUrlLoading( |
360 env, obj.obj(), jurl.obj(), has_user_gesture, is_redirect, is_main_frame); | 361 env, obj.obj(), jurl.obj(), has_user_gesture, is_redirect, is_main_frame); |
| 362 if (HasException(env)) { |
| 363 // Tell the chromium message loop to not perform any tasks after the current |
| 364 // one - we want to make sure we return to Java cleanly without first making |
| 365 // any new jni calls. |
| 366 static_cast<base::MessageLoopForUI*>(base::MessageLoop::current())->Abort(); |
| 367 // If we crashed we don't want to continue the navigation. |
| 368 return true; |
| 369 } |
| 370 return did_override; |
361 } | 371 } |
362 | 372 |
363 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, | 373 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, |
364 const JavaRef<jobject>&, | 374 const JavaRef<jobject>&, |
365 int id, | 375 int id, |
366 const JavaRef<jstring>& prompt) { | 376 const JavaRef<jstring>& prompt) { |
367 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 377 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
368 content::JavaScriptDialogManager::DialogClosedCallback* callback = | 378 content::JavaScriptDialogManager::DialogClosedCallback* callback = |
369 pending_js_dialog_callbacks_.Lookup(id); | 379 pending_js_dialog_callbacks_.Lookup(id); |
370 if (!callback) { | 380 if (!callback) { |
(...skipping 30 matching lines...) Expand all Loading... |
401 pending_client_cert_request_delegates_.Remove(request_id); | 411 pending_client_cert_request_delegates_.Remove(request_id); |
402 | 412 |
403 delete delegate; | 413 delete delegate; |
404 } | 414 } |
405 | 415 |
406 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 416 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
407 return RegisterNativesImpl(env); | 417 return RegisterNativesImpl(env); |
408 } | 418 } |
409 | 419 |
410 } // namespace android_webview | 420 } // namespace android_webview |
OLD | NEW |