Chromium Code Reviews| 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/browser/aw_contents_client_bridge.h" | 5 #include "android_webview/browser/aw_contents_client_bridge.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_contents.h" | 10 #include "android_webview/browser/aw_contents.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 scoped_refptr<net::SSLPrivateKey> private_key) { | 55 scoped_refptr<net::SSLPrivateKey> private_key) { |
| 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 57 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey( | 57 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey( |
| 58 client_cert, std::move(private_key)); | 58 client_cert, std::move(private_key)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, | 63 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, |
| 64 const JavaRef<jobject>& obj) | 64 const JavaRef<jobject>& obj) |
| 65 : java_ref_(env, obj) { | 65 : java_ref_(env, obj), has_pending_java_exception_(false) { |
| 66 DCHECK(!obj.is_null()); | 66 DCHECK(!obj.is_null()); |
| 67 Java_AwContentsClientBridge_setNativeContentsClientBridge( | 67 Java_AwContentsClientBridge_setNativeContentsClientBridge( |
| 68 env, obj, reinterpret_cast<intptr_t>(this)); | 68 env, obj, reinterpret_cast<intptr_t>(this)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 AwContentsClientBridge::~AwContentsClientBridge() { | 71 AwContentsClientBridge::~AwContentsClientBridge() { |
| 72 JNIEnv* env = AttachCurrentThread(); | 72 JNIEnv* env = AttachCurrentThread(); |
| 73 | 73 |
| 74 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 74 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 75 if (!obj.is_null()) { | 75 if (!obj.is_null()) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 104 env, reinterpret_cast<const uint8_t*>(der_string.data()), | 104 env, reinterpret_cast<const uint8_t*>(der_string.data()), |
| 105 der_string.length()); | 105 der_string.length()); |
| 106 ScopedJavaLocalRef<jstring> jurl( | 106 ScopedJavaLocalRef<jstring> jurl( |
| 107 ConvertUTF8ToJavaString(env, request_url.spec())); | 107 ConvertUTF8ToJavaString(env, request_url.spec())); |
| 108 // We need to add the callback before making the call to java side, | 108 // We need to add the callback before making the call to java side, |
| 109 // as it may do a synchronous callback prior to returning. | 109 // as it may do a synchronous callback prior to returning. |
| 110 int request_id = pending_cert_error_callbacks_.Add( | 110 int request_id = pending_cert_error_callbacks_.Add( |
| 111 base::MakeUnique<CertErrorCallback>(callback)); | 111 base::MakeUnique<CertErrorCallback>(callback)); |
| 112 *cancel_request = !Java_AwContentsClientBridge_allowCertificateError( | 112 *cancel_request = !Java_AwContentsClientBridge_allowCertificateError( |
| 113 env, obj, cert_error, jcert, jurl, request_id); | 113 env, obj, cert_error, jcert, jurl, request_id); |
| 114 | |
| 115 if (HasException(env)) { | |
| 116 has_pending_java_exception_ = true; | |
| 117 // Tell the chromium message loop to not perform any tasks after the current | |
| 118 // one - we want to make sure we return to Java cleanly without first making | |
| 119 // any new JNI calls. | |
| 120 base::MessageLoopForUI::current()->Abort(); | |
| 121 // If we crashed we don't want to continue the navigation. | |
| 122 return; | |
| 123 } | |
| 124 | |
| 114 // if the request is cancelled, then cancel the stored callback | 125 // if the request is cancelled, then cancel the stored callback |
| 115 if (*cancel_request) { | 126 if (*cancel_request) { |
|
gsennton
2017/05/17 13:19:18
Selim: I guess if we post the Java-side of allowCe
gsennton
2017/05/17 14:45:07
Aha, I see what's going on here now.
We remove thi
sgurun-gerrit only
2017/05/17 15:23:58
sounds reasonable and simpler.
| |
| 116 pending_cert_error_callbacks_.Remove(request_id); | 127 pending_cert_error_callbacks_.Remove(request_id); |
| 117 } | 128 } |
| 118 } | 129 } |
| 119 | 130 |
| 120 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, | 131 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, |
| 121 const JavaRef<jobject>& obj, | 132 const JavaRef<jobject>& obj, |
| 122 jboolean proceed, | 133 jboolean proceed, |
| 123 jint id) { | 134 jint id) { |
| 124 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 135 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 125 CertErrorCallback* callback = pending_cert_error_callbacks_.Lookup(id); | 136 CertErrorCallback* callback = pending_cert_error_callbacks_.Lookup(id); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 pending_client_cert_request_delegates_.Remove(request_id); | 537 pending_client_cert_request_delegates_.Remove(request_id); |
| 527 | 538 |
| 528 delete delegate; | 539 delete delegate; |
| 529 } | 540 } |
| 530 | 541 |
| 531 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 542 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 532 return RegisterNativesImpl(env); | 543 return RegisterNativesImpl(env); |
| 533 } | 544 } |
| 534 | 545 |
| 535 } // namespace android_webview | 546 } // namespace android_webview |
| OLD | NEW |