Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| index 7a4c05e963061f7c0e5e18756dbdf72d558d39f8..95b873ebac0751ff6f05a3390e436d8f1aca82f3 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| @@ -18,6 +18,7 @@ import android.graphics.Rect; |
| import android.os.Build; |
| import android.os.Bundle; |
| import android.os.Handler; |
| +import android.os.Message; |
| import android.os.ResultReceiver; |
| import android.os.SystemClock; |
| import android.text.Editable; |
| @@ -1045,17 +1046,19 @@ public class ContentViewCore implements MotionEventDelegate { |
| } |
| /** |
| - * 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. |
| + * Injects the passed Javascript code in the current page and evaluates it. |
| + * If a result is required, pass in a Message to be sent to its target. |
| + * Used in automation tests. |
| * |
| - * @return an id that is passed along in the asynchronous onJavaScriptEvaluationResult callback |
| + * @param script The Javascript to execute. |
| + * @param message The message to be fired off when a result is ready. The script's |
| + * result will be json encoded in the Message's {@link Message#obj} field. |
|
Avi (use Gerrit)
2013/01/05 21:57:09
Did I get the javadoc right?
joth
2013/01/07 19:43:28
lgtm
|
| + * If no result is required, pass null. |
| * @throws IllegalStateException If the ContentView has been destroyed. |
| */ |
| - public int evaluateJavaScript(String script) throws IllegalStateException { |
| + public void evaluateJavaScript(String script, Message message) throws IllegalStateException { |
| checkIsAlive(); |
| - return nativeEvaluateJavaScript(script); |
| + nativeEvaluateJavaScript(mNativeContentViewCore, script, message); |
| } |
| /** |
| @@ -1986,8 +1989,9 @@ public class ContentViewCore implements MotionEventDelegate { |
| @SuppressWarnings("unused") |
| @CalledByNative |
| - private void onEvaluateJavaScriptResult(int id, String jsonResult) { |
| - getContentViewClient().onEvaluateJavaScriptResult(id, jsonResult); |
| + private static void onEvaluateJavaScriptResult(String jsonResult, Message message) { |
| + message.obj = jsonResult; |
| + message.sendToTarget(); |
| } |
| @SuppressWarnings("unused") |
| @@ -2494,7 +2498,8 @@ public class ContentViewCore implements MotionEventDelegate { |
| private native void nativeClearHistory(int nativeContentViewCoreImpl); |
| - private native int nativeEvaluateJavaScript(String script); |
| + private native void nativeEvaluateJavaScript(int nativeContentViewCoreImpl, |
| + String script, Message message); |
| private native int nativeGetNativeImeAdapter(int nativeContentViewCoreImpl); |