| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/common/devtools_instrumentation.h" | 9 #include "android_webview/common/devtools_instrumentation.h" |
| 10 #include "android_webview/native/aw_contents.h" | 10 #include "android_webview/native/aw_contents.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 std::string der_string; | 95 std::string der_string; |
| 96 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_string); | 96 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_string); |
| 97 ScopedJavaLocalRef<jbyteArray> jcert = base::android::ToJavaByteArray( | 97 ScopedJavaLocalRef<jbyteArray> jcert = base::android::ToJavaByteArray( |
| 98 env, reinterpret_cast<const uint8_t*>(der_string.data()), | 98 env, reinterpret_cast<const uint8_t*>(der_string.data()), |
| 99 der_string.length()); | 99 der_string.length()); |
| 100 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString( | 100 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString( |
| 101 env, request_url.spec())); | 101 env, request_url.spec())); |
| 102 // We need to add the callback before making the call to java side, | 102 // We need to add the callback before making the call to java side, |
| 103 // as it may do a synchronous callback prior to returning. | 103 // as it may do a synchronous callback prior to returning. |
| 104 int request_id = pending_cert_error_callbacks_.Add( | 104 int request_id = pending_cert_error_callbacks_.Add( |
| 105 new CertErrorCallback(callback)); | 105 base::MakeUnique<CertErrorCallback>(callback)); |
| 106 *cancel_request = !Java_AwContentsClientBridge_allowCertificateError( | 106 *cancel_request = !Java_AwContentsClientBridge_allowCertificateError( |
| 107 env, obj, cert_error, jcert, jurl, request_id); | 107 env, obj, cert_error, jcert, jurl, request_id); |
| 108 // if the request is cancelled, then cancel the stored callback | 108 // if the request is cancelled, then cancel the stored callback |
| 109 if (*cancel_request) { | 109 if (*cancel_request) { |
| 110 pending_cert_error_callbacks_.Remove(request_id); | 110 pending_cert_error_callbacks_.Remove(request_id); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, | 114 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, |
| 115 const JavaRef<jobject>& obj, | 115 const JavaRef<jobject>& obj, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 273 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 274 JNIEnv* env = AttachCurrentThread(); | 274 JNIEnv* env = AttachCurrentThread(); |
| 275 | 275 |
| 276 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 276 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 277 if (obj.is_null()) { | 277 if (obj.is_null()) { |
| 278 callback.Run(false, base::string16()); | 278 callback.Run(false, base::string16()); |
| 279 return; | 279 return; |
| 280 } | 280 } |
| 281 | 281 |
| 282 int callback_id = pending_js_dialog_callbacks_.Add( | 282 int callback_id = pending_js_dialog_callbacks_.Add( |
| 283 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); | 283 base::MakeUnique< |
| 284 content::JavaScriptDialogManager::DialogClosedCallback>(callback)); |
| 284 ScopedJavaLocalRef<jstring> jurl( | 285 ScopedJavaLocalRef<jstring> jurl( |
| 285 ConvertUTF8ToJavaString(env, origin_url.spec())); | 286 ConvertUTF8ToJavaString(env, origin_url.spec())); |
| 286 ScopedJavaLocalRef<jstring> jmessage( | 287 ScopedJavaLocalRef<jstring> jmessage( |
| 287 ConvertUTF16ToJavaString(env, message_text)); | 288 ConvertUTF16ToJavaString(env, message_text)); |
| 288 | 289 |
| 289 switch (message_type) { | 290 switch (message_type) { |
| 290 case content::JAVASCRIPT_MESSAGE_TYPE_ALERT: { | 291 case content::JAVASCRIPT_MESSAGE_TYPE_ALERT: { |
| 291 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsAlert"); | 292 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsAlert"); |
| 292 Java_AwContentsClientBridge_handleJsAlert(env, obj, jurl, jmessage, | 293 Java_AwContentsClientBridge_handleJsAlert(env, obj, jurl, jmessage, |
| 293 callback_id); | 294 callback_id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 321 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 322 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 322 if (obj.is_null()) { | 323 if (obj.is_null()) { |
| 323 callback.Run(false, base::string16()); | 324 callback.Run(false, base::string16()); |
| 324 return; | 325 return; |
| 325 } | 326 } |
| 326 | 327 |
| 327 const base::string16 message_text = | 328 const base::string16 message_text = |
| 328 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE); | 329 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE); |
| 329 | 330 |
| 330 int callback_id = pending_js_dialog_callbacks_.Add( | 331 int callback_id = pending_js_dialog_callbacks_.Add( |
| 331 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); | 332 base::MakeUnique< |
| 333 content::JavaScriptDialogManager::DialogClosedCallback>(callback)); |
| 332 ScopedJavaLocalRef<jstring> jurl( | 334 ScopedJavaLocalRef<jstring> jurl( |
| 333 ConvertUTF8ToJavaString(env, origin_url.spec())); | 335 ConvertUTF8ToJavaString(env, origin_url.spec())); |
| 334 ScopedJavaLocalRef<jstring> jmessage( | 336 ScopedJavaLocalRef<jstring> jmessage( |
| 335 ConvertUTF16ToJavaString(env, message_text)); | 337 ConvertUTF16ToJavaString(env, message_text)); |
| 336 | 338 |
| 337 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsBeforeUnload"); | 339 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsBeforeUnload"); |
| 338 Java_AwContentsClientBridge_handleJsBeforeUnload(env, obj, jurl, jmessage, | 340 Java_AwContentsClientBridge_handleJsBeforeUnload(env, obj, jurl, jmessage, |
| 339 callback_id); | 341 callback_id); |
| 340 } | 342 } |
| 341 | 343 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 pending_client_cert_request_delegates_.Remove(request_id); | 451 pending_client_cert_request_delegates_.Remove(request_id); |
| 450 | 452 |
| 451 delete delegate; | 453 delete delegate; |
| 452 } | 454 } |
| 453 | 455 |
| 454 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 456 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 455 return RegisterNativesImpl(env); | 457 return RegisterNativesImpl(env); |
| 456 } | 458 } |
| 457 | 459 |
| 458 } // namespace android_webview | 460 } // namespace android_webview |
| OLD | NEW |