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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 11788005: Switch Android code to use ExecuteJavascriptInWebFrameCallbackResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new approach with Messages Created 7 years, 12 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
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..f826a93c030f34b79fca1d67a04f434a0cf3497f 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.
+ * 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(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 void onEvaluateJavaScriptResult(String jsonResult, Message message) {
joth 2013/01/05 00:54:42 declare this as static, and then you can skip reso
+ message.obj = jsonResult;
+ message.sendToTarget();
}
@SuppressWarnings("unused")
@@ -2494,7 +2498,7 @@ public class ContentViewCore implements MotionEventDelegate {
private native void nativeClearHistory(int nativeContentViewCoreImpl);
- private native int nativeEvaluateJavaScript(String script);
+ private native void nativeEvaluateJavaScript(String script, Message message);
joth 2013/01/05 00:54:42 huh. I think this was pretty old code :) If you p
Avi (use Gerrit) 2013/01/05 01:05:48 That was the last user of ContentViewCore::GetNati
private native int nativeGetNativeImeAdapter(int nativeContentViewCoreImpl);

Powered by Google App Engine
This is Rietveld 408576698