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 // Multiply-included message file, hence no include guard. 6 7 #include "build/build_config.h" 8 #include "content/child/plugin_param_traits.h" 9 #include "content/common/content_export.h" 10 #include "content/common/content_param_traits.h" 11 #include "content/public/common/common_param_traits.h" 12 #include "ipc/ipc_channel_handle.h" 13 #include "ipc/ipc_message_macros.h" 14 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/rect.h" 16 #include "webkit/common/cursors/webcursor.h" 17 18 #if defined(OS_POSIX) 19 #include "base/file_descriptor_posix.h" 20 #endif 21 22 #undef IPC_MESSAGE_EXPORT 23 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT 24 25 #define IPC_MESSAGE_START PluginMsgStart 26 27 IPC_STRUCT_BEGIN(PluginMsg_Init_Params) 28 IPC_STRUCT_MEMBER(GURL, url) 29 IPC_STRUCT_MEMBER(GURL, page_url) 30 IPC_STRUCT_MEMBER(std::vector<std::string>, arg_names) 31 IPC_STRUCT_MEMBER(std::vector<std::string>, arg_values) 32 IPC_STRUCT_MEMBER(bool, load_manually) 33 IPC_STRUCT_MEMBER(int, host_render_view_routing_id) 34 IPC_STRUCT_END() 35 36 IPC_STRUCT_BEGIN(PluginHostMsg_URLRequest_Params) 37 IPC_STRUCT_MEMBER(std::string, url) 38 IPC_STRUCT_MEMBER(std::string, method) 39 IPC_STRUCT_MEMBER(std::string, target) 40 IPC_STRUCT_MEMBER(std::vector<char>, buffer) 41 IPC_STRUCT_MEMBER(int, notify_id) 42 IPC_STRUCT_MEMBER(bool, popups_allowed) 43 IPC_STRUCT_MEMBER(bool, notify_redirects) 44 IPC_STRUCT_END() 45 46 IPC_STRUCT_BEGIN(PluginMsg_DidReceiveResponseParams) 47 IPC_STRUCT_MEMBER(unsigned long, id) 48 IPC_STRUCT_MEMBER(std::string, mime_type) 49 IPC_STRUCT_MEMBER(std::string, headers) 50 IPC_STRUCT_MEMBER(uint32, expected_length) 51 IPC_STRUCT_MEMBER(uint32, last_modified) 52 IPC_STRUCT_MEMBER(bool, request_is_seekable) 53 IPC_STRUCT_END() 54 55 IPC_STRUCT_BEGIN(PluginMsg_FetchURL_Params) 56 IPC_STRUCT_MEMBER(unsigned long, resource_id) 57 IPC_STRUCT_MEMBER(int, notify_id) 58 IPC_STRUCT_MEMBER(GURL, url) 59 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies) 60 IPC_STRUCT_MEMBER(std::string, method) 61 IPC_STRUCT_MEMBER(std::vector<char>, post_data) 62 IPC_STRUCT_MEMBER(GURL, referrer) 63 IPC_STRUCT_MEMBER(bool, notify_redirect) 64 IPC_STRUCT_MEMBER(bool, is_plugin_src_load) 65 IPC_STRUCT_MEMBER(int, render_view_id) 66 IPC_STRUCT_END() 67 68 IPC_STRUCT_BEGIN(PluginMsg_UpdateGeometry_Param) 69 IPC_STRUCT_MEMBER(gfx::Rect, window_rect) 70 IPC_STRUCT_MEMBER(gfx::Rect, clip_rect) 71 IPC_STRUCT_MEMBER(TransportDIB::Handle, windowless_buffer0) 72 IPC_STRUCT_MEMBER(TransportDIB::Handle, windowless_buffer1) 73 IPC_STRUCT_MEMBER(int, windowless_buffer_index) 74 IPC_STRUCT_END() 75 76 //----------------------------------------------------------------------------- 77 // Plugin messages 78 // These are messages sent from the renderer process to the plugin process. 79 // Tells the plugin process to create a new plugin instance with the given 80 // id. A corresponding WebPluginDelegateStub is created which hosts the 81 // WebPluginDelegateImpl. 82 IPC_SYNC_MESSAGE_CONTROL1_1(PluginMsg_CreateInstance, 83 std::string /* mime_type */, 84 int /* instance_id */) 85 86 // The WebPluginDelegateProxy sends this to the WebPluginDelegateStub in its 87 // destructor, so that the stub deletes the actual WebPluginDelegateImpl 88 // object that it's hosting. 89 IPC_SYNC_MESSAGE_CONTROL1_0(PluginMsg_DestroyInstance, 90 int /* instance_id */) 91 92 IPC_SYNC_MESSAGE_CONTROL0_1(PluginMsg_GenerateRouteID, 93 int /* id */) 94 95 // The messages below all map to WebPluginDelegate methods. 96 IPC_SYNC_MESSAGE_ROUTED1_2(PluginMsg_Init, 97 PluginMsg_Init_Params, 98 bool /* transparent */, 99 bool /* result */) 100 101 // Used to synchronously request a paint for windowless plugins. 102 IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_Paint, 103 gfx::Rect /* damaged_rect */) 104 105 // Sent by the renderer after it paints from its backing store so that the 106 // plugin knows it can send more invalidates. 107 IPC_MESSAGE_ROUTED0(PluginMsg_DidPaint) 108 109 IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_GetPluginScriptableObject, 110 int /* route_id */) 111 112 // Gets the form value of the plugin instance synchronously. 113 IPC_SYNC_MESSAGE_ROUTED0_2(PluginMsg_GetFormValue, 114 base::string16 /* value */, 115 bool /* success */) 116 117 IPC_MESSAGE_ROUTED3(PluginMsg_DidFinishLoadWithReason, 118 GURL /* url */, 119 int /* reason */, 120 int /* notify_id */) 121 122 // Updates the plugin location. 123 IPC_MESSAGE_ROUTED1(PluginMsg_UpdateGeometry, 124 PluginMsg_UpdateGeometry_Param) 125 126 // A synchronous version of above. 127 IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_UpdateGeometrySync, 128 PluginMsg_UpdateGeometry_Param) 129 130 IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_SetFocus, 131 bool /* focused */) 132 133 IPC_SYNC_MESSAGE_ROUTED1_2(PluginMsg_HandleInputEvent, 134 IPC::WebInputEventPointer /* event */, 135 bool /* handled */, 136 WebCursor /* cursor type*/) 137 138 IPC_MESSAGE_ROUTED1(PluginMsg_SetContentAreaFocus, 139 bool /* has_focus */) 140 141 IPC_SYNC_MESSAGE_ROUTED3_0(PluginMsg_WillSendRequest, 142 unsigned long /* id */, 143 GURL /* url */, 144 int /* http_status_code */) 145 146 IPC_MESSAGE_ROUTED1(PluginMsg_DidReceiveResponse, 147 PluginMsg_DidReceiveResponseParams) 148 149 IPC_MESSAGE_ROUTED3(PluginMsg_DidReceiveData, 150 unsigned long /* id */, 151 std::vector<char> /* buffer */, 152 int /* data_offset */) 153 154 IPC_MESSAGE_ROUTED1(PluginMsg_DidFinishLoading, 155 unsigned long /* id */) 156 157 IPC_MESSAGE_ROUTED1(PluginMsg_DidFail, 158 unsigned long /* id */) 159 160 IPC_MESSAGE_ROUTED4(PluginMsg_SendJavaScriptStream, 161 GURL /* url */, 162 std::string /* result */, 163 bool /* success */, 164 int /* notify_id */) 165 166 IPC_MESSAGE_ROUTED2(PluginMsg_DidReceiveManualResponse, 167 GURL /* url */, 168 PluginMsg_DidReceiveResponseParams) 169 170 IPC_MESSAGE_ROUTED1(PluginMsg_DidReceiveManualData, 171 std::vector<char> /* buffer */) 172 173 IPC_MESSAGE_ROUTED0(PluginMsg_DidFinishManualLoading) 174 175 IPC_MESSAGE_ROUTED0(PluginMsg_DidManualLoadFail) 176 177 IPC_MESSAGE_ROUTED3(PluginMsg_HandleURLRequestReply, 178 unsigned long /* resource_id */, 179 GURL /* url */, 180 int /* notify_id */) 181 182 IPC_MESSAGE_ROUTED2(PluginMsg_HTTPRangeRequestReply, 183 unsigned long /* resource_id */, 184 int /* range_request_id */) 185 186 IPC_MESSAGE_CONTROL1(PluginMsg_SignalModalDialogEvent, 187 int /* render_view_id */) 188 189 IPC_MESSAGE_CONTROL1(PluginMsg_ResetModalDialogEvent, 190 int /* render_view_id */) 191 192 IPC_MESSAGE_ROUTED1(PluginMsg_FetchURL, 193 PluginMsg_FetchURL_Params) 194 195 IPC_MESSAGE_CONTROL1(PluginHostMsg_DidAbortLoading, 196 int /* render_view_id */) 197 198 #if defined(OS_WIN) 199 IPC_MESSAGE_ROUTED4(PluginMsg_ImeCompositionUpdated, 200 base::string16 /* text */, 201 std::vector<int> /* clauses */, 202 std::vector<int>, /* target */ 203 int /* cursor_position */) 204 205 IPC_MESSAGE_ROUTED1(PluginMsg_ImeCompositionCompleted, 206 base::string16 /* text */) 207 #endif 208 209 #if defined(OS_MACOSX) 210 IPC_MESSAGE_ROUTED1(PluginMsg_SetWindowFocus, 211 bool /* has_focus */) 212 213 IPC_MESSAGE_ROUTED0(PluginMsg_ContainerHidden) 214 215 IPC_MESSAGE_ROUTED3(PluginMsg_ContainerShown, 216 gfx::Rect /* window_frame */, 217 gfx::Rect /* view_frame */, 218 bool /* has_focus */) 219 220 IPC_MESSAGE_ROUTED2(PluginMsg_WindowFrameChanged, 221 gfx::Rect /* window_frame */, 222 gfx::Rect /* view_frame */) 223 224 IPC_MESSAGE_ROUTED1(PluginMsg_ImeCompositionCompleted, 225 base::string16 /* text */) 226 227 // This message, used only on 10.6 and later, transmits the "fake" 228 // window handle allocated by the browser on behalf of the renderer 229 // to the GPU plugin. 230 IPC_MESSAGE_ROUTED1(PluginMsg_SetFakeAcceleratedSurfaceWindowHandle, 231 gfx::PluginWindowHandle /* window */) 232 #endif 233 234 //----------------------------------------------------------------------------- 235 // PluginHost messages 236 // These are messages sent from the plugin process to the renderer process. 237 // They all map to the corresponding WebPlugin methods. 238 // Sends the plugin window information to the renderer. 239 // The window parameter is a handle to the window if the plugin is a windowed 240 // plugin. It is NULL for windowless plugins. 241 IPC_SYNC_MESSAGE_ROUTED1_0(PluginHostMsg_SetWindow, 242 gfx::PluginWindowHandle /* window */) 243 244 IPC_MESSAGE_ROUTED1(PluginHostMsg_URLRequest, 245 PluginHostMsg_URLRequest_Params) 246 247 IPC_MESSAGE_ROUTED1(PluginHostMsg_CancelResource, 248 int /* id */) 249 250 IPC_MESSAGE_ROUTED1(PluginHostMsg_InvalidateRect, 251 gfx::Rect /* rect */) 252 253 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetWindowScriptNPObject, 254 int /* route id */, 255 bool /* success */) 256 257 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetPluginElement, 258 int /* route id */, 259 bool /* success */) 260 261 IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_ResolveProxy, 262 GURL /* url */, 263 bool /* result */, 264 std::string /* proxy list */) 265 266 IPC_MESSAGE_ROUTED3(PluginHostMsg_SetCookie, 267 GURL /* url */, 268 GURL /* first_party_for_cookies */, 269 std::string /* cookie */) 270 271 IPC_SYNC_MESSAGE_ROUTED2_1(PluginHostMsg_GetCookies, 272 GURL /* url */, 273 GURL /* first_party_for_cookies */, 274 std::string /* cookies */) 275 276 IPC_MESSAGE_ROUTED0(PluginHostMsg_CancelDocumentLoad) 277 278 IPC_MESSAGE_ROUTED3(PluginHostMsg_InitiateHTTPRangeRequest, 279 std::string /* url */, 280 std::string /* range_info */, 281 int /* range_request_id */) 282 283 IPC_MESSAGE_ROUTED0(PluginHostMsg_DidStartLoading) 284 IPC_MESSAGE_ROUTED0(PluginHostMsg_DidStopLoading) 285 286 IPC_MESSAGE_ROUTED2(PluginHostMsg_DeferResourceLoading, 287 unsigned long /* resource_id */, 288 bool /* defer */) 289 290 IPC_SYNC_MESSAGE_CONTROL1_0(PluginHostMsg_SetException, 291 std::string /* message */) 292 293 IPC_MESSAGE_CONTROL0(PluginHostMsg_PluginShuttingDown) 294 295 IPC_MESSAGE_ROUTED2(PluginHostMsg_URLRedirectResponse, 296 bool /* allow */, 297 int /* resource_id */) 298 299 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_CheckIfRunInsecureContent, 300 GURL /* url */, 301 bool /* result */) 302 303 #if defined(OS_WIN) 304 // The modal_loop_pump_messages_event parameter is an event handle which is 305 // passed in for windowless plugins and is used to indicate if messages 306 // are to be pumped in sync calls to the plugin process. Currently used 307 // in HandleEvent calls. 308 IPC_SYNC_MESSAGE_ROUTED2_0(PluginHostMsg_SetWindowlessData, 309 HANDLE /* modal_loop_pump_messages_event */, 310 gfx::NativeViewId /* dummy_activation_window*/) 311 312 // Send the IME status retrieved from a windowless plug-in. A windowless plug-in 313 // uses the IME attached to a browser process as a renderer does. A plug-in 314 // sends this message to control the IME status of a browser process. I would 315 // note that a plug-in sends this message to a renderer process that hosts this 316 // plug-in (not directly to a browser process) so the renderer process can 317 // update its IME status. 318 IPC_MESSAGE_ROUTED2(PluginHostMsg_NotifyIMEStatus, 319 int /* input_type */, 320 gfx::Rect /* caret_rect */) 321 #endif 322 323 #if defined(OS_MACOSX) 324 IPC_MESSAGE_ROUTED1(PluginHostMsg_FocusChanged, 325 bool /* focused */) 326 327 IPC_MESSAGE_ROUTED0(PluginHostMsg_StartIme) 328 329 //---------------------------------------------------------------------- 330 // Core Animation plugin implementation rendering via compositor. 331 332 // Notifies the renderer process that this plugin will be using the 333 // accelerated rendering path. 334 IPC_MESSAGE_ROUTED0(PluginHostMsg_AcceleratedPluginEnabledRendering) 335 336 // Notifies the renderer process that the plugin allocated a new 337 // IOSurface into which it is rendering. The renderer process forwards 338 // this IOSurface to the GPU process, causing it to be bound to a 339 // texture from which the compositor can render. Any previous 340 // IOSurface allocated by this plugin must be implicitly released by 341 // the receipt of this message. 342 IPC_MESSAGE_ROUTED3(PluginHostMsg_AcceleratedPluginAllocatedIOSurface, 343 int32 /* width */, 344 int32 /* height */, 345 uint32 /* surface_id */) 346 347 // Notifies the renderer process that the plugin produced a new frame 348 // of content into its IOSurface, and therefore that the compositor 349 // needs to redraw. 350 IPC_MESSAGE_ROUTED0(PluginHostMsg_AcceleratedPluginSwappedIOSurface) 351 #endif 352 353 354 //----------------------------------------------------------------------------- 355 // NPObject messages 356 // These are messages used to marshall NPObjects. They are sent both from the 357 // plugin to the renderer and from the renderer to the plugin. 358 IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Release) 359 360 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasMethod, 361 content::NPIdentifier_Param /* name */, 362 bool /* result */) 363 364 IPC_SYNC_MESSAGE_ROUTED3_2(NPObjectMsg_Invoke, 365 bool /* is_default */, 366 content::NPIdentifier_Param /* method */, 367 std::vector<content::NPVariant_Param> /* args */, 368 content::NPVariant_Param /* result_param */, 369 bool /* result */) 370 371 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasProperty, 372 content::NPIdentifier_Param /* name */, 373 bool /* result */) 374 375 IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_GetProperty, 376 content::NPIdentifier_Param /* name */, 377 content::NPVariant_Param /* property */, 378 bool /* result */) 379 380 IPC_SYNC_MESSAGE_ROUTED2_1(NPObjectMsg_SetProperty, 381 content::NPIdentifier_Param /* name */, 382 content::NPVariant_Param /* property */, 383 bool /* result */) 384 385 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_RemoveProperty, 386 content::NPIdentifier_Param /* name */, 387 bool /* result */) 388 389 IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Invalidate) 390 391 IPC_SYNC_MESSAGE_ROUTED0_2(NPObjectMsg_Enumeration, 392 std::vector<content::NPIdentifier_Param> /* value */, 393 bool /* result */) 394 395 IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_Construct, 396 std::vector<content::NPVariant_Param> /* args */, 397 content::NPVariant_Param /* result_param */, 398 bool /* result */) 399 400 IPC_SYNC_MESSAGE_ROUTED2_2(NPObjectMsg_Evaluate, 401 std::string /* script */, 402 bool /* popups_allowed */, 403 content::NPVariant_Param /* result_param */, 404 bool /* result */) 405