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 file, hence no include guard.
7 #include "build/build_config.h"
8 #include "content/common/content_export.h"
9 #include "content/common/content_param_traits.h"
10 #include "content/public/common/common_param_traits.h"
11 #include "ipc/ipc_channel_handle.h"
12 #include "ipc/ipc_message_macros.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/rect.h"
15 #include "webkit/glue/webcursor.h"
18 #include "base/file_descriptor_posix.h"
21 #undef IPC_MESSAGE_EXPORT
22 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
24 #define IPC_MESSAGE_START PluginMsgStart
26 IPC_STRUCT_BEGIN(PluginMsg_Init_Params
)
27 IPC_STRUCT_MEMBER(GURL
, url
)
28 IPC_STRUCT_MEMBER(GURL
, page_url
)
29 IPC_STRUCT_MEMBER(std::vector
<std::string
>, arg_names
)
30 IPC_STRUCT_MEMBER(std::vector
<std::string
>, arg_values
)
31 IPC_STRUCT_MEMBER(bool, load_manually
)
32 IPC_STRUCT_MEMBER(int, host_render_view_routing_id
)
35 IPC_STRUCT_BEGIN(PluginHostMsg_URLRequest_Params
)
36 IPC_STRUCT_MEMBER(std::string
, url
)
37 IPC_STRUCT_MEMBER(std::string
, method
)
38 IPC_STRUCT_MEMBER(std::string
, target
)
39 IPC_STRUCT_MEMBER(std::vector
<char>, buffer
)
40 IPC_STRUCT_MEMBER(int, notify_id
)
41 IPC_STRUCT_MEMBER(bool, popups_allowed
)
42 IPC_STRUCT_MEMBER(bool, notify_redirects
)
45 IPC_STRUCT_BEGIN(PluginMsg_DidReceiveResponseParams
)
46 IPC_STRUCT_MEMBER(unsigned long, id
)
47 IPC_STRUCT_MEMBER(std::string
, mime_type
)
48 IPC_STRUCT_MEMBER(std::string
, headers
)
49 IPC_STRUCT_MEMBER(uint32
, expected_length
)
50 IPC_STRUCT_MEMBER(uint32
, last_modified
)
51 IPC_STRUCT_MEMBER(bool, request_is_seekable
)
54 IPC_STRUCT_BEGIN(PluginMsg_UpdateGeometry_Param
)
55 IPC_STRUCT_MEMBER(gfx::Rect
, window_rect
)
56 IPC_STRUCT_MEMBER(gfx::Rect
, clip_rect
)
57 IPC_STRUCT_MEMBER(TransportDIB::Handle
, windowless_buffer0
)
58 IPC_STRUCT_MEMBER(TransportDIB::Handle
, windowless_buffer1
)
59 IPC_STRUCT_MEMBER(int, windowless_buffer_index
)
62 //-----------------------------------------------------------------------------
63 // PluginProcess messages
64 // These are messages sent from the browser to the plugin process.
65 // Tells the plugin process to create a new channel for communication with a
66 // given renderer. The channel name is returned in a
67 // PluginProcessHostMsg_ChannelCreated message. The renderer ID is passed so
68 // that the plugin process reuses an existing channel to that process if it
69 // exists. This ID is a unique opaque identifier generated by the browser
71 IPC_MESSAGE_CONTROL2(PluginProcessMsg_CreateChannel
,
72 int /* renderer_id */,
73 bool /* off_the_record */)
75 // Tells the plugin process to notify every connected renderer of the pending
76 // shutdown, so we don't mistake it for a crash.
77 IPC_MESSAGE_CONTROL0(PluginProcessMsg_NotifyRenderersOfPendingShutdown
)
80 //-----------------------------------------------------------------------------
81 // PluginProcessHost messages
82 // These are messages sent from the plugin process to the browser process.
83 // Response to a PluginProcessMsg_CreateChannel message.
84 IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_ChannelCreated
,
85 IPC::ChannelHandle
/* channel_handle */)
88 // Destroys the given window's parent on the UI thread.
89 IPC_MESSAGE_CONTROL2(PluginProcessHostMsg_PluginWindowDestroyed
,
95 // On X11, the mapping between NativeViewId and X window ids
96 // is known only to the browser. This message lets the plugin process
97 // ask about a NativeViewId that was provided by the renderer.
98 // It will get 0 back if it's a bogus input.
99 IPC_SYNC_MESSAGE_CONTROL1_1(PluginProcessHostMsg_MapNativeViewId
,
100 gfx::NativeViewId
/* input: native view id */,
101 gfx::PluginWindowHandle
/* output: X window id */)
104 #if defined(OS_MACOSX)
105 // On Mac OS X, we need the browser to keep track of plugin windows so
106 // that it can add and remove them from stacking groups, hide and show the
107 // menu bar, etc. We pass the window rect for convenience so that the
108 // browser can easily tell if the window is fullscreen.
110 // Notifies the browser that the plugin has selected a window (i.e., brought
111 // it to the front and wants it to have keyboard focus).
112 IPC_MESSAGE_CONTROL3(PluginProcessHostMsg_PluginSelectWindow
,
113 uint32
/* window ID */,
114 gfx::Rect
/* window rect */,
117 // Notifies the browser that the plugin has shown a window.
118 IPC_MESSAGE_CONTROL3(PluginProcessHostMsg_PluginShowWindow
,
119 uint32
/* window ID */,
120 gfx::Rect
/* window rect */,
123 // Notifies the browser that the plugin has hidden a window.
124 IPC_MESSAGE_CONTROL2(PluginProcessHostMsg_PluginHideWindow
,
125 uint32
/* window ID */,
126 gfx::Rect
/* window rect */)
128 // Notifies the browser that a plugin instance has requested a cursor
129 // visibility change.
130 IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_PluginSetCursorVisibility
,
131 bool /* cursor visibility */)
135 //-----------------------------------------------------------------------------
137 // These are messages sent from the renderer process to the plugin process.
138 // Tells the plugin process to create a new plugin instance with the given
139 // id. A corresponding WebPluginDelegateStub is created which hosts the
140 // WebPluginDelegateImpl.
141 IPC_SYNC_MESSAGE_CONTROL1_1(PluginMsg_CreateInstance
,
142 std::string
/* mime_type */,
143 int /* instance_id */)
145 // The WebPluginDelegateProxy sends this to the WebPluginDelegateStub in its
146 // destructor, so that the stub deletes the actual WebPluginDelegateImpl
147 // object that it's hosting.
148 IPC_SYNC_MESSAGE_CONTROL1_0(PluginMsg_DestroyInstance
,
149 int /* instance_id */)
151 IPC_SYNC_MESSAGE_CONTROL0_1(PluginMsg_GenerateRouteID
,
154 // The messages below all map to WebPluginDelegate methods.
155 IPC_SYNC_MESSAGE_ROUTED1_1(PluginMsg_Init
,
156 PluginMsg_Init_Params
,
159 // Used to synchronously request a paint for windowless plugins.
160 IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_Paint
,
161 gfx::Rect
/* damaged_rect */)
163 // Sent by the renderer after it paints from its backing store so that the
164 // plugin knows it can send more invalidates.
165 IPC_MESSAGE_ROUTED0(PluginMsg_DidPaint
)
167 IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_GetPluginScriptableObject
,
170 // Gets the form value of the plugin instance synchronously.
171 IPC_SYNC_MESSAGE_ROUTED0_2(PluginMsg_GetFormValue
,
172 string16
/* value */,
175 IPC_MESSAGE_ROUTED3(PluginMsg_DidFinishLoadWithReason
,
180 // Updates the plugin location.
181 IPC_MESSAGE_ROUTED1(PluginMsg_UpdateGeometry
,
182 PluginMsg_UpdateGeometry_Param
)
184 // A synchronous version of above.
185 IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_UpdateGeometrySync
,
186 PluginMsg_UpdateGeometry_Param
)
188 IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_SetFocus
,
191 IPC_SYNC_MESSAGE_ROUTED1_2(PluginMsg_HandleInputEvent
,
192 IPC::WebInputEventPointer
/* event */,
194 WebCursor
/* cursor type*/)
196 IPC_MESSAGE_ROUTED1(PluginMsg_SetContentAreaFocus
,
197 bool /* has_focus */)
200 IPC_MESSAGE_ROUTED4(PluginMsg_ImeCompositionUpdated
,
202 std::vector
<int> /* clauses */,
203 std::vector
<int>, /* target */
204 int /* cursor_position */)
206 IPC_MESSAGE_ROUTED1(PluginMsg_ImeCompositionCompleted
,
210 #if defined(OS_MACOSX)
211 IPC_MESSAGE_ROUTED1(PluginMsg_SetWindowFocus
,
212 bool /* has_focus */)
214 IPC_MESSAGE_ROUTED0(PluginMsg_ContainerHidden
)
216 IPC_MESSAGE_ROUTED3(PluginMsg_ContainerShown
,
217 gfx::Rect
/* window_frame */,
218 gfx::Rect
/* view_frame */,
219 bool /* has_focus */)
221 IPC_MESSAGE_ROUTED2(PluginMsg_WindowFrameChanged
,
222 gfx::Rect
/* window_frame */,
223 gfx::Rect
/* view_frame */)
225 IPC_MESSAGE_ROUTED1(PluginMsg_ImeCompositionCompleted
,
229 IPC_SYNC_MESSAGE_ROUTED3_0(PluginMsg_WillSendRequest
,
230 unsigned long /* id */,
232 int /* http_status_code */)
234 IPC_MESSAGE_ROUTED1(PluginMsg_DidReceiveResponse
,
235 PluginMsg_DidReceiveResponseParams
)
237 IPC_MESSAGE_ROUTED3(PluginMsg_DidReceiveData
,
238 unsigned long /* id */,
239 std::vector
<char> /* buffer */,
240 int /* data_offset */)
242 IPC_MESSAGE_ROUTED1(PluginMsg_DidFinishLoading
,
243 unsigned long /* id */)
245 IPC_MESSAGE_ROUTED1(PluginMsg_DidFail
,
246 unsigned long /* id */)
248 IPC_MESSAGE_ROUTED4(PluginMsg_SendJavaScriptStream
,
250 std::string
/* result */,
254 IPC_MESSAGE_ROUTED2(PluginMsg_DidReceiveManualResponse
,
256 PluginMsg_DidReceiveResponseParams
)
258 IPC_MESSAGE_ROUTED1(PluginMsg_DidReceiveManualData
,
259 std::vector
<char> /* buffer */)
261 IPC_MESSAGE_ROUTED0(PluginMsg_DidFinishManualLoading
)
263 IPC_MESSAGE_ROUTED0(PluginMsg_DidManualLoadFail
)
265 IPC_MESSAGE_ROUTED3(PluginMsg_HandleURLRequestReply
,
266 unsigned long /* resource_id */,
270 IPC_MESSAGE_ROUTED2(PluginMsg_HTTPRangeRequestReply
,
271 unsigned long /* resource_id */,
272 int /* range_request_id */)
274 IPC_MESSAGE_CONTROL1(PluginMsg_SignalModalDialogEvent
,
275 int /* render_view_id */)
277 IPC_MESSAGE_CONTROL1(PluginMsg_ResetModalDialogEvent
,
278 int /* render_view_id */)
280 #if defined(OS_MACOSX)
281 // This message, used only on 10.6 and later, transmits the "fake"
282 // window handle allocated by the browser on behalf of the renderer
283 // to the GPU plugin.
284 IPC_MESSAGE_ROUTED1(PluginMsg_SetFakeAcceleratedSurfaceWindowHandle
,
285 gfx::PluginWindowHandle
/* window */)
288 IPC_MESSAGE_CONTROL3(PluginMsg_ClearSiteData
,
289 std::string
/* site */,
291 uint64
/* max_age */)
293 //-----------------------------------------------------------------------------
294 // PluginHost messages
295 // These are messages sent from the plugin process to the renderer process.
296 // They all map to the corresponding WebPlugin methods.
297 // Sends the plugin window information to the renderer.
298 // The window parameter is a handle to the window if the plugin is a windowed
299 // plugin. It is NULL for windowless plugins.
300 IPC_SYNC_MESSAGE_ROUTED1_0(PluginHostMsg_SetWindow
,
301 gfx::PluginWindowHandle
/* window */)
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*/)
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 */)
323 IPC_MESSAGE_ROUTED1(PluginHostMsg_URLRequest
,
324 PluginHostMsg_URLRequest_Params
)
326 IPC_MESSAGE_ROUTED1(PluginHostMsg_CancelResource
,
329 IPC_MESSAGE_ROUTED1(PluginHostMsg_InvalidateRect
,
330 gfx::Rect
/* rect */)
332 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetWindowScriptNPObject
,
336 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetPluginElement
,
340 IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_ResolveProxy
,
343 std::string
/* proxy list */)
345 IPC_MESSAGE_ROUTED3(PluginHostMsg_SetCookie
,
347 GURL
/* first_party_for_cookies */,
348 std::string
/* cookie */)
350 IPC_SYNC_MESSAGE_ROUTED2_1(PluginHostMsg_GetCookies
,
352 GURL
/* first_party_for_cookies */,
353 std::string
/* cookies */)
355 IPC_MESSAGE_ROUTED0(PluginHostMsg_CancelDocumentLoad
)
357 IPC_MESSAGE_ROUTED3(PluginHostMsg_InitiateHTTPRangeRequest
,
358 std::string
/* url */,
359 std::string
/* range_info */,
360 int /* range_request_id */)
362 IPC_MESSAGE_ROUTED2(PluginHostMsg_DeferResourceLoading
,
363 unsigned long /* resource_id */,
366 IPC_SYNC_MESSAGE_CONTROL1_0(PluginHostMsg_SetException
,
367 std::string
/* message */)
369 IPC_MESSAGE_CONTROL0(PluginHostMsg_PluginShuttingDown
)
371 #if defined(OS_MACOSX)
372 IPC_MESSAGE_ROUTED1(PluginHostMsg_FocusChanged
,
375 IPC_MESSAGE_ROUTED0(PluginHostMsg_StartIme
)
377 //----------------------------------------------------------------------
378 // Legacy Core Animation plugin implementation rendering directly to screen.
380 // This message, used in Mac OS X 10.5 and earlier, is sent from the plug-in
381 // process to the renderer process to indicate that the plug-in allocated a
382 // new TransportDIB that holds the GPU's rendered image. This information is
383 // then forwarded to the browser process via a similar message.
384 IPC_MESSAGE_ROUTED4(PluginHostMsg_AcceleratedSurfaceSetTransportDIB
,
385 gfx::PluginWindowHandle
/* window */,
388 TransportDIB::Handle
/* handle to the TransportDIB */)
390 // Synthesize a fake window handle for the plug-in to identify the instance
391 // to the browser, allowing mapping to a surface for hardware accelleration
392 // of plug-in content. The browser generates the handle which is then set on
393 // the plug-in. |opaque| indicates whether the content should be treated as
395 IPC_MESSAGE_ROUTED1(PluginHostMsg_BindFakePluginWindowHandle
,
398 // This message, used only on 10.6 and later, is sent from the plug-in process
399 // to the renderer process to indicate that the plugin allocated a new
400 // IOSurface object of the given width and height. This information is then
401 // forwarded on to the browser process.
403 // NOTE: the original intent was to pass a mach port as the IOSurface
404 // identifier but it looks like that will be a lot of work. For now we pass an
405 // ID from IOSurfaceGetID.
406 IPC_MESSAGE_ROUTED4(PluginHostMsg_AcceleratedSurfaceSetIOSurface
,
407 gfx::PluginWindowHandle
/* window */,
410 uint64
/* surface_id */)
413 // On the Mac, shared memory can't be allocated in the sandbox, so
414 // the TransportDIB used by the plug-in for rendering has to be allocated
415 // and managed by the browser. This is a synchronous message, use with care.
416 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_AllocTransportDIB
,
417 size_t /* requested memory size */,
418 TransportDIB::Handle
/* output: DIB handle */)
420 // Since the browser keeps handles to the allocated transport DIBs, this
421 // message is sent to tell the browser that it may release them when the
422 // renderer is finished with them.
423 IPC_MESSAGE_ROUTED1(PluginHostMsg_FreeTransportDIB
,
424 TransportDIB::Id
/* DIB id */)
426 // This message notifies the renderer process (and from there the
427 // browser process) that the plug-in swapped the buffers associated
428 // with the given "window", which should cause the browser to redraw
429 // the various plug-ins' contents.
430 IPC_MESSAGE_ROUTED2(PluginHostMsg_AcceleratedSurfaceBuffersSwapped
,
431 gfx::PluginWindowHandle
/* window */,
432 uint64
/* surface_handle */)
434 //----------------------------------------------------------------------
435 // New Core Animation plugin implementation rendering via compositor.
437 // Notifies the renderer process that this plugin will be using the
438 // accelerated rendering path.
439 IPC_MESSAGE_ROUTED0(PluginHostMsg_AcceleratedPluginEnabledRendering
)
441 // Notifies the renderer process that the plugin allocated a new
442 // IOSurface into which it is rendering. The renderer process forwards
443 // this IOSurface to the GPU process, causing it to be bound to a
444 // texture from which the compositor can render. Any previous
445 // IOSurface allocated by this plugin must be implicitly released by
446 // the receipt of this message.
447 IPC_MESSAGE_ROUTED3(PluginHostMsg_AcceleratedPluginAllocatedIOSurface
,
450 uint32
/* surface_id */)
452 // Notifies the renderer process that the plugin produced a new frame
453 // of content into its IOSurface, and therefore that the compositor
455 IPC_MESSAGE_ROUTED0(PluginHostMsg_AcceleratedPluginSwappedIOSurface
)
458 IPC_MESSAGE_CONTROL1(PluginHostMsg_ClearSiteDataResult
,
461 IPC_MESSAGE_ROUTED2(PluginHostMsg_URLRedirectResponse
,
463 int /* resource_id */)
466 //-----------------------------------------------------------------------------
468 // These are messages used to marshall NPObjects. They are sent both from the
469 // plugin to the renderer and from the renderer to the plugin.
470 IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Release
)
472 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasMethod
,
473 content::NPIdentifier_Param
/* name */,
476 IPC_SYNC_MESSAGE_ROUTED3_2(NPObjectMsg_Invoke
,
477 bool /* is_default */,
478 content::NPIdentifier_Param
/* method */,
479 std::vector
<content::NPVariant_Param
> /* args */,
480 content::NPVariant_Param
/* result_param */,
483 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasProperty
,
484 content::NPIdentifier_Param
/* name */,
487 IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_GetProperty
,
488 content::NPIdentifier_Param
/* name */,
489 content::NPVariant_Param
/* property */,
492 IPC_SYNC_MESSAGE_ROUTED2_1(NPObjectMsg_SetProperty
,
493 content::NPIdentifier_Param
/* name */,
494 content::NPVariant_Param
/* property */,
497 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_RemoveProperty
,
498 content::NPIdentifier_Param
/* name */,
501 IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Invalidate
)
503 IPC_SYNC_MESSAGE_ROUTED0_2(NPObjectMsg_Enumeration
,
504 std::vector
<content::NPIdentifier_Param
> /* value */,
507 IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_Construct
,
508 std::vector
<content::NPVariant_Param
> /* args */,
509 content::NPVariant_Param
/* result_param */,
512 IPC_SYNC_MESSAGE_ROUTED2_2(NPObjectMsg_Evaluate
,
513 std::string
/* script */,
514 bool /* popups_allowed */,
515 content::NPVariant_Param
/* result_param */,