Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / xwalk / extensions / common / xwalk_extension_messages.h
1 // Copyright (c) 2013 Intel Corporation. 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.
4
5 #include <stdint.h>
6 #include <string>
7 #include <vector>
8 #include "base/memory/shared_memory.h"
9 #include "base/values.h"
10 #include "ipc/ipc_channel_handle.h"
11 #include "ipc/ipc_message_macros.h"
12 #include "xwalk/extensions/common/xwalk_extension_permission_types.h"
13
14 // Note: it is safe to use numbers after LastIPCMsgStart since that limit
15 // is not relevant for embedders. It is used only by a tool inside chrome/
16 // that we currently don't use.
17 // See also https://code.google.com/p/chromium/issues/detail?id=110911.
18 #ifndef XWALK_EXTENSIONS_COMMON_XWALK_EXTENSION_MESSAGES_H_
19 #define XWALK_EXTENSIONS_COMMON_XWALK_EXTENSION_MESSAGES_H_
20 enum {
21   XWalkExtensionMsgStart = LastIPCMsgStart + 1,
22   XWalkExtensionClientServerMsgStart
23 };
24 #endif  // XWALK_EXTENSIONS_COMMON_XWALK_EXTENSION_MESSAGES_H_
25
26
27 #define IPC_MESSAGE_START XWalkExtensionMsgStart
28
29 IPC_MESSAGE_CONTROL2(XWalkExtensionProcessMsg_RegisterExtensions,  // NOLINT(*)
30                      base::FilePath /* extensions path */,
31                      base::ListValue /* browser variables */)
32
33 // This implies that extensions are all loaded and Extension Process
34 // is ready to be used.
35 IPC_MESSAGE_CONTROL1(XWalkExtensionProcessHostMsg_RenderProcessChannelCreated, // NOLINT(*)
36                      IPC::ChannelHandle /* channel id */)
37
38 // Message from Render Process to Browser Process. This message needs
39 // to be synchronous because Render Process cannot load anything without having
40 // collected the extensions loaded in Extension Process.
41 IPC_SYNC_MESSAGE_CONTROL0_1(XWalkExtensionProcessHostMsg_GetExtensionProcessChannel,  // NOLINT(*)
42                             IPC::ChannelHandle /* channel id */)
43
44 // Message from Extension Process to Browser Process
45 IPC_ENUM_TRAITS_MAX_VALUE(xwalk::extensions::RuntimePermission,
46                           xwalk::extensions::UNDEFINED_RUNTIME_PERM)
47 IPC_SYNC_MESSAGE_CONTROL2_1(XWalkExtensionProcessHostMsg_CheckAPIAccessControl, // NOLINT(*)
48                             std::string,
49                             std::string,
50                             xwalk::extensions::RuntimePermission)
51 IPC_SYNC_MESSAGE_CONTROL2_1(XWalkExtensionProcessHostMsg_RegisterPermissions, // NOLINT(*)
52                             std::string,
53                             std::string,
54                             bool)
55
56 // We use a separated message class for Client<->Server communication
57 // to ease filtering.
58 #undef IPC_MESSAGE_START
59 #define IPC_MESSAGE_START XWalkExtensionClientServerMsgStart
60
61 IPC_STRUCT_BEGIN(XWalkExtensionServerMsg_ExtensionRegisterParams)
62   IPC_STRUCT_MEMBER(std::string, name)
63   IPC_STRUCT_MEMBER(std::string, js_api)
64   IPC_STRUCT_MEMBER(std::vector<std::string>, entry_points)
65 IPC_STRUCT_END()
66
67 IPC_MESSAGE_CONTROL2(XWalkExtensionServerMsg_CreateInstance,  // NOLINT(*)
68                      int64_t /* instance id */,
69                      std::string /* extension name */)
70
71 IPC_MESSAGE_CONTROL2(XWalkExtensionServerMsg_PostMessageToNative,  // NOLINT(*)
72                      int64_t /* instance id */,
73                      base::ListValue /* contents */)
74
75 IPC_MESSAGE_CONTROL2(XWalkExtensionClientMsg_PostMessageToJS,  // NOLINT(*)
76                      int64_t /* instance id */,
77                      base::ListValue /* contents */)
78
79 IPC_MESSAGE_CONTROL2(XWalkExtensionClientMsg_PostOutOfLineMessageToJS,  // NOLINT(*)
80                      base::SharedMemoryHandle /* message buffer */,
81                      size_t /* buffer size */)
82
83 IPC_SYNC_MESSAGE_CONTROL2_1(XWalkExtensionServerMsg_SendSyncMessageToNative,  // NOLINT(*)
84                             int64_t /* instance id */,
85                             base::ListValue /* input contents */,
86                             base::ListValue /* output contents */)
87
88 IPC_SYNC_MESSAGE_CONTROL0_1(XWalkExtensionServerMsg_GetExtensions,  // NOLINT(*)
89                             std::vector<XWalkExtensionServerMsg_ExtensionRegisterParams> /* output contents */) // NOLINT(*)
90
91 IPC_MESSAGE_CONTROL1(XWalkExtensionServerMsg_DestroyInstance,  // NOLINT(*)
92                      int64_t /* instance id */)
93
94 IPC_MESSAGE_CONTROL1(XWalkExtensionClientMsg_InstanceDestroyed,  // NOLINT(*)
95                      int64_t /* instance id */)