Loading core/java/android/webkit/CallbackProxy.java +35 −0 Original line number Original line Diff line number Diff line Loading @@ -98,6 +98,7 @@ class CallbackProxy extends Handler { private static final int SCALE_CHANGED = 123; private static final int SCALE_CHANGED = 123; private static final int RECEIVED_CERTIFICATE = 124; private static final int RECEIVED_CERTIFICATE = 124; private static final int SWITCH_OUT_HISTORY = 125; private static final int SWITCH_OUT_HISTORY = 125; private static final int JS_TIMEOUT = 126; // Message triggered by the client to resume execution // Message triggered by the client to resume execution private static final int NOTIFY = 200; private static final int NOTIFY = 200; Loading Loading @@ -530,6 +531,18 @@ class CallbackProxy extends Handler { } } break; break; case JS_TIMEOUT: if(mWebChromeClient != null) { final JsResult res = (JsResult) msg.obj; if(mWebChromeClient.onJsTimeout()) { res.confirm(); } else { res.cancel(); } res.setReady(); } break; case RECEIVED_CERTIFICATE: case RECEIVED_CERTIFICATE: mWebView.setCertificate((SslCertificate) msg.obj); mWebView.setCertificate((SslCertificate) msg.obj); break; break; Loading Loading @@ -1022,4 +1035,26 @@ class CallbackProxy extends Handler { } } return result.getResult(); return result.getResult(); } } /** * @hide pending API council approval */ public boolean onJsTimeout() { //always interrupt timedout JS by default if (mWebChromeClient == null) { return true; } JsResult result = new JsResult(this, true); Message timeout = obtainMessage(JS_TIMEOUT, result); synchronized (this) { sendMessage(timeout); try { wait(); } catch (InterruptedException e) { Log.e(LOGTAG, "Caught exception while waiting for jsUnload"); Log.e(LOGTAG, Log.getStackTraceString(e)); } } return result.getResult(); } } } core/java/android/webkit/WebChromeClient.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -157,4 +157,19 @@ public class WebChromeClient { JsResult result) { JsResult result) { return false; return false; } } /** * Tell the client that a JavaScript execution timeout has occured. And the * client may decide whether or not to interrupt the execution. If the * client returns true, the JavaScript will be interrupted. If the client * returns false, the execution will continue. Note that in the case of * continuing execution, the timeout counter will be reset, and the callback * will continue to occur if the script does not finish at the next check * point. * @return boolean Whether the JavaScript execution should be interrupted. * @hide pending API Council approval */ public boolean onJsTimeout() { return true; } } } core/java/android/webkit/WebViewCore.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -263,6 +263,16 @@ final class WebViewCore { return mCallbackProxy.onJsBeforeUnload(url, message); return mCallbackProxy.onJsBeforeUnload(url, message); } } /** * * Callback to notify that a JavaScript execution timeout has occured. * @return True if the JavaScript execution should be interrupted. False * will continue the execution. */ protected boolean jsInterrupt() { return mCallbackProxy.onJsTimeout(); } //------------------------------------------------------------------------- //------------------------------------------------------------------------- // JNI methods // JNI methods //------------------------------------------------------------------------- //------------------------------------------------------------------------- Loading Loading
core/java/android/webkit/CallbackProxy.java +35 −0 Original line number Original line Diff line number Diff line Loading @@ -98,6 +98,7 @@ class CallbackProxy extends Handler { private static final int SCALE_CHANGED = 123; private static final int SCALE_CHANGED = 123; private static final int RECEIVED_CERTIFICATE = 124; private static final int RECEIVED_CERTIFICATE = 124; private static final int SWITCH_OUT_HISTORY = 125; private static final int SWITCH_OUT_HISTORY = 125; private static final int JS_TIMEOUT = 126; // Message triggered by the client to resume execution // Message triggered by the client to resume execution private static final int NOTIFY = 200; private static final int NOTIFY = 200; Loading Loading @@ -530,6 +531,18 @@ class CallbackProxy extends Handler { } } break; break; case JS_TIMEOUT: if(mWebChromeClient != null) { final JsResult res = (JsResult) msg.obj; if(mWebChromeClient.onJsTimeout()) { res.confirm(); } else { res.cancel(); } res.setReady(); } break; case RECEIVED_CERTIFICATE: case RECEIVED_CERTIFICATE: mWebView.setCertificate((SslCertificate) msg.obj); mWebView.setCertificate((SslCertificate) msg.obj); break; break; Loading Loading @@ -1022,4 +1035,26 @@ class CallbackProxy extends Handler { } } return result.getResult(); return result.getResult(); } } /** * @hide pending API council approval */ public boolean onJsTimeout() { //always interrupt timedout JS by default if (mWebChromeClient == null) { return true; } JsResult result = new JsResult(this, true); Message timeout = obtainMessage(JS_TIMEOUT, result); synchronized (this) { sendMessage(timeout); try { wait(); } catch (InterruptedException e) { Log.e(LOGTAG, "Caught exception while waiting for jsUnload"); Log.e(LOGTAG, Log.getStackTraceString(e)); } } return result.getResult(); } } }
core/java/android/webkit/WebChromeClient.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -157,4 +157,19 @@ public class WebChromeClient { JsResult result) { JsResult result) { return false; return false; } } /** * Tell the client that a JavaScript execution timeout has occured. And the * client may decide whether or not to interrupt the execution. If the * client returns true, the JavaScript will be interrupted. If the client * returns false, the execution will continue. Note that in the case of * continuing execution, the timeout counter will be reset, and the callback * will continue to occur if the script does not finish at the next check * point. * @return boolean Whether the JavaScript execution should be interrupted. * @hide pending API Council approval */ public boolean onJsTimeout() { return true; } } }
core/java/android/webkit/WebViewCore.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -263,6 +263,16 @@ final class WebViewCore { return mCallbackProxy.onJsBeforeUnload(url, message); return mCallbackProxy.onJsBeforeUnload(url, message); } } /** * * Callback to notify that a JavaScript execution timeout has occured. * @return True if the JavaScript execution should be interrupted. False * will continue the execution. */ protected boolean jsInterrupt() { return mCallbackProxy.onJsTimeout(); } //------------------------------------------------------------------------- //------------------------------------------------------------------------- // JNI methods // JNI methods //------------------------------------------------------------------------- //------------------------------------------------------------------------- Loading