03471701ca785efa756754b416d694cd7ff40c2a
[platform/framework/web/crosswalk.git] / src / content / common / frame_messages.h
1 // Copyright 2013 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.
4
5 // IPC messages for interacting with frames.
6 // Multiply-included message file, hence no include guard.
7
8 #include "content/common/content_export.h"
9 #include "content/common/content_param_traits.h"
10 #include "content/common/frame_message_enums.h"
11 #include "content/common/frame_param.h"
12 #include "content/common/navigation_gesture.h"
13 #include "content/public/common/common_param_traits.h"
14 #include "content/public/common/context_menu_params.h"
15 #include "content/public/common/frame_navigate_params.h"
16 #include "content/public/common/page_state.h"
17 #include "ipc/ipc_message_macros.h"
18 #include "url/gurl.h"
19
20 #undef IPC_MESSAGE_EXPORT
21 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
22
23 #define IPC_MESSAGE_START FrameMsgStart
24
25 IPC_ENUM_TRAITS_MAX_VALUE(FrameMsg_Navigate_Type::Value,
26                           FrameMsg_Navigate_Type::NAVIGATE_TYPE_LAST)
27 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContextMenuData::MediaType,
28                           blink::WebContextMenuData::MediaTypeLast)
29
30 IPC_ENUM_TRAITS_MAX_VALUE(ui::MenuSourceType, ui::MENU_SOURCE_TYPE_LAST)
31
32 IPC_STRUCT_TRAITS_BEGIN(content::ContextMenuParams)
33   IPC_STRUCT_TRAITS_MEMBER(media_type)
34   IPC_STRUCT_TRAITS_MEMBER(x)
35   IPC_STRUCT_TRAITS_MEMBER(y)
36   IPC_STRUCT_TRAITS_MEMBER(link_url)
37   IPC_STRUCT_TRAITS_MEMBER(link_text)
38   IPC_STRUCT_TRAITS_MEMBER(unfiltered_link_url)
39   IPC_STRUCT_TRAITS_MEMBER(src_url)
40   IPC_STRUCT_TRAITS_MEMBER(has_image_contents)
41   IPC_STRUCT_TRAITS_MEMBER(page_url)
42   IPC_STRUCT_TRAITS_MEMBER(keyword_url)
43   IPC_STRUCT_TRAITS_MEMBER(frame_url)
44   IPC_STRUCT_TRAITS_MEMBER(frame_id)
45   IPC_STRUCT_TRAITS_MEMBER(frame_page_state)
46   IPC_STRUCT_TRAITS_MEMBER(media_flags)
47   IPC_STRUCT_TRAITS_MEMBER(selection_text)
48   IPC_STRUCT_TRAITS_MEMBER(misspelled_word)
49   IPC_STRUCT_TRAITS_MEMBER(misspelling_hash)
50   IPC_STRUCT_TRAITS_MEMBER(dictionary_suggestions)
51   IPC_STRUCT_TRAITS_MEMBER(speech_input_enabled)
52   IPC_STRUCT_TRAITS_MEMBER(spellcheck_enabled)
53   IPC_STRUCT_TRAITS_MEMBER(is_editable)
54   IPC_STRUCT_TRAITS_MEMBER(writing_direction_default)
55   IPC_STRUCT_TRAITS_MEMBER(writing_direction_left_to_right)
56   IPC_STRUCT_TRAITS_MEMBER(writing_direction_right_to_left)
57   IPC_STRUCT_TRAITS_MEMBER(edit_flags)
58   IPC_STRUCT_TRAITS_MEMBER(security_info)
59   IPC_STRUCT_TRAITS_MEMBER(frame_charset)
60   IPC_STRUCT_TRAITS_MEMBER(referrer_policy)
61   IPC_STRUCT_TRAITS_MEMBER(custom_context)
62   IPC_STRUCT_TRAITS_MEMBER(custom_items)
63   IPC_STRUCT_TRAITS_MEMBER(source_type)
64 #if defined(OS_ANDROID)
65   IPC_STRUCT_TRAITS_MEMBER(selection_start)
66   IPC_STRUCT_TRAITS_MEMBER(selection_end)
67 #endif
68 IPC_STRUCT_TRAITS_END()
69
70 IPC_STRUCT_TRAITS_BEGIN(content::CustomContextMenuContext)
71   IPC_STRUCT_TRAITS_MEMBER(is_pepper_menu)
72   IPC_STRUCT_TRAITS_MEMBER(request_id)
73   IPC_STRUCT_TRAITS_MEMBER(render_widget_id)
74 IPC_STRUCT_TRAITS_END()
75
76 IPC_STRUCT_BEGIN(FrameHostMsg_DidFailProvisionalLoadWithError_Params)
77   // The frame ID for the failure report.
78   IPC_STRUCT_MEMBER(int64, frame_id)
79   // The WebFrame's uniqueName().
80   IPC_STRUCT_MEMBER(base::string16, frame_unique_name)
81   // True if this is the top-most frame.
82   IPC_STRUCT_MEMBER(bool, is_main_frame)
83   // Error code as reported in the DidFailProvisionalLoad callback.
84   IPC_STRUCT_MEMBER(int, error_code)
85   // An error message generated from the error_code. This can be an empty
86   // string if we were unable to find a meaningful description.
87   IPC_STRUCT_MEMBER(base::string16, error_description)
88   // The URL that the error is reported for.
89   IPC_STRUCT_MEMBER(GURL, url)
90   // True if the failure is the result of navigating to a POST again
91   // and we're going to show the POST interstitial.
92   IPC_STRUCT_MEMBER(bool, showing_repost_interstitial)
93 IPC_STRUCT_END()
94
95 IPC_STRUCT_TRAITS_BEGIN(content::FrameNavigateParams)
96   IPC_STRUCT_TRAITS_MEMBER(page_id)
97   IPC_STRUCT_TRAITS_MEMBER(url)
98   IPC_STRUCT_TRAITS_MEMBER(base_url)
99   IPC_STRUCT_TRAITS_MEMBER(referrer)
100   IPC_STRUCT_TRAITS_MEMBER(transition)
101   IPC_STRUCT_TRAITS_MEMBER(redirects)
102   IPC_STRUCT_TRAITS_MEMBER(should_update_history)
103   IPC_STRUCT_TRAITS_MEMBER(searchable_form_url)
104   IPC_STRUCT_TRAITS_MEMBER(searchable_form_encoding)
105   IPC_STRUCT_TRAITS_MEMBER(contents_mime_type)
106   IPC_STRUCT_TRAITS_MEMBER(socket_address)
107 IPC_STRUCT_TRAITS_END()
108
109 // Parameters structure for FrameHostMsg_DidCommitProvisionalLoad, which has
110 // too many data parameters to be reasonably put in a predefined IPC message.
111 IPC_STRUCT_BEGIN_WITH_PARENT(FrameHostMsg_DidCommitProvisionalLoad_Params,
112                              content::FrameNavigateParams)
113   IPC_STRUCT_TRAITS_PARENT(content::FrameNavigateParams)
114   // The frame ID for this navigation. The frame ID uniquely identifies the
115   // frame the navigation happened in for a given renderer.
116   IPC_STRUCT_MEMBER(int64, frame_id)
117
118   // The WebFrame's uniqueName().
119   IPC_STRUCT_MEMBER(base::string16, frame_unique_name)
120
121   // Information regarding the security of the connection (empty if the
122   // connection was not secure).
123   IPC_STRUCT_MEMBER(std::string, security_info)
124
125   // The gesture that initiated this navigation.
126   IPC_STRUCT_MEMBER(content::NavigationGesture, gesture)
127
128   // True if this was a post request.
129   IPC_STRUCT_MEMBER(bool, is_post)
130
131   // The POST body identifier. -1 if it doesn't exist.
132   IPC_STRUCT_MEMBER(int64, post_id)
133
134   // Whether the frame navigation resulted in no change to the documents within
135   // the page. For example, the navigation may have just resulted in scrolling
136   // to a named anchor.
137   IPC_STRUCT_MEMBER(bool, was_within_same_page)
138
139   // The status code of the HTTP request.
140   IPC_STRUCT_MEMBER(int, http_status_code)
141
142   // True if the connection was proxied.  In this case, socket_address
143   // will represent the address of the proxy, rather than the remote host.
144   IPC_STRUCT_MEMBER(bool, was_fetched_via_proxy)
145
146   // Serialized history item state to store in the navigation entry.
147   IPC_STRUCT_MEMBER(content::PageState, page_state)
148
149   // Original request's URL.
150   IPC_STRUCT_MEMBER(GURL, original_request_url)
151
152   // User agent override used to navigate.
153   IPC_STRUCT_MEMBER(bool, is_overriding_user_agent)
154
155   // Notifies the browser that for this navigation, the session history was
156   // successfully cleared.
157   IPC_STRUCT_MEMBER(bool, history_list_was_cleared)
158 IPC_STRUCT_END()
159
160 IPC_STRUCT_BEGIN(FrameMsg_Navigate_Params)
161   // The page_id for this navigation, or -1 if it is a new navigation.  Back,
162   // Forward, and Reload navigations should have a valid page_id.  If the load
163   // succeeds, then this page_id will be reflected in the resultant
164   // FrameHostMsg_DidCommitProvisionalLoad message.
165   IPC_STRUCT_MEMBER(int32, page_id)
166
167   // If page_id is -1, then pending_history_list_offset will also be -1.
168   // Otherwise, it contains the offset into the history list corresponding to
169   // the current navigation.
170   IPC_STRUCT_MEMBER(int, pending_history_list_offset)
171
172   // Informs the RenderView of where its current page contents reside in
173   // session history and the total size of the session history list.
174   IPC_STRUCT_MEMBER(int, current_history_list_offset)
175   IPC_STRUCT_MEMBER(int, current_history_list_length)
176
177   // Informs the RenderView the session history should be cleared. In that
178   // case, the RenderView needs to notify the browser that the clearing was
179   // succesful when the navigation commits.
180   IPC_STRUCT_MEMBER(bool, should_clear_history_list)
181
182   // The URL to load.
183   IPC_STRUCT_MEMBER(GURL, url)
184
185   // Base URL for use in WebKit's SubstituteData.
186   // Is only used with data: URLs.
187   IPC_STRUCT_MEMBER(GURL, base_url_for_data_url)
188
189   // History URL for use in WebKit's SubstituteData.
190   // Is only used with data: URLs.
191   IPC_STRUCT_MEMBER(GURL, history_url_for_data_url)
192
193   // The URL to send in the "Referer" header field. Can be empty if there is
194   // no referrer.
195   IPC_STRUCT_MEMBER(content::Referrer, referrer)
196
197   // Any redirect URLs that occurred before |url|. Useful for cross-process
198   // navigations; defaults to empty.
199   IPC_STRUCT_MEMBER(std::vector<GURL>, redirects)
200
201   // The type of transition.
202   IPC_STRUCT_MEMBER(content::PageTransition, transition)
203
204   // Informs the RenderView the pending navigation should replace the current
205   // history entry when it commits. This is used for cross-process redirects so
206   // the transferred navigation can recover the navigation state.
207   IPC_STRUCT_MEMBER(bool, should_replace_current_entry)
208
209   // Opaque history state (received by ViewHostMsg_UpdateState).
210   IPC_STRUCT_MEMBER(content::PageState, page_state)
211
212   // Type of navigation.
213   IPC_STRUCT_MEMBER(FrameMsg_Navigate_Type::Value, navigation_type)
214
215   // The time the request was created
216   IPC_STRUCT_MEMBER(base::Time, request_time)
217
218   // Extra headers (separated by \n) to send during the request.
219   IPC_STRUCT_MEMBER(std::string, extra_headers)
220
221   // The following two members identify a previous request that has been
222   // created before this navigation is being transferred to a new render view.
223   // This serves the purpose of recycling the old request.
224   // Unless this refers to a transferred navigation, these values are -1 and -1.
225   IPC_STRUCT_MEMBER(int, transferred_request_child_id)
226   IPC_STRUCT_MEMBER(int, transferred_request_request_id)
227
228   // Whether or not we should allow the url to download.
229   IPC_STRUCT_MEMBER(bool, allow_download)
230
231   // Whether or not the user agent override string should be used.
232   IPC_STRUCT_MEMBER(bool, is_overriding_user_agent)
233
234   // True if this was a post request.
235   IPC_STRUCT_MEMBER(bool, is_post)
236
237   // If is_post is true, holds the post_data information from browser. Empty
238   // otherwise.
239   IPC_STRUCT_MEMBER(std::vector<unsigned char>, browser_initiated_post_data)
240
241   // Whether or not this url should be allowed to access local file://
242   // resources.
243   IPC_STRUCT_MEMBER(bool, can_load_local_resources)
244
245   // If not empty, which frame to navigate.
246   IPC_STRUCT_MEMBER(std::string, frame_to_navigate)
247
248   // The navigationStart time to expose to JS for this navigation.
249   IPC_STRUCT_MEMBER(base::TimeTicks, browser_navigation_start)
250 IPC_STRUCT_END()
251
252 // -----------------------------------------------------------------------------
253 // Messages sent from the browser to the renderer.
254
255 // When HW accelerated buffers are swapped in an out-of-process child frame
256 // renderer, the message is forwarded to the embedding frame to notify it of
257 // a new texture available for compositing. When the buffer has finished
258 // presenting, a FrameHostMsg_BuffersSwappedACK should be sent back to
259 // gpu host that produced this buffer.
260 //
261 // This is used in the non-ubercomp HW accelerated compositing path.
262 IPC_MESSAGE_ROUTED1(FrameMsg_BuffersSwapped,
263                     FrameMsg_BuffersSwapped_Params /* params */)
264
265 // Notifies the embedding frame that a new CompositorFrame is ready to be
266 // presented. When the frame finishes presenting, a matching
267 // FrameHostMsg_CompositorFrameSwappedACK should be sent back to the
268 // RenderViewHost that was produced the CompositorFrame.
269 //
270 // This is used in the ubercomp compositing path.
271 IPC_MESSAGE_ROUTED1(FrameMsg_CompositorFrameSwapped,
272                     FrameMsg_CompositorFrameSwapped_Params /* params */)
273
274 // Notifies the embedding frame that the process rendering the child frame's
275 // contents has terminated.
276 IPC_MESSAGE_ROUTED0(FrameMsg_ChildFrameProcessGone)
277
278 // Sent in response to a FrameHostMsg_ContextMenu to let the renderer know that
279 // the menu has been closed.
280 IPC_MESSAGE_ROUTED1(FrameMsg_ContextMenuClosed,
281                     content::CustomContextMenuContext /* custom_context */)
282
283 // Executes custom context menu action that was provided from Blink.
284 IPC_MESSAGE_ROUTED2(FrameMsg_CustomContextMenuAction,
285                     content::CustomContextMenuContext /* custom_context */,
286                     unsigned /* action */)
287
288 // Tells the renderer to perform the specified navigation, interrupting any
289 // existing navigation.
290 IPC_MESSAGE_ROUTED1(FrameMsg_Navigate, FrameMsg_Navigate_Params)
291
292 // -----------------------------------------------------------------------------
293 // Messages sent from the renderer to the browser.
294
295 // Sent by the renderer when a child frame is created in the renderer. The
296 // |parent_frame_id| and |frame_id| are NOT routing ids. They are
297 // renderer-allocated identifiers used for tracking a frame's creation.
298 //
299 // Each of these messages will have a corresponding FrameHostMsg_Detach message
300 // sent when the frame is detached from the DOM.
301 //
302 // TOOD(ajwong): replace parent_render_frame_id and frame_id with just the
303 // routing ids.
304 IPC_SYNC_MESSAGE_CONTROL4_1(FrameHostMsg_CreateChildFrame,
305                             int32 /* parent_render_frame_id */,
306                             int64 /* parent_frame_id */,
307                             int64 /* frame_id */,
308                             std::string /* frame_name */,
309                             int /* new_render_frame_id */)
310
311 // Sent by the renderer to the parent RenderFrameHost when a child frame is
312 // detached from the DOM.
313 IPC_MESSAGE_ROUTED2(FrameHostMsg_Detach,
314                     int64 /* parent_frame_id */,
315                     int64 /* frame_id */)
316
317 // Sent when the renderer starts a provisional load for a frame.
318 IPC_MESSAGE_ROUTED4(FrameHostMsg_DidStartProvisionalLoadForFrame,
319                     int64 /* frame_id */,
320                     int64 /* parent_frame_id */,
321                     bool /* true if it is the main frame */,
322                     GURL /* url */)
323
324 // Sent when the renderer fails a provisional load with an error.
325 IPC_MESSAGE_ROUTED1(FrameHostMsg_DidFailProvisionalLoadWithError,
326                     FrameHostMsg_DidFailProvisionalLoadWithError_Params)
327
328 // Sent when a provisional load on the main frame redirects.
329 IPC_MESSAGE_ROUTED3(FrameHostMsg_DidRedirectProvisionalLoad,
330                     int /* page_id */,
331                     GURL /* source_url*/,
332                     GURL /* target_url */)
333
334 // Notifies the browser that a frame in the view has changed. This message
335 // has a lot of parameters and is packed/unpacked by functions defined in
336 // render_messages.h.
337 IPC_MESSAGE_ROUTED1(FrameHostMsg_DidCommitProvisionalLoad,
338                     FrameHostMsg_DidCommitProvisionalLoad_Params)
339
340 // Notifies the browser that a document has been loaded.
341 IPC_MESSAGE_ROUTED1(FrameHostMsg_DidFinishDocumentLoad,
342                     int64 /* frame_id */)
343
344 IPC_MESSAGE_ROUTED5(FrameHostMsg_DidFailLoadWithError,
345                     int64 /* frame_id */,
346                     GURL /* validated_url */,
347                     bool /* is_main_frame */,
348                     int /* error_code */,
349                     base::string16 /* error_description */)
350
351 // Sent when the renderer starts loading the page. This corresponds to
352 // Blink's notion of the throbber starting. Note that sometimes you may get
353 // duplicates of these during a single load.
354 IPC_MESSAGE_ROUTED0(FrameHostMsg_DidStartLoading)
355
356 // Sent when the renderer is done loading a page. This corresponds to Blink's
357 // notion of the throbber stopping.
358 IPC_MESSAGE_ROUTED0(FrameHostMsg_DidStopLoading)
359
360 // Sent to the browser when the renderer detects it is blocked on a pepper
361 // plugin message for too long. This is also sent when it becomes unhung
362 // (according to the value of is_hung). The browser can give the user the
363 // option of killing the plugin.
364 IPC_MESSAGE_ROUTED3(FrameHostMsg_PepperPluginHung,
365                     int /* plugin_child_id */,
366                     base::FilePath /* path */,
367                     bool /* is_hung */)
368
369 // Sent by the renderer process to indicate that a plugin instance has crashed.
370 // Note: |plugin_pid| should not be trusted. The corresponding process has
371 // probably died. Moreover, the ID may have been reused by a new process. Any
372 // usage other than displaying it in a prompt to the user is very likely to be
373 // wrong.
374 IPC_MESSAGE_ROUTED2(FrameHostMsg_PluginCrashed,
375                     base::FilePath /* plugin_path */,
376                     base::ProcessId /* plugin_pid */)
377
378 // Return information about a plugin for the given URL and MIME
379 // type. If there is no matching plugin, |found| is false.
380 // |actual_mime_type| is the actual mime type supported by the
381 // found plugin.
382 IPC_SYNC_MESSAGE_CONTROL4_3(FrameHostMsg_GetPluginInfo,
383                             int /* render_frame_id */,
384                             GURL /* url */,
385                             GURL /* page_url */,
386                             std::string /* mime_type */,
387                             bool /* found */,
388                             content::WebPluginInfo /* plugin info */,
389                             std::string /* actual_mime_type */)
390
391 // A renderer sends this to the browser process when it wants to
392 // create a plugin.  The browser will create the plugin process if
393 // necessary, and will return a handle to the channel on success.
394 // On error an empty string is returned.
395 IPC_SYNC_MESSAGE_CONTROL4_2(FrameHostMsg_OpenChannelToPlugin,
396                             int /* render_frame_id */,
397                             GURL /* url */,
398                             GURL /* page_url */,
399                             std::string /* mime_type */,
400                             IPC::ChannelHandle /* channel_handle */,
401                             content::WebPluginInfo /* info */)
402
403 // Acknowledge that we presented a HW buffer and provide a sync point
404 // to specify the location in the command stream when the compositor
405 // is no longer using it.
406 //
407 // See FrameMsg_BuffersSwapped.
408 IPC_MESSAGE_ROUTED1(FrameHostMsg_BuffersSwappedACK,
409                     FrameHostMsg_BuffersSwappedACK_Params /* params */)
410
411 // Acknowledge that we presented an ubercomp frame.
412 //
413 // See FrameMsg_CompositorFrameSwapped
414 IPC_MESSAGE_ROUTED1(FrameHostMsg_CompositorFrameSwappedACK,
415                     FrameHostMsg_CompositorFrameSwappedACK_Params /* params */)
416
417 // Indicates that the current frame has swapped out, after a SwapOut message.
418 IPC_MESSAGE_ROUTED0(FrameHostMsg_SwapOut_ACK)
419
420 IPC_MESSAGE_ROUTED1(FrameHostMsg_ReclaimCompositorResources,
421                     FrameHostMsg_ReclaimCompositorResources_Params /* params */)
422
423 // Forwards an input event to a child.
424 // TODO(nick): Temporary bridge, revisit once the browser process can route
425 // input directly to subframes. http://crbug.com/339659
426 IPC_MESSAGE_ROUTED1(FrameHostMsg_ForwardInputEvent,
427                     IPC::WebInputEventPointer /* event */)
428
429 // Instructs the frame to swap out for a cross-site transition, including
430 // running the unload event handler. Expects a SwapOut_ACK message when
431 // finished.
432 IPC_MESSAGE_ROUTED0(FrameMsg_SwapOut)
433
434 // Used to tell the parent that the user right clicked on an area of the
435 // content area, and a context menu should be shown for it. The params
436 // object contains information about the node(s) that were selected when the
437 // user right clicked.
438 IPC_MESSAGE_ROUTED1(FrameHostMsg_ContextMenu, content::ContextMenuParams)