OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Multiply-included file, no traditional include guard. | 5 // Multiply-included file, no traditional include guard. |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ipc/ipc_message_macros.h" | 9 #include "ipc/ipc_message_macros.h" |
10 | 10 |
11 #define IPC_MESSAGE_START AwMessagePortMsgStart | 11 #define IPC_MESSAGE_START AwMessagePortMsgStart |
12 | 12 |
13 //----------------------------------------------------------------------------- | 13 //----------------------------------------------------------------------------- |
14 // MessagePort messages | 14 // MessagePort messages |
15 // These are messages sent from the browser to the renderer process. | 15 // These are messages sent from the browser to the renderer process. |
16 | 16 |
17 // Tells the renderer to convert the sent message from a WebSerializeScript | 17 // Normally the postmessages are exchanged between the renderers and the message |
18 // format to a base::ListValue. Due to the complexities of renderer/browser | 18 // itself is opaque to the browser process. The format of the message is a |
19 // relation, this can only be done in renderer for now. | 19 // WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure |
20 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_Message, | 20 // and can only be serialized/deserialized in renderer. Further, we could not |
| 21 // have Blink or V8 on the browser side due to their relience on static |
| 22 // variables. |
| 23 // |
| 24 // For posting messages from Java (Webview) to JS, we pass the browser/renderer |
| 25 // boundary an extra time and convert the messages to a type that browser can |
| 26 // use. Since WebView is single-process this is not terribly expensive, but |
| 27 // if we can do the conversion at the browser, then we can drop this code. |
| 28 |
| 29 // Tells the renderer to convert the message from a WebSerializeScript |
| 30 // format to a base::ListValue. This IPC is used for messages that are |
| 31 // incoming to Android webview from JS. |
| 32 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_WebToAppMessage, |
21 int /* recipient message port id */, | 33 int /* recipient message port id */, |
22 base::string16 /* message */, | 34 base::string16 /* message */, |
23 std::vector<int> /* sent message port_ids */) | 35 std::vector<int> /* sent message port_ids */) |
| 36 |
| 37 // Tells the renderer to convert the message from a String16 |
| 38 // format to a WebSerializedScriptValue. This IPC is used for messages that |
| 39 // are outgoing from Webview to JS. |
| 40 // TODO(sgurun) when we start supporting other types, use a ListValue instead |
| 41 // of string16 |
| 42 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage, |
| 43 int /* recipient message port id */, |
| 44 base::string16 /* message */, |
| 45 std::vector<int> /* sent message port_ids */) |
24 | 46 |
25 //----------------------------------------------------------------------------- | 47 //----------------------------------------------------------------------------- |
26 // These are messages sent from the renderer to the browser process. | 48 // These are messages sent from the renderer to the browser process. |
27 | 49 |
28 // Response to AwMessagePortMessage_ConvertMessage | 50 // Response to AwMessagePortMessage_WebToAppMessage |
29 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedMessage, | 51 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage, |
30 int /* recipient message port id */, | 52 int /* recipient message port id */, |
31 base::ListValue /* converted message */, | 53 base::ListValue /* converted message */, |
32 std::vector<int> /* sent message port_ids */) | 54 std::vector<int> /* sent message port_ids */) |
| 55 |
| 56 // Response to AwMessagePortMessage_AppToWebMessage |
| 57 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage, |
| 58 int /* recipient message port id */, |
| 59 base::string16 /* converted message */, |
| 60 std::vector<int> /* sent message port_ids */) |
OLD | NEW |