• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors.
2 // Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 // IPC messages for CEF.
7 // Multiply-included message file, hence no include guard.
8 
9 #include <stdint.h>
10 
11 #include "libcef/common/net/upload_data.h"
12 
13 #include "base/memory/shared_memory_mapping.h"
14 #include "base/values.h"
15 #include "content/public/common/common_param_traits.h"
16 #include "content/public/common/referrer.h"
17 #include "ipc/ipc_message_macros.h"
18 #include "ui/gfx/ipc/gfx_param_traits.h"
19 
20 // Singly-included section for enums and custom IPC traits.
21 #ifndef CEF_LIBCEF_COMMON_CEF_MESSAGES_H_
22 #define CEF_LIBCEF_COMMON_CEF_MESSAGES_H_
23 
24 namespace IPC {
25 
26 // Extracted from chrome/common/automation_messages.h.
27 template <>
28 struct ParamTraits<scoped_refptr<net::UploadData>> {
29   typedef scoped_refptr<net::UploadData> param_type;
30   static void Write(base::Pickle* m, const param_type& p);
31   static bool Read(const base::Pickle* m,
32                    base::PickleIterator* iter,
33                    param_type* r);
34   static void Log(const param_type& p, std::string* l);
35 };
36 
37 }  // namespace IPC
38 
39 #endif  // CEF_LIBCEF_COMMON_CEF_MESSAGES_H_
40 
41 // TODO(cef): Re-using the message start for extensions may be problematic in
42 // the future. It would be better if ipc_message_utils.h contained a value
43 // reserved for consumers of the content API.
44 // See: http://crbug.com/110911
45 #define IPC_MESSAGE_START ExtensionMsgStart
46 
47 // Common types.
48 
49 // Parameters structure for a request.
50 IPC_STRUCT_BEGIN(Cef_Request_Params)
51   // Unique request id to match requests and responses.
52   IPC_STRUCT_MEMBER(int, request_id)
53 
54   // True if the request is user-initiated instead of internal.
55   IPC_STRUCT_MEMBER(bool, user_initiated)
56 
57   // True if a response is expected.
58   IPC_STRUCT_MEMBER(bool, expect_response)
59 
60   // Message name.
61   IPC_STRUCT_MEMBER(std::string, name)
62 
63   // List of message arguments.
64   IPC_STRUCT_MEMBER(base::ListValue, arguments)
65 IPC_STRUCT_END()
66 
67 // Parameters structure for a response.
68 IPC_STRUCT_BEGIN(Cef_Response_Params)
69   // Unique request id to match requests and responses.
70   IPC_STRUCT_MEMBER(int, request_id)
71 
72   // True if a response ack is expected.
73   IPC_STRUCT_MEMBER(bool, expect_response_ack)
74 
75   // True on success.
76   IPC_STRUCT_MEMBER(bool, success)
77 
78   // Response or error string depending on the value of |success|.
79   IPC_STRUCT_MEMBER(std::string, response)
80 IPC_STRUCT_END()
81 
82 // Parameters structure for a cross-origin white list entry.
83 IPC_STRUCT_BEGIN(Cef_CrossOriginWhiteListEntry_Params)
84   IPC_STRUCT_MEMBER(std::string, source_origin)
85   IPC_STRUCT_MEMBER(std::string, target_protocol)
86   IPC_STRUCT_MEMBER(std::string, target_domain)
87   IPC_STRUCT_MEMBER(bool, allow_target_subdomains)
88 IPC_STRUCT_END()
89 
90 // Parameters structure for a draggable region.
91 IPC_STRUCT_BEGIN(Cef_DraggableRegion_Params)
92   IPC_STRUCT_MEMBER(gfx::Rect, bounds)
93   IPC_STRUCT_MEMBER(bool, draggable)
94 IPC_STRUCT_END()
95 
96 // Messages sent from the browser to the renderer.
97 
98 // Parameters for a resource request.
99 IPC_STRUCT_BEGIN(CefMsg_LoadRequest_Params)
100   // The request method: GET, POST, etc.
101   IPC_STRUCT_MEMBER(std::string, method)
102 
103   // The requested URL.
104   IPC_STRUCT_MEMBER(GURL, url)
105 
106   // The URL to send in the "Referer" header field. Can be empty if there is
107   // no referrer.
108   IPC_STRUCT_MEMBER(GURL, referrer)
109   // One of the cef_referrer_policy_t values.
110   IPC_STRUCT_MEMBER(int, referrer_policy)
111 
112   // Usually the URL of the document in the top-level window, which may be
113   // checked by the third-party cookie blocking policy. Leaving it empty may
114   // lead to undesired cookie blocking. Third-party cookie blocking can be
115   // bypassed by setting site_for_cookies = url, but this should ideally
116   // only be done if there really is no way to determine the correct value.
117   IPC_STRUCT_MEMBER(net::SiteForCookies, site_for_cookies)
118 
119   // Additional HTTP request headers.
120   IPC_STRUCT_MEMBER(std::string, headers)
121 
122   // net::URLRequest load flags (0 by default).
123   IPC_STRUCT_MEMBER(int, load_flags)
124 
125   // Optional upload data (may be null).
126   IPC_STRUCT_MEMBER(scoped_refptr<net::UploadData>, upload_data)
127 IPC_STRUCT_END()
128 
129 // Tell the renderer to load a request.
130 IPC_MESSAGE_ROUTED1(CefMsg_LoadRequest, CefMsg_LoadRequest_Params)
131 
132 // Sent when the browser has a request for the renderer. The renderer may
133 // respond with a CefHostMsg_Response.
134 IPC_MESSAGE_ROUTED1(CefMsg_Request, Cef_Request_Params)
135 
136 // Optional message sent in response to a CefHostMsg_Request.
137 IPC_MESSAGE_ROUTED1(CefMsg_Response, Cef_Response_Params)
138 
139 // Optional Ack message sent to the browser to notify that a CefHostMsg_Response
140 // has been processed.
141 IPC_MESSAGE_ROUTED1(CefMsg_ResponseAck, int /* request_id */)
142 
143 // Tells the renderer that loading has stopped.
144 IPC_MESSAGE_ROUTED0(CefMsg_DidStopLoading)
145 
146 // Notification that a move or resize of the renderer's containing window has
147 // started. Used on Windows and Linux with the Alloy runtime, and was
148 // previously handled by RenderViewHost::NotifyMoveOrResizeStarted() prior to
149 // that method's removal in https://crbug.com/1051648.
150 IPC_MESSAGE_ROUTED0(CefMsg_MoveOrResizeStarted)
151 
152 // Sent to child processes to add or remove a cross-origin whitelist entry.
153 IPC_MESSAGE_CONTROL2(CefProcessMsg_ModifyCrossOriginWhitelistEntry,
154                      bool /* add */,
155                      Cef_CrossOriginWhiteListEntry_Params /* params */)
156 
157 // Sent to child processes to clear the cross-origin whitelist.
158 IPC_MESSAGE_CONTROL0(CefProcessMsg_ClearCrossOriginWhitelist)
159 
160 // Messages sent from the renderer to the browser.
161 
162 // Parameters for a newly created render thread.
163 IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewRenderThreadInfo_Params)
164   IPC_STRUCT_MEMBER(std::vector<Cef_CrossOriginWhiteListEntry_Params>,
165                     cross_origin_whitelist_entries)
166 IPC_STRUCT_END()
167 
168 // Retrieve information about a newly created render thread.
169 IPC_SYNC_MESSAGE_CONTROL0_1(
170     CefProcessHostMsg_GetNewRenderThreadInfo,
171     CefProcessHostMsg_GetNewRenderThreadInfo_Params /* params*/)
172 
173 // Parameters for a newly created browser window.
174 IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewBrowserInfo_Params)
175   IPC_STRUCT_MEMBER(int, browser_id)
176   IPC_STRUCT_MEMBER(bool, is_popup)
177   IPC_STRUCT_MEMBER(bool, is_windowless)
178   IPC_STRUCT_MEMBER(bool, is_guest_view)
179   IPC_STRUCT_MEMBER(base::DictionaryValue, extra_info)
180 IPC_STRUCT_END()
181 
182 // Retrieve information about a newly created browser.
183 IPC_SYNC_MESSAGE_CONTROL1_1(
184     CefProcessHostMsg_GetNewBrowserInfo,
185     int /* render_frame_routing_id */,
186     CefProcessHostMsg_GetNewBrowserInfo_Params /* params*/)
187 
188 // Sent by the renderer when the frame can begin receiving messages.
189 IPC_MESSAGE_ROUTED0(CefHostMsg_FrameAttached)
190 
191 // Sent when a frame has finished loading. Based on ViewHostMsg_DidFinishLoad.
192 IPC_MESSAGE_ROUTED2(CefHostMsg_DidFinishLoad,
193                     GURL /* validated_url */,
194                     int /* http_status_code */)
195 
196 // Sent when the renderer has a request for the browser. The browser may respond
197 // with a CefMsg_Response.
198 IPC_MESSAGE_ROUTED1(CefHostMsg_Request, Cef_Request_Params)
199 
200 // Optional message sent in response to a CefMsg_Request.
201 IPC_MESSAGE_ROUTED1(CefHostMsg_Response, Cef_Response_Params)
202 
203 // Optional Ack message sent to the browser to notify that a CefMsg_Response
204 // has been processed.
205 IPC_MESSAGE_ROUTED1(CefHostMsg_ResponseAck, int /* request_id */)
206 
207 // Sent by the renderer when the draggable regions are updated.
208 IPC_MESSAGE_ROUTED1(CefHostMsg_UpdateDraggableRegions,
209                     std::vector<Cef_DraggableRegion_Params> /* regions */)
210