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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 387113003: Add a content API to create a message channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address nit Created 6 years, 1 month 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
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/MessageChannel.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 854865b8bb0262dba55dbfe8602be44b5bf4c2b8..3eedfeded1d65cf19ba56c0d8552dbe5ec42e499 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -1754,6 +1754,35 @@ public class AwContents implements SmartClipProvider {
if (!isDestroyed()) mWebContents.evaluateJavaScript(script, null);
}
+ /**
+ * Post a message to a frame.
+ * TODO(sgurun) investigate if we should hardcode the source origin to some
+ * value instead.
+ *
+ * @param frameName The name of the frame. If the name is null the message is posted
+ * to the main frame.
+ * @param message The message
+ * @param sourceOrigin The source origin
+ * @param targetOrigin The target origin
+ * @param msgPorts The sent message ports, if any. Pass null if there is no
+ * message ports to pass.
+ */
+ public void postMessageToFrame(String frameName, String message,
+ String sourceOrigin, String targetOrigin, int[] msgPorts) {
+ nativePostMessageToFrame(mNativeAwContents, frameName, message, sourceOrigin,
+ targetOrigin, msgPorts);
+ }
+
+ /**
+ * Creates a message channel.
+ *
+ * @param callback The message channel created.
+ */
+ public void createMessageChannel(ValueCallback<MessageChannel> callback) {
+ nativeCreateMessageChannel(mNativeAwContents, callback);
+ }
+
+
//--------------------------------------------------------------------------------------------
// View and ViewGroup method implementations
//--------------------------------------------------------------------------------------------
@@ -2166,6 +2195,12 @@ public class AwContents implements SmartClipProvider {
}
}
+ @CalledByNative
+ private static void onMessageChannelCreated(int portId1, int portId2,
+ ValueCallback<MessageChannel> callback) {
+ callback.onReceiveValue(new MessageChannel(portId1, portId2));
+ }
+
// -------------------------------------------------------------------------------------------
// Helper methods
// -------------------------------------------------------------------------------------------
@@ -2643,4 +2678,10 @@ public class AwContents implements SmartClipProvider {
private native void nativePreauthorizePermission(long nativeAwContents, String origin,
long resources);
+
+ private native void nativePostMessageToFrame(long nativeAwContents, String frameId,
+ String message, String sourceOrigin, String targetOrigin, int[] msgPorts);
+
+ private native void nativeCreateMessageChannel(long nativeAwContents,
+ ValueCallback<MessageChannel> callback);
}
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/MessageChannel.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698