summaryrefslogtreecommitdiffstats
path: root/android_webview/common
diff options
context:
space:
mode:
authorsgurun <sgurun@chromium.org>2015-01-29 15:08:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-29 23:08:52 +0000
commit92afec533e58387d2364f49227a053993e1afd8f (patch)
tree6f8b18ee82afc13b7ae4b16bd2064552026ae599 /android_webview/common
parent1625b74468e4dd55f54ba209f8e91d05493875b9 (diff)
downloadchromium_src-92afec533e58387d2364f49227a053993e1afd8f.zip
chromium_src-92afec533e58387d2364f49227a053993e1afd8f.tar.gz
chromium_src-92afec533e58387d2364f49227a053993e1afd8f.tar.bz2
Post a message from Java to JS using message channels.
BUG=393291 Review URL: https://codereview.chromium.org/869133005 Cr-Commit-Position: refs/heads/master@{#313817}
Diffstat (limited to 'android_webview/common')
-rw-r--r--android_webview/common/aw_message_port_messages.h54
1 files changed, 48 insertions, 6 deletions
diff --git a/android_webview/common/aw_message_port_messages.h b/android_webview/common/aw_message_port_messages.h
index 866d713..00ec171 100644
--- a/android_webview/common/aw_message_port_messages.h
+++ b/android_webview/common/aw_message_port_messages.h
@@ -14,10 +14,46 @@
// MessagePort messages
// These are messages sent from the browser to the renderer process.
-// Tells the renderer to convert the sent message from a WebSerializeScript
-// format to a base::ListValue. Due to the complexities of renderer/browser
-// relation, this can only be done in renderer for now.
-IPC_MESSAGE_ROUTED3(AwMessagePortMsg_Message,
+// Normally the postmessages are exchanged between the renderers and the message
+// itself is opaque to the browser process. The format of the message is a
+// WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure
+// and can only be serialized/deserialized in renderer. Further, we could not
+// have Blink or V8 on the browser side due to their relience on static
+// variables.
+//
+// For posting messages from Java (Webview) to JS, we pass the browser/renderer
+// boundary an extra time and convert the messages to a type that browser can
+// use. Since WebView is single-process this is not terribly expensive, but
+// if we can do the conversion at the browser, then we can drop this code.
+
+// Important Note about multi-process situation: Webview is single process so
+// such a conversion does not increase the risk due to untrusted renderers.
+// However, in a multi-process scenario, the renderer that does the conversion
+// can be different then the renderer that receives the message. There are
+// 2 possible solutions to deal with this:
+// 1. Do the conversion at the browser side by writing a new serializer
+// deserializer for WebSerializedScriptValue
+// 2. Do the conversion at the content layer, at the renderer at the time of
+// receiveing the message. This may need adding new flags to indicate that
+// message needs to be converted. However, this is complicated due to queing
+// at the browser side and possibility of ports being shipped to a different
+// renderer or browser delegate.
+
+
+// Tells the renderer to convert the message from a WebSerializeScript
+// format to a base::ListValue. This IPC is used for messages that are
+// incoming to Android webview from JS.
+IPC_MESSAGE_ROUTED3(AwMessagePortMsg_WebToAppMessage,
+ int /* recipient message port id */,
+ base::string16 /* message */,
+ std::vector<int> /* sent message port_ids */)
+
+// Tells the renderer to convert the message from a String16
+// format to a WebSerializedScriptValue. This IPC is used for messages that
+// are outgoing from Webview to JS.
+// TODO(sgurun) when we start supporting other types, use a ListValue instead
+// of string16
+IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage,
int /* recipient message port id */,
base::string16 /* message */,
std::vector<int> /* sent message port_ids */)
@@ -25,8 +61,14 @@ IPC_MESSAGE_ROUTED3(AwMessagePortMsg_Message,
//-----------------------------------------------------------------------------
// These are messages sent from the renderer to the browser process.
-// Response to AwMessagePortMessage_ConvertMessage
-IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedMessage,
+// Response to AwMessagePortMessage_WebToAppMessage
+IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage,
int /* recipient message port id */,
base::ListValue /* converted message */,
std::vector<int> /* sent message port_ids */)
+
+// Response to AwMessagePortMessage_AppToWebMessage
+IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage,
+ int /* recipient message port id */,
+ base::string16 /* converted message */,
+ std::vector<int> /* sent message port_ids */)