| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 bool has_user_gesture, | 340 bool has_user_gesture, |
| 340 bool is_redirect, | 341 bool is_redirect, |
| 341 bool is_main_frame) { | 342 bool is_main_frame) { |
| 342 JNIEnv* env = AttachCurrentThread(); | 343 JNIEnv* env = AttachCurrentThread(); |
| 343 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 344 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 344 if (obj.is_null()) | 345 if (obj.is_null()) |
| 345 return false; | 346 return false; |
| 346 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url); | 347 ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url); |
| 347 devtools_instrumentation::ScopedEmbedderCallbackTask( | 348 devtools_instrumentation::ScopedEmbedderCallbackTask( |
| 348 "shouldOverrideUrlLoading"); | 349 "shouldOverrideUrlLoading"); |
| 349 return Java_AwContentsClientBridge_shouldOverrideUrlLoading( | 350 bool did_override = Java_AwContentsClientBridge_shouldOverrideUrlLoading( |
| 350 env, obj, jurl, has_user_gesture, is_redirect, is_main_frame); | 351 env, obj, jurl, has_user_gesture, is_redirect, is_main_frame); |
| 352 if (HasException(env)) { |
| 353 // Tell the chromium message loop to not perform any tasks after the current |
| 354 // one - we want to make sure we return to Java cleanly without first making |
| 355 // any new JNI calls. |
| 356 static_cast<base::MessageLoopForUI*>(base::MessageLoop::current())->Abort(); |
| 357 // If we crashed we don't want to continue the navigation. |
| 358 return true; |
| 359 } |
| 360 return did_override; |
| 351 } | 361 } |
| 352 | 362 |
| 353 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, | 363 void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env, |
| 354 const JavaRef<jobject>&, | 364 const JavaRef<jobject>&, |
| 355 int id, | 365 int id, |
| 356 const JavaRef<jstring>& prompt) { | 366 const JavaRef<jstring>& prompt) { |
| 357 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 367 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 358 content::JavaScriptDialogManager::DialogClosedCallback* callback = | 368 content::JavaScriptDialogManager::DialogClosedCallback* callback = |
| 359 pending_js_dialog_callbacks_.Lookup(id); | 369 pending_js_dialog_callbacks_.Lookup(id); |
| 360 if (!callback) { | 370 if (!callback) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 391 pending_client_cert_request_delegates_.Remove(request_id); | 401 pending_client_cert_request_delegates_.Remove(request_id); |
| 392 | 402 |
| 393 delete delegate; | 403 delete delegate; |
| 394 } | 404 } |
| 395 | 405 |
| 396 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 406 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 397 return RegisterNativesImpl(env); | 407 return RegisterNativesImpl(env); |
| 398 } | 408 } |
| 399 | 409 |
| 400 } // namespace android_webview | 410 } // namespace android_webview |
| OLD | NEW |