| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
|
| ===================================================================
|
| --- content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java (revision 176919)
|
| +++ content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java (working copy)
|
| @@ -1097,26 +1097,18 @@
|
| }
|
| }
|
|
|
| - public interface JavaScriptCallback {
|
| - void handleJavaScriptResult(String jsonResult);
|
| - }
|
| -
|
| /**
|
| - * Injects the passed Javascript code in the current page and evaluates it.
|
| - * If a result is required, pass in a callback.
|
| - * Used in automation tests.
|
| + * Injects the passed JavaScript code in the current page and evaluates it.
|
| + * Once evaluated, an asynchronous call to
|
| + * ContentViewClient.onJavaScriptEvaluationResult is made. Used in automation
|
| + * tests.
|
| *
|
| - * @param script The Javascript to execute.
|
| - * @param message The callback to be fired off when a result is ready. The script's
|
| - * result will be json encoded and passed as the parameter, and the call
|
| - * will be made on the main thread.
|
| - * If no result is required, pass null.
|
| + * @return an id that is passed along in the asynchronous onJavaScriptEvaluationResult callback
|
| * @throws IllegalStateException If the ContentView has been destroyed.
|
| */
|
| - public void evaluateJavaScript(
|
| - String script, JavaScriptCallback callback) throws IllegalStateException {
|
| + public int evaluateJavaScript(String script) throws IllegalStateException {
|
| checkIsAlive();
|
| - nativeEvaluateJavaScript(mNativeContentViewCore, script, callback);
|
| + return nativeEvaluateJavaScript(script);
|
| }
|
|
|
| /**
|
| @@ -2051,9 +2043,8 @@
|
|
|
| @SuppressWarnings("unused")
|
| @CalledByNative
|
| - private static void onEvaluateJavaScriptResult(
|
| - String jsonResult, JavaScriptCallback callback) {
|
| - callback.handleJavaScriptResult(jsonResult);
|
| + private void onEvaluateJavaScriptResult(int id, String jsonResult) {
|
| + getContentViewClient().onEvaluateJavaScriptResult(id, jsonResult);
|
| }
|
|
|
| @SuppressWarnings("unused")
|
| @@ -2564,8 +2555,7 @@
|
|
|
| private native void nativeClearHistory(int nativeContentViewCoreImpl);
|
|
|
| - private native void nativeEvaluateJavaScript(int nativeContentViewCoreImpl,
|
| - String script, JavaScriptCallback callback);
|
| + private native int nativeEvaluateJavaScript(String script);
|
|
|
| private native int nativeGetNativeImeAdapter(int nativeContentViewCoreImpl);
|
|
|
|
|