Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / common / browser_plugin / browser_plugin_messages.h
1 // Copyright (c) 2012 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 // Multiply-included message header, no traditional include guard.
6
7 #include <string>
8
9 #include "base/basictypes.h"
10 #include "base/memory/shared_memory.h"
11 #include "base/process/process.h"
12 #include "base/values.h"
13 #include "cc/output/compositor_frame.h"
14 #include "cc/output/compositor_frame_ack.h"
15 #include "content/common/content_export.h"
16 #include "content/common/content_param_traits.h"
17 #include "content/common/edit_command.h"
18 #include "content/common/frame_param_macros.h"
19 #include "content/public/common/browser_plugin_permission_type.h"
20 #include "content/public/common/common_param_traits.h"
21 #include "content/public/common/drop_data.h"
22 #include "ipc/ipc_channel_handle.h"
23 #include "ipc/ipc_message_macros.h"
24 #include "ipc/ipc_message_utils.h"
25 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
27 #include "third_party/WebKit/public/web/WebDragOperation.h"
28 #include "third_party/WebKit/public/web/WebDragStatus.h"
29 #include "ui/gfx/point.h"
30 #include "ui/gfx/rect.h"
31 #include "ui/gfx/size.h"
32 #include "url/gurl.h"
33 #include "webkit/common/cursors/webcursor.h"
34
35 #undef IPC_MESSAGE_EXPORT
36 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
37
38 #define IPC_MESSAGE_START BrowserPluginMsgStart
39
40
41 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDragStatus, blink::WebDragStatusLast)
42
43 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_AutoSize_Params)
44   IPC_STRUCT_MEMBER(bool, enable)
45   IPC_STRUCT_MEMBER(gfx::Size, max_size)
46   IPC_STRUCT_MEMBER(gfx::Size, min_size)
47 IPC_STRUCT_END()
48
49 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_ResizeGuest_Params)
50   // Indicates whether the parameters have been populated or not.
51   IPC_STRUCT_MEMBER(bool, size_changed)
52   // The sequence number used to uniquely identify the damage buffer for the
53   // current container size.
54   IPC_STRUCT_MEMBER(uint32, damage_buffer_sequence_id)
55   // The handle to use to map the damage buffer in the browser process.
56   IPC_STRUCT_MEMBER(base::SharedMemoryHandle, damage_buffer_handle)
57   // The size of the damage buffer.
58   IPC_STRUCT_MEMBER(size_t, damage_buffer_size)
59   // The new rect of the guest view area.
60   IPC_STRUCT_MEMBER(gfx::Rect, view_rect)
61   // Indicates the scale factor of the embedder WebView.
62   IPC_STRUCT_MEMBER(float, scale_factor)
63   // Indicates a request for a full repaint of the page.
64   // This is required for switching from compositing to the software
65   // rendering path.
66   IPC_STRUCT_MEMBER(bool, repaint)
67 IPC_STRUCT_END()
68
69 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params)
70   IPC_STRUCT_MEMBER(std::string, storage_partition_id)
71   IPC_STRUCT_MEMBER(bool, persist_storage)
72   IPC_STRUCT_MEMBER(bool, focused)
73   IPC_STRUCT_MEMBER(bool, visible)
74   IPC_STRUCT_MEMBER(bool, opaque)
75   IPC_STRUCT_MEMBER(std::string, name)
76   IPC_STRUCT_MEMBER(std::string, src)
77   IPC_STRUCT_MEMBER(GURL, embedder_frame_url)
78   IPC_STRUCT_MEMBER(BrowserPluginHostMsg_AutoSize_Params, auto_size_params)
79   IPC_STRUCT_MEMBER(BrowserPluginHostMsg_ResizeGuest_Params,
80                     resize_guest_params)
81 IPC_STRUCT_END()
82
83 IPC_STRUCT_BEGIN(BrowserPluginMsg_Attach_ACK_Params)
84   IPC_STRUCT_MEMBER(std::string, storage_partition_id)
85   IPC_STRUCT_MEMBER(bool, persist_storage)
86   IPC_STRUCT_MEMBER(std::string, name)
87 IPC_STRUCT_END()
88
89 IPC_STRUCT_BEGIN(BrowserPluginMsg_UpdateRect_Params)
90   // The sequence number of the damage buffer used by the browser process.
91   IPC_STRUCT_MEMBER(uint32, damage_buffer_sequence_id)
92
93   // The position and size of the bitmap.
94   IPC_STRUCT_MEMBER(gfx::Rect, bitmap_rect)
95
96   // The scroll delta.  Only one of the delta components can be non-zero, and if
97   // they are both zero, then it means there is no scrolling and the scroll_rect
98   // is ignored.
99   IPC_STRUCT_MEMBER(gfx::Vector2d, scroll_delta)
100
101   // The rectangular region to scroll.
102   IPC_STRUCT_MEMBER(gfx::Rect, scroll_rect)
103
104   // The scroll offset of the render view.
105   IPC_STRUCT_MEMBER(gfx::Point, scroll_offset)
106
107   // The regions of the bitmap (in view coords) that contain updated pixels.
108   // In the case of scrolling, this includes the scroll damage rect.
109   IPC_STRUCT_MEMBER(std::vector<gfx::Rect>, copy_rects)
110
111   // The size of the RenderView when this message was generated.  This is
112   // included so the host knows how large the view is from the perspective of
113   // the renderer process.  This is necessary in case a resize operation is in
114   // progress. If auto-resize is enabled, this should update the corresponding
115   // view size.
116   IPC_STRUCT_MEMBER(gfx::Size, view_size)
117
118   // All the above coordinates are in DIP. This is the scale factor needed
119   // to convert them to pixels.
120   IPC_STRUCT_MEMBER(float, scale_factor)
121
122   // Is this UpdateRect an ACK to a resize request?
123   IPC_STRUCT_MEMBER(bool, is_resize_ack)
124
125   // Used in HW accelerated case to switch between sending an UpdateRect_ACK
126   // with the new size or just resizing.
127   IPC_STRUCT_MEMBER(bool, needs_ack)
128 IPC_STRUCT_END()
129
130 // Browser plugin messages
131
132 // -----------------------------------------------------------------------------
133 // These messages are from the embedder to the browser process.
134
135 // This message is sent to the browser process to request an instance ID.
136 // |request_id| is used by BrowserPluginEmbedder to route the response back
137 // to its origin.
138 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_AllocateInstanceID,
139                     int /* request_id */)
140
141 // This message is sent from BrowserPlugin to BrowserPluginGuest to issue an
142 // edit command.
143 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ExecuteEditCommand,
144                      int /* instance_id */,
145                      std::string /* command */)
146
147 // This message must be sent just before sending a key event.
148 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
149                     int /* instance_id */,
150                     std::vector<content::EditCommand> /* edit_commands */)
151
152 // This message is sent from BrowserPlugin to BrowserPluginGuest whenever IME
153 // composition state is updated.
154 IPC_MESSAGE_ROUTED5(
155     BrowserPluginHostMsg_ImeSetComposition,
156     int /* instance_id */,
157     std::string /* text */,
158     std::vector<blink::WebCompositionUnderline> /* underlines */,
159     int /* selectiont_start */,
160     int /* selection_end */)
161
162 // This message is sent from BrowserPlugin to BrowserPluginGuest to notify that
163 // confirming the current composition is requested.
164 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_ImeConfirmComposition,
165                     int /* instance_id */,
166                     std::string /* text */,
167                     bool /* keep selection */)
168
169 // Deletes the current selection plus the specified number of characters before
170 // and after the selection or caret.
171 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_ExtendSelectionAndDelete,
172                     int /* instance_id */,
173                     int /* before */,
174                     int /* after */)
175
176 // This message is sent to the browser process to enable or disable autosize
177 // mode.
178 IPC_MESSAGE_ROUTED3(
179     BrowserPluginHostMsg_SetAutoSize,
180     int /* instance_id */,
181     BrowserPluginHostMsg_AutoSize_Params /* auto_size_params */,
182     BrowserPluginHostMsg_ResizeGuest_Params /* resize_guest_params */)
183
184 // This message is sent to the browser process to indicate that a BrowserPlugin
185 // has taken ownership of the lifetime of the guest of the given |instance_id|.
186 // |params| is the state of the BrowserPlugin taking ownership of
187 // the guest. If a guest doesn't already exist with the given |instance_id|,
188 // a new one will be created.
189 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_Attach,
190                     int /* instance_id */,
191                     BrowserPluginHostMsg_Attach_Params /* params */,
192                     base::DictionaryValue /* extra_params */)
193
194 // Tells the guest to focus or defocus itself.
195 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetFocus,
196                     int /* instance_id */,
197                     bool /* enable */)
198
199 // Sends an input event to the guest.
200 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_HandleInputEvent,
201                     int /* instance_id */,
202                     gfx::Rect /* guest_window_rect */,
203                     IPC::WebInputEventPointer /* event */)
204
205 // An ACK to the guest process letting it know that the embedder has handled
206 // the previous frame and is ready for the next frame. If the guest sent the
207 // embedder a bitmap that does not match the size of the BrowserPlugin's
208 // container, the BrowserPlugin requests a new size as well.
209 IPC_MESSAGE_ROUTED4(BrowserPluginHostMsg_UpdateRect_ACK,
210     int /* instance_id */,
211     bool /* needs_ack */,
212     BrowserPluginHostMsg_AutoSize_Params /* auto_size_params */,
213     BrowserPluginHostMsg_ResizeGuest_Params /* resize_guest_params */)
214
215 // A BrowserPlugin sends this to BrowserPluginEmbedder (browser process) when it
216 // wants to navigate to a given src URL. If a guest WebContents already exists,
217 // it will navigate that WebContents. If not, it will create the WebContents,
218 // associate it with the BrowserPluginGuest, and navigate it to the requested
219 // URL.
220 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_NavigateGuest,
221                     int /* instance_id*/,
222                     std::string /* src */)
223
224 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck,
225                     int /* instance_id */,
226                     int /* request_id */,
227                     SkBitmap);
228
229 // Notify the guest renderer that some resources given to the embededer
230 // are not used any more.
231 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ReclaimCompositorResources,
232                     int /* instance_id */,
233                     FrameHostMsg_ReclaimCompositorResources_Params /* params */)
234
235 // When a BrowserPlugin has been removed from the embedder's DOM, it informs
236 // the browser process to cleanup the guest.
237 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_PluginDestroyed,
238                     int /* instance_id */)
239
240 // Tells the guest it has been shown or hidden.
241 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetVisibility,
242                     int /* instance_id */,
243                     bool /* visible */)
244
245 // Tells the guest to change its background opacity.
246 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetContentsOpaque,
247                     int /* instance_id */,
248                     bool /* opaque */)
249
250 // Tells the guest that a drag event happened on the plugin.
251 IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_DragStatusUpdate,
252                     int /* instance_id */,
253                     blink::WebDragStatus /* drag_status */,
254                     content::DropData /* drop_data */,
255                     blink::WebDragOperationsMask /* operation_mask */,
256                     gfx::Point /* plugin_location */)
257
258 // Response to BrowserPluginMsg_PluginAtPositionRequest, returns the browser
259 // plugin instace id and the coordinates (local to the plugin).
260 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_PluginAtPositionResponse,
261                     int /* instance_id */,
262                     int /* request_id */,
263                     gfx::Point /* position */)
264
265 // Sets the name of the guest window to the provided |name|.
266 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetName,
267                     int /* instance_id */,
268                     std::string /* name */)
269
270 // Sends a PointerLock Lock ACK to the BrowserPluginGuest.
271 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_LockMouse_ACK,
272                     int /* instance_id */,
273                     bool /* succeeded */)
274
275 // Sends a PointerLock Unlock ACK to the BrowserPluginGuest.
276 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_UnlockMouse_ACK, int /* instance_id */)
277
278 // Sent when plugin's position has changed without UpdateRect.
279 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_UpdateGeometry,
280                     int /* instance_id */,
281                     gfx::Rect /* view_rect */)
282
283 // -----------------------------------------------------------------------------
284 // These messages are from the guest renderer to the browser process
285
286 // A embedder sends this message to the browser when it wants
287 // to resize a guest plugin container so that the guest is relaid out
288 // according to the new size.
289 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ResizeGuest,
290                     int /* instance_id*/,
291                     BrowserPluginHostMsg_ResizeGuest_Params)
292
293 // -----------------------------------------------------------------------------
294 // These messages are from the browser process to the embedder.
295
296 // This message is sent from the browser process to the embedder render process
297 // in response to a request to allocate an instance ID. The |request_id| is used
298 // to route the response to the requestor.
299 IPC_MESSAGE_ROUTED2(BrowserPluginMsg_AllocateInstanceID_ACK,
300                     int /* request_id */,
301                     int /* instance_id */)
302
303 // This message is sent in response to a completed attachment of a guest
304 // to a BrowserPlugin. This message carries information about the guest
305 // that is used to update the attributes of the browser plugin.
306 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_Attach_ACK,
307                      int /* instance_id */,
308                      BrowserPluginMsg_Attach_ACK_Params /* params */)
309
310 // Once the swapped out guest RenderView has been created in the embedder render
311 // process, the browser process informs the embedder of its routing ID.
312 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_GuestContentWindowReady,
313                      int /* instance_id */,
314                      int /* source_routing_id */)
315
316 // When the guest crashes, the browser process informs the embedder through this
317 // message.
318 IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone,
319                      int /* instance_id */)
320
321 // When the user tabs to the end of the tab stops of a guest, the browser
322 // process informs the embedder to tab out of the browser plugin.
323 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_AdvanceFocus,
324                      int /* instance_id */,
325                      bool /* reverse */)
326
327 // When the guest starts/stops listening to touch events, it needs to notify the
328 // plugin in the embedder about it.
329 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_ShouldAcceptTouchEvents,
330                      int /* instance_id */,
331                      bool /* accept */)
332
333 // Inform the embedder of the cursor the guest wishes to display.
334 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetCursor,
335                      int /* instance_id */,
336                      WebCursor /* cursor */)
337
338 // The guest has damage it wants to convey to the embedder so that it can
339 // update its backing store.
340 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdateRect,
341                      int /* instance_id */,
342                      BrowserPluginMsg_UpdateRect_Params)
343
344 IPC_MESSAGE_CONTROL4(BrowserPluginMsg_CopyFromCompositingSurface,
345                      int /* instance_id */,
346                      int /* request_id */,
347                      gfx::Rect  /* source_rect */,
348                      gfx::Size  /* dest_size */)
349
350 // Requests the renderer to find out if a browser plugin is at position
351 // (|x|, |y|) within the embedder.
352 // The response message is BrowserPluginHostMsg_PluginAtPositionResponse.
353 // The |request_id| uniquely identifies a request from an embedder.
354 IPC_MESSAGE_ROUTED2(BrowserPluginMsg_PluginAtPositionRequest,
355                     int /* request_id */,
356                     gfx::Point /* position */)
357
358 // Informs BrowserPlugin of a new name set for the top-level guest frame.
359 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdatedName,
360                      int /* instance_id */,
361                      std::string /* name */)
362
363 // Guest renders into an FBO with textures provided by the embedder.
364 // BrowserPlugin shares mostly the same logic as out-of-process RenderFrames but
365 // because BrowserPlugins implement custom a second level of routing logic,
366 // the IPCs need to be annotated with an extra instance_id. These messages
367 // provide that extra id.
368 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_BuffersSwapped,
369                      int /* instance_id */,
370                      FrameMsg_BuffersSwapped_Params /* params */)
371
372 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_CompositorFrameSwapped,
373                      int /* instance_id */,
374                      FrameMsg_CompositorFrameSwapped_Params /* params */)
375
376 // Forwards a PointerLock Unlock request to the BrowserPlugin.
377 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock,
378                      int /* instance_id */,
379                      bool /* enable */)
380
381 // See comment about BrowserPluginMsg_BuffersSwapped and
382 // BrowserPluginMsg_CompositorFrameSwapped for how these related
383 // to the FrameHostMsg variants.
384 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_BuffersSwappedACK,
385                     int /* instance_id */,
386                     FrameHostMsg_BuffersSwappedACK_Params /* params */)
387
388 // Acknowledge that we presented an ubercomp frame.
389 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_CompositorFrameSwappedACK,
390                     int /* instance_id */,
391                     FrameHostMsg_CompositorFrameSwappedACK_Params /* params */)