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 d97b6d13cd24cd7c7657277d7785e88a1596f4c2..d9db6cdd400e7143929b136cd4c4de90b34a1a2a 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 |
@@ -563,6 +563,21 @@ 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. |
+ * |
+ * @return an id that is passed along in the asynchronous onJavaScriptEvaluationResult callback |
+ * @throws IllegalStateException If the ContentView has been destroyed. |
+ * @hide |
+ */ |
+ public int evaluateJavaScript(String script) throws IllegalStateException { |
+ checkIsAlive(); |
+ return nativeEvaluateJavaScript(script); |
+ } |
+ |
+ /** |
* This method should be called when the containing activity is paused |
*/ |
public void onActivityPause() { |
@@ -738,6 +753,12 @@ public class ContentViewCore implements MotionEventDelegate { |
SelectPopupDialog.show(this, items, enabled, multiple, selectedIndices); |
} |
+ @SuppressWarnings("unused") |
+ @CalledByNative |
+ private void onEvaluateJavaScriptResult(int id, String jsonResult) { |
+ getContentViewClient().onEvaluateJavaScriptResult(id, jsonResult); |
+ } |
+ |
/** |
* Called (from native) when page loading begins. |
*/ |
@@ -997,6 +1018,8 @@ public class ContentViewCore implements MotionEventDelegate { |
private native void nativeClearHistory(int nativeContentViewCoreImpl); |
+ private native int nativeEvaluateJavaScript(String script); |
+ |
private native void nativeAddJavascriptInterface(int nativeContentViewCoreImpl, Object object, |
String name, boolean allowInheritedMethods); |