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
3 // found in the LICENSE file.
5 // Multiply-included file, no traditional include guard.
8 #include "base/basictypes.h"
9 #include "ipc/ipc_message_macros.h"
11 #define IPC_MESSAGE_START AwMessagePortMsgStart
13 //-----------------------------------------------------------------------------
14 // MessagePort messages
15 // These are messages sent from the browser to the renderer process.
17 // Normally the postmessages are exchanged between the renderers and the message
18 // itself is opaque to the browser process. The format of the message is a
19 // WebSerializesScriptValue. A WebSerializedScriptValue is a blink structure
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
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.
29 // Important Note about multi-process situation: Webview is single process so
30 // such a conversion does not increase the risk due to untrusted renderers.
31 // However, in a multi-process scenario, the renderer that does the conversion
32 // can be different then the renderer that receives the message. There are
33 // 2 possible solutions to deal with this:
34 // 1. Do the conversion at the browser side by writing a new serializer
35 // deserializer for WebSerializedScriptValue
36 // 2. Do the conversion at the content layer, at the renderer at the time of
37 // receiveing the message. This may need adding new flags to indicate that
38 // message needs to be converted. However, this is complicated due to queing
39 // at the browser side and possibility of ports being shipped to a different
40 // renderer or browser delegate.
43 // Tells the renderer to convert the message from a WebSerializeScript
44 // format to a base::ListValue. This IPC is used for messages that are
45 // incoming to Android webview from JS.
46 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_WebToAppMessage
,
47 int /* recipient message port id */,
48 base::string16
/* message */,
49 std::vector
<int> /* sent message port_ids */)
51 // Tells the renderer to convert the message from a String16
52 // format to a WebSerializedScriptValue. This IPC is used for messages that
53 // are outgoing from Webview to JS.
54 // TODO(sgurun) when we start supporting other types, use a ListValue instead
56 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage
,
57 int /* recipient message port id */,
58 base::string16
/* message */,
59 std::vector
<int> /* sent message port_ids */)
61 // Used to defer message port closing until after all in-flight messages
62 // are flushed from renderer to browser. Renderer piggy-backs the message
64 IPC_MESSAGE_ROUTED1(AwMessagePortMsg_ClosePort
,
65 int /* message port id */)
67 //-----------------------------------------------------------------------------
68 // These are messages sent from the renderer to the browser process.
70 // Response to AwMessagePortMessage_WebToAppMessage
71 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage
,
72 int /* recipient message port id */,
73 base::ListValue
/* converted message */,
74 std::vector
<int> /* sent message port_ids */)
76 // Response to AwMessagePortMessage_AppToWebMessage
77 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage
,
78 int /* recipient message port id */,
79 base::string16
/* converted message */,
80 std::vector
<int> /* sent message port_ids */)
82 // Response to AwMessagePortMsg_ClosePort
83 IPC_MESSAGE_ROUTED1(AwMessagePortHostMsg_ClosePortAck
,
84 int /* message port id */)