bd6f38b5072027d56440991c16a748949871b811
[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/cursors/webcursor.h"
18 #include "content/common/edit_command.h"
19 #include "content/common/frame_param_macros.h"
20 #include "content/public/common/browser_plugin_permission_type.h"
21 #include "content/public/common/common_param_traits.h"
22 #include "content/public/common/drop_data.h"
23 #include "ipc/ipc_channel_handle.h"
24 #include "ipc/ipc_message_macros.h"
25 #include "ipc/ipc_message_utils.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 "third_party/skia/include/core/SkBitmap.h"
30 #include "ui/gfx/point.h"
31 #include "ui/gfx/rect.h"
32 #include "ui/gfx/size.h"
33 #include "url/gurl.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 // Sets the name of the guest window to the provided |name|.
259 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetName,
260                     int /* instance_id */,
261                     std::string /* name */)
262
263 // Sends a PointerLock Lock ACK to the BrowserPluginGuest.
264 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_LockMouse_ACK,
265                     int /* instance_id */,
266                     bool /* succeeded */)
267
268 // Sends a PointerLock Unlock ACK to the BrowserPluginGuest.
269 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_UnlockMouse_ACK, int /* instance_id */)
270
271 // Sent when plugin's position has changed without UpdateRect.
272 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_UpdateGeometry,
273                     int /* instance_id */,
274                     gfx::Rect /* view_rect */)
275
276 // -----------------------------------------------------------------------------
277 // These messages are from the guest renderer to the browser process
278
279 // A embedder sends this message to the browser when it wants
280 // to resize a guest plugin container so that the guest is relaid out
281 // according to the new size.
282 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ResizeGuest,
283                     int /* instance_id*/,
284                     BrowserPluginHostMsg_ResizeGuest_Params)
285
286 // -----------------------------------------------------------------------------
287 // These messages are from the browser process to the embedder.
288
289 // This message is sent from the browser process to the embedder render process
290 // in response to a request to allocate an instance ID. The |request_id| is used
291 // to route the response to the requestor.
292 IPC_MESSAGE_ROUTED2(BrowserPluginMsg_AllocateInstanceID_ACK,
293                     int /* request_id */,
294                     int /* instance_id */)
295
296 // This message is sent in response to a completed attachment of a guest
297 // to a BrowserPlugin. This message carries information about the guest
298 // that is used to update the attributes of the browser plugin.
299 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_Attach_ACK,
300                      int /* instance_id */,
301                      BrowserPluginMsg_Attach_ACK_Params /* params */)
302
303 // Once the swapped out guest RenderView has been created in the embedder render
304 // process, the browser process informs the embedder of its routing ID.
305 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_GuestContentWindowReady,
306                      int /* instance_id */,
307                      int /* source_routing_id */)
308
309 // When the guest crashes, the browser process informs the embedder through this
310 // message.
311 IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone,
312                      int /* instance_id */)
313
314 // When the user tabs to the end of the tab stops of a guest, the browser
315 // process informs the embedder to tab out of the browser plugin.
316 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_AdvanceFocus,
317                      int /* instance_id */,
318                      bool /* reverse */)
319
320 // When the guest starts/stops listening to touch events, it needs to notify the
321 // plugin in the embedder about it.
322 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_ShouldAcceptTouchEvents,
323                      int /* instance_id */,
324                      bool /* accept */)
325
326 // Inform the embedder of the cursor the guest wishes to display.
327 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetCursor,
328                      int /* instance_id */,
329                      content::WebCursor /* cursor */)
330
331 // The guest has damage it wants to convey to the embedder so that it can
332 // update its backing store.
333 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdateRect,
334                      int /* instance_id */,
335                      BrowserPluginMsg_UpdateRect_Params)
336
337 IPC_MESSAGE_CONTROL4(BrowserPluginMsg_CopyFromCompositingSurface,
338                      int /* instance_id */,
339                      int /* request_id */,
340                      gfx::Rect  /* source_rect */,
341                      gfx::Size  /* dest_size */)
342
343 // Informs BrowserPlugin of a new name set for the top-level guest frame.
344 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdatedName,
345                      int /* instance_id */,
346                      std::string /* name */)
347
348 // Guest renders into an FBO with textures provided by the embedder.
349 // BrowserPlugin shares mostly the same logic as out-of-process RenderFrames but
350 // because BrowserPlugins implement custom a second level of routing logic,
351 // the IPCs need to be annotated with an extra instance_id. These messages
352 // provide that extra id.
353 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_BuffersSwapped,
354                      int /* instance_id */,
355                      FrameMsg_BuffersSwapped_Params /* params */)
356
357 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_CompositorFrameSwapped,
358                      int /* instance_id */,
359                      FrameMsg_CompositorFrameSwapped_Params /* params */)
360
361 // Forwards a PointerLock Unlock request to the BrowserPlugin.
362 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock,
363                      int /* instance_id */,
364                      bool /* enable */)
365
366 // See comment about BrowserPluginMsg_BuffersSwapped and
367 // BrowserPluginMsg_CompositorFrameSwapped for how these related
368 // to the FrameHostMsg variants.
369 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_BuffersSwappedACK,
370                     int /* instance_id */,
371                     FrameHostMsg_BuffersSwappedACK_Params /* params */)
372
373 // Acknowledge that we presented an ubercomp frame.
374 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_CompositorFrameSwappedACK,
375                     int /* instance_id */,
376                     FrameHostMsg_CompositorFrameSwappedACK_Params /* params */)