Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2548)

Unified Diff: android_webview/browser/aw_contents_client_bridge.cc

Issue 2869103002: [Android WebView] Propagate Java exceptions thrown in OnReceivedSslError (Closed)
Patch Set: Add comments to ssl_manager.h as well. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/aw_contents_client_bridge.cc
diff --git a/android_webview/browser/aw_contents_client_bridge.cc b/android_webview/browser/aw_contents_client_bridge.cc
index eb4ecab7ac70783943fbdc8b4cd8df23a4616964..480f9722741b22850740f3d29484cd73f1d9280e 100644
--- a/android_webview/browser/aw_contents_client_bridge.cc
+++ b/android_webview/browser/aw_contents_client_bridge.cc
@@ -62,7 +62,7 @@ void RecordClientCertificateKey(net::X509Certificate* client_cert,
AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env,
const JavaRef<jobject>& obj)
- : java_ref_(env, obj) {
+ : java_ref_(env, obj), has_pending_java_exception_(false) {
DCHECK(!obj.is_null());
Java_AwContentsClientBridge_setNativeContentsClientBridge(
env, obj, reinterpret_cast<intptr_t>(this));
@@ -111,6 +111,17 @@ void AwContentsClientBridge::AllowCertificateError(
base::MakeUnique<CertErrorCallback>(callback));
*cancel_request = !Java_AwContentsClientBridge_allowCertificateError(
env, obj, cert_error, jcert, jurl, request_id);
+
+ if (HasException(env)) {
+ has_pending_java_exception_ = true;
+ // Tell the chromium message loop to not perform any tasks after the current
+ // one - we want to make sure we return to Java cleanly without first making
+ // any new JNI calls.
+ base::MessageLoopForUI::current()->Abort();
+ // If we crashed we don't want to continue the navigation.
+ return;
+ }
+
// if the request is cancelled, then cancel the stored callback
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.
pending_cert_error_callbacks_.Remove(request_id);
« no previous file with comments | « android_webview/browser/aw_contents_client_bridge.h ('k') | android_webview/browser/aw_contents_client_bridge_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698