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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java

Issue 2886963003: [Android WebView] Propagate Java exceptions from JS dialog callbacks (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java
index a294913efc1270ead695e6a680faae6726f85b01..d2207f4cd61c8dde28d77a82565802d48e6ab848 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java
@@ -7,6 +7,7 @@ package org.chromium.android_webview;
import android.content.Context;
import android.net.http.SslCertificate;
import android.net.http.SslError;
+import android.os.Handler;
import android.util.Log;
import android.webkit.ValueCallback;
@@ -231,21 +232,49 @@ public class AwContentsClientBridge {
}
@CalledByNative
- private void handleJsAlert(String url, String message, int id) {
- JsResultHandler handler = new JsResultHandler(this, id);
- mClient.handleJsAlert(url, message, handler);
+ private void handleJsAlert(final String url, final String message, final int id) {
+ // Post the application callback back to the current thread to ensure the application
+ // callback is executed without any native code on the stack. This so that any exception
+ // thrown by the application callback won't have to be propagated through a native call
+ // stack.
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ JsResultHandler handler = new JsResultHandler(AwContentsClientBridge.this, id);
+ mClient.handleJsAlert(url, message, handler);
+ }
+ });
}
@CalledByNative
- private void handleJsConfirm(String url, String message, int id) {
- JsResultHandler handler = new JsResultHandler(this, id);
- mClient.handleJsConfirm(url, message, handler);
+ private void handleJsConfirm(final String url, final String message, final int id) {
+ // Post the application callback back to the current thread to ensure the application
+ // callback is executed without any native code on the stack. This so that any exception
+ // thrown by the application callback won't have to be propagated through a native call
+ // stack.
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ JsResultHandler handler = new JsResultHandler(AwContentsClientBridge.this, id);
+ mClient.handleJsConfirm(url, message, handler);
+ }
+ });
}
@CalledByNative
- private void handleJsPrompt(String url, String message, String defaultValue, int id) {
- JsResultHandler handler = new JsResultHandler(this, id);
- mClient.handleJsPrompt(url, message, defaultValue, handler);
+ private void handleJsPrompt(
+ final String url, final String message, final String defaultValue, final int id) {
+ // Post the application callback back to the current thread to ensure the application
+ // callback is executed without any native code on the stack. This so that any exception
+ // thrown by the application callback won't have to be propagated through a native call
+ // stack.
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ JsResultHandler handler = new JsResultHandler(AwContentsClientBridge.this, id);
+ mClient.handleJsPrompt(url, message, defaultValue, handler);
+ }
+ });
}
@CalledByNative
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698