Home | History | Annotate | Download | only in child
      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/common/cursors/webcursor.h"
     12 #include "content/public/common/common_param_traits.h"
     13 #include "ipc/ipc_channel_handle.h"
     14 #include "ipc/ipc_message_macros.h"
     15 #include "ui/gfx/native_widget_types.h"
     16 #include "ui/gfx/rect.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_frame_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                            content::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 #endif
    227 
    228 //-----------------------------------------------------------------------------
    229 // PluginHost messages
    230 // These are messages sent from the plugin process to the renderer process.
    231 // They all map to the corresponding WebPlugin methods.
    232 // Sends the plugin window information to the renderer.
    233 // The window parameter is a handle to the window if the plugin is a windowed
    234 // plugin. It is NULL for windowless plugins.
    235 IPC_SYNC_MESSAGE_ROUTED1_0(PluginHostMsg_SetWindow,
    236                            gfx::PluginWindowHandle /* window */)
    237 
    238 IPC_MESSAGE_ROUTED1(PluginHostMsg_URLRequest,
    239                     PluginHostMsg_URLRequest_Params)
    240 
    241 IPC_MESSAGE_ROUTED1(PluginHostMsg_CancelResource,
    242                     int /* id */)
    243 
    244 IPC_MESSAGE_ROUTED1(PluginHostMsg_InvalidateRect,
    245                     gfx::Rect /* rect */)
    246 
    247 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetWindowScriptNPObject,
    248                            int /* route id */,
    249                            bool /* success */)
    250 
    251 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetPluginElement,
    252                            int /* route id */,
    253                            bool /* success */)
    254 
    255 IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_ResolveProxy,
    256                            GURL /* url */,
    257                            bool /* result */,
    258                            std::string /* proxy list */)
    259 
    260 IPC_MESSAGE_ROUTED3(PluginHostMsg_SetCookie,
    261                     GURL /* url */,
    262                     GURL /* first_party_for_cookies */,
    263                     std::string /* cookie */)
    264 
    265 IPC_SYNC_MESSAGE_ROUTED2_1(PluginHostMsg_GetCookies,
    266                            GURL /* url */,
    267                            GURL /* first_party_for_cookies */,
    268                            std::string /* cookies */)
    269 
    270 IPC_MESSAGE_ROUTED0(PluginHostMsg_CancelDocumentLoad)
    271 
    272 IPC_MESSAGE_ROUTED3(PluginHostMsg_InitiateHTTPRangeRequest,
    273                     std::string /* url */,
    274                     std::string /* range_info */,
    275                     int         /* range_request_id */)
    276 
    277 IPC_MESSAGE_ROUTED0(PluginHostMsg_DidStartLoading)
    278 IPC_MESSAGE_ROUTED0(PluginHostMsg_DidStopLoading)
    279 
    280 IPC_MESSAGE_ROUTED2(PluginHostMsg_DeferResourceLoading,
    281                     unsigned long /* resource_id */,
    282                     bool /* defer */)
    283 
    284 IPC_SYNC_MESSAGE_CONTROL1_0(PluginHostMsg_SetException,
    285                             std::string /* message */)
    286 
    287 IPC_MESSAGE_CONTROL0(PluginHostMsg_PluginShuttingDown)
    288 
    289 IPC_MESSAGE_ROUTED2(PluginHostMsg_URLRedirectResponse,
    290                     bool /* allow */,
    291                     int  /* resource_id */)
    292 
    293 IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_CheckIfRunInsecureContent,
    294                            GURL /* url */,
    295                            bool /* result */)
    296 
    297 #if defined(OS_WIN)
    298 // The modal_loop_pump_messages_event parameter is an event handle which is
    299 // passed in for windowless plugins and is used to indicate if messages
    300 // are to be pumped in sync calls to the plugin process. Currently used
    301 // in HandleEvent calls.
    302 IPC_SYNC_MESSAGE_ROUTED2_0(PluginHostMsg_SetWindowlessData,
    303                            HANDLE /* modal_loop_pump_messages_event */,
    304                            gfx::NativeViewId /* dummy_activation_window*/)
    305 
    306 // Send the IME status retrieved from a windowless plug-in. A windowless plug-in
    307 // uses the IME attached to a browser process as a renderer does. A plug-in
    308 // sends this message to control the IME status of a browser process. I would
    309 // note that a plug-in sends this message to a renderer process that hosts this
    310 // plug-in (not directly to a browser process) so the renderer process can
    311 // update its IME status.
    312 IPC_MESSAGE_ROUTED2(PluginHostMsg_NotifyIMEStatus,
    313                     int /* input_type */,
    314                     gfx::Rect /* caret_rect */)
    315 #endif
    316 
    317 #if defined(OS_MACOSX)
    318 IPC_MESSAGE_ROUTED1(PluginHostMsg_FocusChanged,
    319                     bool /* focused */)
    320 
    321 IPC_MESSAGE_ROUTED0(PluginHostMsg_StartIme)
    322 
    323 //----------------------------------------------------------------------
    324 // Core Animation plugin implementation rendering via compositor.
    325 
    326 // Notifies the renderer process that this plugin will be using the
    327 // accelerated rendering path.
    328 IPC_MESSAGE_ROUTED0(PluginHostMsg_AcceleratedPluginEnabledRendering)
    329 
    330 // Notifies the renderer process that the plugin allocated a new
    331 // IOSurface into which it is rendering. The renderer process forwards
    332 // this IOSurface to the GPU process, causing it to be bound to a
    333 // texture from which the compositor can render. Any previous
    334 // IOSurface allocated by this plugin must be implicitly released by
    335 // the receipt of this message.
    336 IPC_MESSAGE_ROUTED3(PluginHostMsg_AcceleratedPluginAllocatedIOSurface,
    337                     int32 /* width */,
    338                     int32 /* height */,
    339                     uint32 /* surface_id */)
    340 
    341 // Notifies the renderer process that the plugin produced a new frame
    342 // of content into its IOSurface, and therefore that the compositor
    343 // needs to redraw.
    344 IPC_MESSAGE_ROUTED0(PluginHostMsg_AcceleratedPluginSwappedIOSurface)
    345 #endif
    346 
    347 
    348 //-----------------------------------------------------------------------------
    349 // NPObject messages
    350 // These are messages used to marshall NPObjects.  They are sent both from the
    351 // plugin to the renderer and from the renderer to the plugin.
    352 IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Release)
    353 
    354 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasMethod,
    355                            content::NPIdentifier_Param /* name */,
    356                            bool /* result */)
    357 
    358 IPC_SYNC_MESSAGE_ROUTED3_2(NPObjectMsg_Invoke,
    359                            bool /* is_default */,
    360                            content::NPIdentifier_Param /* method */,
    361                            std::vector<content::NPVariant_Param> /* args */,
    362                            content::NPVariant_Param /* result_param */,
    363                            bool /* result */)
    364 
    365 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_HasProperty,
    366                            content::NPIdentifier_Param /* name */,
    367                            bool /* result */)
    368 
    369 IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_GetProperty,
    370                            content::NPIdentifier_Param /* name */,
    371                            content::NPVariant_Param /* property */,
    372                            bool /* result */)
    373 
    374 IPC_SYNC_MESSAGE_ROUTED2_1(NPObjectMsg_SetProperty,
    375                            content::NPIdentifier_Param /* name */,
    376                            content::NPVariant_Param /* property */,
    377                            bool /* result */)
    378 
    379 IPC_SYNC_MESSAGE_ROUTED1_1(NPObjectMsg_RemoveProperty,
    380                            content::NPIdentifier_Param /* name */,
    381                            bool /* result */)
    382 
    383 IPC_SYNC_MESSAGE_ROUTED0_0(NPObjectMsg_Invalidate)
    384 
    385 IPC_SYNC_MESSAGE_ROUTED0_2(NPObjectMsg_Enumeration,
    386                            std::vector<content::NPIdentifier_Param> /* value */,
    387                            bool /* result */)
    388 
    389 IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_Construct,
    390                            std::vector<content::NPVariant_Param> /* args */,
    391                            content::NPVariant_Param /* result_param */,
    392                            bool /* result */)
    393 
    394 IPC_SYNC_MESSAGE_ROUTED2_2(NPObjectMsg_Evaluate,
    395                            std::string /* script */,
    396                            bool /* popups_allowed */,
    397                            content::NPVariant_Param /* result_param */,
    398                            bool /* result */)
    399