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

Side by Side Diff: android_webview/common/aw_message_port_messages.h

Issue 869133005: Post a Message from Java to JS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: spelling fix Created 5 years, 10 months 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 unified diff | Download patch
OLDNEW
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 // 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.
41
42
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,
21 int /* recipient message port id */, 47 int /* recipient message port id */,
22 base::string16 /* message */, 48 base::string16 /* message */,
23 std::vector<int> /* sent message port_ids */) 49 std::vector<int> /* sent message port_ids */)
50
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
55 // of string16
56 IPC_MESSAGE_ROUTED3(AwMessagePortMsg_AppToWebMessage,
57 int /* recipient message port id */,
58 base::string16 /* message */,
59 std::vector<int> /* sent message port_ids */)
24 60
25 //----------------------------------------------------------------------------- 61 //-----------------------------------------------------------------------------
26 // These are messages sent from the renderer to the browser process. 62 // These are messages sent from the renderer to the browser process.
27 63
28 // Response to AwMessagePortMessage_ConvertMessage 64 // Response to AwMessagePortMessage_WebToAppMessage
29 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedMessage, 65 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedWebToAppMessage,
30 int /* recipient message port id */, 66 int /* recipient message port id */,
31 base::ListValue /* converted message */, 67 base::ListValue /* converted message */,
32 std::vector<int> /* sent message port_ids */) 68 std::vector<int> /* sent message port_ids */)
69
70 // Response to AwMessagePortMessage_AppToWebMessage
71 IPC_MESSAGE_ROUTED3(AwMessagePortHostMsg_ConvertedAppToWebMessage,
72 int /* recipient message port id */,
73 base::string16 /* converted message */,
74 std::vector<int> /* sent message port_ids */)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698