diff options
author | Ben Murdoch <benm@google.com> | 2013-07-17 16:25:07 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2013-07-19 10:24:05 +0100 |
commit | a5cdd51cb7dc3acd608b67186bdef1d2a12bdbe7 (patch) | |
tree | 88d70ffc1be61452d20ba2943e91500186196764 /core/java/android/webkit/WebView.java | |
parent | c0743ec46658027ce4bc10e8ab2e1152531c52aa (diff) | |
download | frameworks_base-a5cdd51cb7dc3acd608b67186bdef1d2a12bdbe7.zip frameworks_base-a5cdd51cb7dc3acd608b67186bdef1d2a12bdbe7.tar.gz frameworks_base-a5cdd51cb7dc3acd608b67186bdef1d2a12bdbe7.tar.bz2 |
Add WebView.evaluateJavaScript(String, ValueCallback) API.
This API is intended to replace the "WebView.loadUrl("javascript:...")
pattern that is the current mechanism for executing JavaScript in the
context of the current page displayed in the WebView.
The new API is more convenient - it doesn't trigger the normal URL
loading path - and so does not have side effects such as hiding
the keyboard - and allows the caller to specify a callback that will
be invoked once the script execution is complete.
BUG=9814043
Change-Id: I3f27e8ff5371077d9265430090d61381a3a86e76
Diffstat (limited to 'core/java/android/webkit/WebView.java')
-rw-r--r-- | core/java/android/webkit/WebView.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 0149f03..7146d0d 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -850,6 +850,23 @@ public class WebView extends AbsoluteLayout } /** + * Asynchronously evaluates JavaScript in the context of the currently displayed page. + * If non-null, |resultCallback| will be invoked with any result returned from that + * execution. This method must be called on the UI thread and the callback will + * be made on the UI thread. + * + * @param script the JavaScript to execute. + * @param resultCallback A callback to be invoked when the script execution + * completes with the result of the execution (if any). + * May be null if no notificaion of the result is required. + * @hide pending API council approval and CTS test coverage. + */ + public void evaluateJavascript(String script, ValueCallback<String> resultCallback) { + checkThread(); + mProvider.evaluateJavaScript(script, resultCallback); + } + + /** * Saves the current view as a web archive. * * @param filename the filename where the archive should be placed |