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