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

Unified Diff: android_webview/native/aw_contents_client_bridge.cc

Issue 2169553002: Properly throw java exceptions from shouldOverrideUrlLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybot compilation failure. Created 4 years, 4 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
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java ('k') | base/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_contents_client_bridge.cc
diff --git a/android_webview/native/aw_contents_client_bridge.cc b/android_webview/native/aw_contents_client_bridge.cc
index 1a6e11b9143b8216cfd1255cfec38b260ead99fb..c428f2421855da288ff88fe0b88b98e6f908308b 100644
--- a/android_webview/native/aw_contents_client_bridge.cc
+++ b/android_webview/native/aw_contents_client_bridge.cc
@@ -31,6 +31,7 @@ using base::android::AttachCurrentThread;
using base::android::ConvertJavaStringToUTF16;
using base::android::ConvertUTF8ToJavaString;
using base::android::ConvertUTF16ToJavaString;
+using base::android::HasException;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
using content::BrowserThread;
@@ -346,8 +347,17 @@ bool AwContentsClientBridge::ShouldOverrideUrlLoading(const base::string16& url,
ScopedJavaLocalRef<jstring> jurl = ConvertUTF16ToJavaString(env, url);
devtools_instrumentation::ScopedEmbedderCallbackTask(
"shouldOverrideUrlLoading");
- return Java_AwContentsClientBridge_shouldOverrideUrlLoading(
+ bool did_override = Java_AwContentsClientBridge_shouldOverrideUrlLoading(
env, obj, jurl, has_user_gesture, is_redirect, is_main_frame);
+ if (HasException(env)) {
+ // 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.
+ static_cast<base::MessageLoopForUI*>(base::MessageLoop::current())->Abort();
+ // If we crashed we don't want to continue the navigation.
+ return true;
+ }
+ return did_override;
}
void AwContentsClientBridge::ConfirmJsResult(JNIEnv* env,
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java ('k') | base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698