| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 &pending_client_cert_request_delegates_); | 73 &pending_client_cert_request_delegates_); |
| 74 !iter.IsAtEnd(); iter.Advance()) { | 74 !iter.IsAtEnd(); iter.Advance()) { |
| 75 delete iter.GetCurrentValue(); | 75 delete iter.GetCurrentValue(); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 void AwContentsClientBridge::AllowCertificateError( | 79 void AwContentsClientBridge::AllowCertificateError( |
| 80 int cert_error, | 80 int cert_error, |
| 81 net::X509Certificate* cert, | 81 net::X509Certificate* cert, |
| 82 const GURL& request_url, | 82 const GURL& request_url, |
| 83 const base::Callback<void(bool)>& callback, | 83 const base::Callback<void(content::CertificateRequestResultType)>& callback, |
| 84 bool* cancel_request) { | 84 bool* cancel_request) { |
| 85 | |
| 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 87 JNIEnv* env = AttachCurrentThread(); | 86 JNIEnv* env = AttachCurrentThread(); |
| 88 | 87 |
| 89 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 88 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 90 if (obj.is_null()) | 89 if (obj.is_null()) |
| 91 return; | 90 return; |
| 92 | 91 |
| 93 std::string der_string; | 92 std::string der_string; |
| 94 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_string); | 93 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_string); |
| 95 ScopedJavaLocalRef<jbyteArray> jcert = base::android::ToJavaByteArray( | 94 ScopedJavaLocalRef<jbyteArray> jcert = base::android::ToJavaByteArray( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 112 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, | 111 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, |
| 113 const JavaRef<jobject>& obj, | 112 const JavaRef<jobject>& obj, |
| 114 jboolean proceed, | 113 jboolean proceed, |
| 115 jint id) { | 114 jint id) { |
| 116 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 115 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 117 CertErrorCallback* callback = pending_cert_error_callbacks_.Lookup(id); | 116 CertErrorCallback* callback = pending_cert_error_callbacks_.Lookup(id); |
| 118 if (!callback || callback->is_null()) { | 117 if (!callback || callback->is_null()) { |
| 119 LOG(WARNING) << "Ignoring unexpected ssl error proceed callback"; | 118 LOG(WARNING) << "Ignoring unexpected ssl error proceed callback"; |
| 120 return; | 119 return; |
| 121 } | 120 } |
| 122 callback->Run(proceed); | 121 callback->Run(proceed ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE |
| 122 : content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); |
| 123 pending_cert_error_callbacks_.Remove(id); | 123 pending_cert_error_callbacks_.Remove(id); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // This method is inspired by SelectClientCertificate() in | 126 // This method is inspired by SelectClientCertificate() in |
| 127 // chrome/browser/ui/android/ssl_client_certificate_request.cc | 127 // chrome/browser/ui/android/ssl_client_certificate_request.cc |
| 128 void AwContentsClientBridge::SelectClientCertificate( | 128 void AwContentsClientBridge::SelectClientCertificate( |
| 129 net::SSLCertRequestInfo* cert_request_info, | 129 net::SSLCertRequestInfo* cert_request_info, |
| 130 std::unique_ptr<content::ClientCertificateDelegate> delegate) { | 130 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
| 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 132 | 132 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 pending_client_cert_request_delegates_.Remove(request_id); | 401 pending_client_cert_request_delegates_.Remove(request_id); |
| 402 | 402 |
| 403 delete delegate; | 403 delete delegate; |
| 404 } | 404 } |
| 405 | 405 |
| 406 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 406 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 407 return RegisterNativesImpl(env); | 407 return RegisterNativesImpl(env); |
| 408 } | 408 } |
| 409 | 409 |
| 410 } // namespace android_webview | 410 } // namespace android_webview |
| OLD | NEW |