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.
5 // Multiply-included message header, no traditional include guard.
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/public/common/browser_plugin_permission_type.h"
19 #include "content/public/common/common_param_traits.h"
20 #include "content/public/common/drop_data.h"
21 #include "ipc/ipc_channel_handle.h"
22 #include "ipc/ipc_message_macros.h"
23 #include "ipc/ipc_message_utils.h"
24 #include "third_party/WebKit/public/web/WebDragOperation.h"
25 #include "third_party/WebKit/public/web/WebDragStatus.h"
26 #include "ui/gfx/point.h"
27 #include "ui/gfx/rect.h"
28 #include "ui/gfx/size.h"
30 #include "webkit/common/cursors/webcursor.h"
32 #undef IPC_MESSAGE_EXPORT
33 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
35 #define IPC_MESSAGE_START BrowserPluginMsgStart
38 IPC_ENUM_TRAITS(WebKit::WebDragStatus)
40 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_AutoSize_Params)
41 IPC_STRUCT_MEMBER(bool, enable)
42 IPC_STRUCT_MEMBER(gfx::Size, max_size)
43 IPC_STRUCT_MEMBER(gfx::Size, min_size)
46 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_ResizeGuest_Params)
47 // Indicates whether the parameters have been populated or not.
48 IPC_STRUCT_MEMBER(bool, size_changed)
49 // The sequence number used to uniquely identify the damage buffer for the
50 // current container size.
51 IPC_STRUCT_MEMBER(uint32, damage_buffer_sequence_id)
52 // The handle to use to map the damage buffer in the browser process.
53 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, damage_buffer_handle)
54 // The size of the damage buffer.
55 IPC_STRUCT_MEMBER(size_t, damage_buffer_size)
56 // The new rect of the guest view area.
57 IPC_STRUCT_MEMBER(gfx::Rect, view_rect)
58 // Indicates the scale factor of the embedder WebView.
59 IPC_STRUCT_MEMBER(float, scale_factor)
60 // Indicates a request for a full repaint of the page.
61 // This is required for switching from compositing to the software
63 IPC_STRUCT_MEMBER(bool, repaint)
66 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params)
67 IPC_STRUCT_MEMBER(std::string, storage_partition_id)
68 IPC_STRUCT_MEMBER(bool, persist_storage)
69 IPC_STRUCT_MEMBER(bool, focused)
70 IPC_STRUCT_MEMBER(bool, visible)
71 IPC_STRUCT_MEMBER(std::string, name)
72 IPC_STRUCT_MEMBER(std::string, src)
73 IPC_STRUCT_MEMBER(GURL, embedder_frame_url)
74 IPC_STRUCT_MEMBER(BrowserPluginHostMsg_AutoSize_Params, auto_size_params)
75 IPC_STRUCT_MEMBER(BrowserPluginHostMsg_ResizeGuest_Params,
79 IPC_STRUCT_BEGIN(BrowserPluginMsg_Attach_ACK_Params)
80 IPC_STRUCT_MEMBER(std::string, storage_partition_id)
81 IPC_STRUCT_MEMBER(bool, persist_storage)
82 IPC_STRUCT_MEMBER(std::string, name)
85 IPC_STRUCT_BEGIN(BrowserPluginMsg_BuffersSwapped_Params)
86 IPC_STRUCT_MEMBER(gfx::Size, size)
87 IPC_STRUCT_MEMBER(gfx::Rect, damage_rect)
88 IPC_STRUCT_MEMBER(std::string, mailbox_name)
89 IPC_STRUCT_MEMBER(int, route_id)
90 IPC_STRUCT_MEMBER(int, host_id)
93 IPC_STRUCT_BEGIN(BrowserPluginMsg_UpdateRect_Params)
94 // The sequence number of the damage buffer used by the browser process.
95 IPC_STRUCT_MEMBER(uint32, damage_buffer_sequence_id)
97 // The position and size of the bitmap.
98 IPC_STRUCT_MEMBER(gfx::Rect, bitmap_rect)
100 // The scroll delta. Only one of the delta components can be non-zero, and if
101 // they are both zero, then it means there is no scrolling and the scroll_rect
103 IPC_STRUCT_MEMBER(gfx::Vector2d, scroll_delta)
105 // The rectangular region to scroll.
106 IPC_STRUCT_MEMBER(gfx::Rect, scroll_rect)
108 // The scroll offset of the render view.
109 IPC_STRUCT_MEMBER(gfx::Point, scroll_offset)
111 // The regions of the bitmap (in view coords) that contain updated pixels.
112 // In the case of scrolling, this includes the scroll damage rect.
113 IPC_STRUCT_MEMBER(std::vector<gfx::Rect>, copy_rects)
115 // The size of the RenderView when this message was generated. This is
116 // included so the host knows how large the view is from the perspective of
117 // the renderer process. This is necessary in case a resize operation is in
118 // progress. If auto-resize is enabled, this should update the corresponding
120 IPC_STRUCT_MEMBER(gfx::Size, view_size)
122 // All the above coordinates are in DIP. This is the scale factor needed
123 // to convert them to pixels.
124 IPC_STRUCT_MEMBER(float, scale_factor)
126 // Is this UpdateRect an ACK to a resize request?
127 IPC_STRUCT_MEMBER(bool, is_resize_ack)
129 // Used in HW accelerated case to switch between sending an UpdateRect_ACK
130 // with the new size or just resizing.
131 IPC_STRUCT_MEMBER(bool, needs_ack)
134 // Browser plugin messages
136 // -----------------------------------------------------------------------------
137 // These messages are from the embedder to the browser process.
139 // This message is sent to the browser process to request an instance ID.
140 // |request_id| is used by BrowserPluginEmbedder to route the response back
142 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_AllocateInstanceID,
143 int /* request_id */)
145 // This message is sent from BrowserPlugin to BrowserPluginGuest to issue an
147 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ExecuteEditCommand,
148 int /* instance_id */,
149 std::string /* command */)
151 // This message must be sent just before sending a key event.
152 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
153 int /* instance_id */,
154 std::vector<content::EditCommand> /* edit_commands */)
156 // This message is sent to the browser process to enable or disable autosize
159 BrowserPluginHostMsg_SetAutoSize,
160 int /* instance_id */,
161 BrowserPluginHostMsg_AutoSize_Params /* auto_size_params */,
162 BrowserPluginHostMsg_ResizeGuest_Params /* resize_guest_params */)
164 // This message is sent to the browser process to indicate that a BrowserPlugin
165 // has taken ownership of the lifetime of the guest of the given |instance_id|.
166 // |params| is the state of the BrowserPlugin taking ownership of
167 // the guest. If a guest doesn't already exist with the given |instance_id|,
168 // a new one will be created.
169 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_Attach,
170 int /* instance_id */,
171 BrowserPluginHostMsg_Attach_Params /* params */,
172 base::DictionaryValue /* extra_params */)
174 // Tells the guest to focus or defocus itself.
175 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetFocus,
176 int /* instance_id */,
179 // Sends an input event to the guest.
180 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_HandleInputEvent,
181 int /* instance_id */,
182 gfx::Rect /* guest_window_rect */,
183 IPC::WebInputEventPointer /* event */)
185 // An ACK to the guest process letting it know that the embedder has handled
186 // the previous frame and is ready for the next frame. If the guest sent the
187 // embedder a bitmap that does not match the size of the BrowserPlugin's
188 // container, the BrowserPlugin requests a new size as well.
189 IPC_MESSAGE_ROUTED4(BrowserPluginHostMsg_UpdateRect_ACK,
190 int /* instance_id */,
191 bool /* needs_ack */,
192 BrowserPluginHostMsg_AutoSize_Params /* auto_size_params */,
193 BrowserPluginHostMsg_ResizeGuest_Params /* resize_guest_params */)
195 // A BrowserPlugin sends this to BrowserPluginEmbedder (browser process) when it
196 // wants to navigate to a given src URL. If a guest WebContents already exists,
197 // it will navigate that WebContents. If not, it will create the WebContents,
198 // associate it with the BrowserPluginGuest, and navigate it to the requested
200 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_NavigateGuest,
201 int /* instance_id*/,
202 std::string /* src */)
204 // Acknowledge that we presented a HW buffer and provide a sync point
205 // to specify the location in the command stream when the compositor
206 // is no longer using it.
207 IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_BuffersSwappedACK,
208 int /* instance_id */,
210 int /* gpu_host_id */,
211 std::string /* mailbox_name */,
212 uint32 /* sync_point */)
214 // Acknowledge that we presented an ubercomp frame.
215 IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_CompositorFrameACK,
216 int /* instance_id */,
218 uint32 /* output_surface_id */,
219 int /* renderer_host_id */,
220 cc::CompositorFrameAck /* ack */)
222 // When a BrowserPlugin has been removed from the embedder's DOM, it informs
223 // the browser process to cleanup the guest.
224 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_PluginDestroyed,
225 int /* instance_id */)
227 // Tells the guest it has been shown or hidden.
228 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetVisibility,
229 int /* instance_id */,
232 // Tells the guest that a drag event happened on the plugin.
233 IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_DragStatusUpdate,
234 int /* instance_id */,
235 WebKit::WebDragStatus /* drag_status */,
236 content::DropData /* drop_data */,
237 WebKit::WebDragOperationsMask /* operation_mask */,
238 gfx::Point /* plugin_location */)
240 // Response to BrowserPluginMsg_PluginAtPositionRequest, returns the browser
241 // plugin instace id and the coordinates (local to the plugin).
242 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_PluginAtPositionResponse,
243 int /* instance_id */,
244 int /* request_id */,
245 gfx::Point /* position */)
247 // Sets the name of the guest window to the provided |name|.
248 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetName,
249 int /* instance_id */,
250 std::string /* name */)
252 // Sends a PointerLock Lock ACK to the BrowserPluginGuest.
253 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_LockMouse_ACK,
254 int /* instance_id */,
255 bool /* succeeded */)
257 // Sends a PointerLock Unlock ACK to the BrowserPluginGuest.
258 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_UnlockMouse_ACK, int /* instance_id */)
260 // Sent when plugin's position has changed without UpdateRect.
261 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_UpdateGeometry,
262 int /* instance_id */,
263 gfx::Rect /* view_rect */)
265 // -----------------------------------------------------------------------------
266 // These messages are from the guest renderer to the browser process
268 // A embedder sends this message to the browser when it wants
269 // to resize a guest plugin container so that the guest is relaid out
270 // according to the new size.
271 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ResizeGuest,
272 int /* instance_id*/,
273 BrowserPluginHostMsg_ResizeGuest_Params)
275 // -----------------------------------------------------------------------------
276 // These messages are from the browser process to the embedder.
278 // This message is sent from the browser process to the embedder render process
279 // in response to a request to allocate an instance ID. The |request_id| is used
280 // to route the response to the requestor.
281 IPC_MESSAGE_ROUTED2(BrowserPluginMsg_AllocateInstanceID_ACK,
282 int /* request_id */,
283 int /* instance_id */)
285 // This message is sent in response to a completed attachment of a guest
286 // to a BrowserPlugin. This message carries information about the guest
287 // that is used to update the attributes of the browser plugin.
288 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_Attach_ACK,
289 int /* instance_id */,
290 BrowserPluginMsg_Attach_ACK_Params /* params */)
292 // Once the swapped out guest RenderView has been created in the embedder render
293 // process, the browser process informs the embedder of its routing ID.
294 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_GuestContentWindowReady,
295 int /* instance_id */,
296 int /* source_routing_id */)
298 // When the guest crashes, the browser process informs the embedder through this
300 IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone,
301 int /* instance_id */)
303 // When the user tabs to the end of the tab stops of a guest, the browser
304 // process informs the embedder to tab out of the browser plugin.
305 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_AdvanceFocus,
306 int /* instance_id */,
309 // When the guest starts/stops listening to touch events, it needs to notify the
310 // plugin in the embedder about it.
311 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_ShouldAcceptTouchEvents,
312 int /* instance_id */,
315 // Inform the embedder of the cursor the guest wishes to display.
316 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetCursor,
317 int /* instance_id */,
318 WebCursor /* cursor */)
320 // The guest has damage it wants to convey to the embedder so that it can
321 // update its backing store.
322 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdateRect,
323 int /* instance_id */,
324 BrowserPluginMsg_UpdateRect_Params)
326 // Requests the renderer to find out if a browser plugin is at position
327 // (|x|, |y|) within the embedder.
328 // The response message is BrowserPluginHostMsg_PluginAtPositionResponse.
329 // The |request_id| uniquely identifies a request from an embedder.
330 IPC_MESSAGE_ROUTED2(BrowserPluginMsg_PluginAtPositionRequest,
331 int /* request_id */,
332 gfx::Point /* position */)
334 // Informs BrowserPlugin of a new name set for the top-level guest frame.
335 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdatedName,
336 int /* instance_id */,
337 std::string /* name */)
339 // Guest renders into an FBO with textures provided by the embedder.
340 // When HW accelerated buffers are swapped in the guest, the message
341 // is forwarded to the embedder to notify it of a new texture
342 // available for compositing.
343 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_BuffersSwapped,
344 int /* instance_id */,
345 BrowserPluginMsg_BuffersSwapped_Params)
347 IPC_MESSAGE_CONTROL5(BrowserPluginMsg_CompositorFrameSwapped,
348 int /* instance_id */,
349 cc::CompositorFrame /* frame */,
351 uint32 /* output_surface_id */,
352 int /* renderer_host_id */)
354 // Forwards a PointerLock Unlock request to the BrowserPlugin.
355 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock,
356 int /* instance_id */,