Home | History | Annotate | Download | only in browser_plugin
      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/process/process.h"
     11 #include "content/common/content_export.h"
     12 #include "content/common/content_param_traits.h"
     13 #include "content/common/cursors/webcursor.h"
     14 #include "content/common/edit_command.h"
     15 #include "content/common/frame_param_macros.h"
     16 #include "content/public/common/common_param_traits.h"
     17 #include "content/public/common/drop_data.h"
     18 #include "ipc/ipc_channel_handle.h"
     19 #include "ipc/ipc_message_macros.h"
     20 #include "ipc/ipc_message_utils.h"
     21 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
     22 #include "third_party/WebKit/public/web/WebDragOperation.h"
     23 #include "third_party/WebKit/public/web/WebDragStatus.h"
     24 #include "third_party/skia/include/core/SkBitmap.h"
     25 #include "ui/gfx/ipc/gfx_param_traits.h"
     26 #include "ui/gfx/point.h"
     27 #include "ui/gfx/rect.h"
     28 #include "ui/gfx/size.h"
     29 #include "url/gurl.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_MAX_VALUE(blink::WebDragStatus, blink::WebDragStatusLast)
     38 
     39 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_ResizeGuest_Params)
     40   // The new size of guest view.
     41   IPC_STRUCT_MEMBER(gfx::Size, view_size)
     42   // Indicates the scale factor of the embedder WebView.
     43   IPC_STRUCT_MEMBER(float, scale_factor)
     44   // Indicates a request for a full repaint of the page.
     45   // This is required for switching from compositing to the software
     46   // rendering path.
     47   IPC_STRUCT_MEMBER(bool, repaint)
     48 IPC_STRUCT_END()
     49 
     50 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params)
     51   IPC_STRUCT_MEMBER(bool, focused)
     52   IPC_STRUCT_MEMBER(bool, visible)
     53   IPC_STRUCT_MEMBER(BrowserPluginHostMsg_ResizeGuest_Params,
     54                     resize_guest_params)
     55   IPC_STRUCT_MEMBER(gfx::Point, origin)
     56 IPC_STRUCT_END()
     57 
     58 // Browser plugin messages
     59 
     60 // -----------------------------------------------------------------------------
     61 // These messages are from the embedder to the browser process.
     62 
     63 // This message is sent from BrowserPlugin to BrowserPluginGuest to issue an
     64 // edit command.
     65 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ExecuteEditCommand,
     66                     int /* browser_plugin_instance_id */,
     67                     std::string /* command */)
     68 
     69 // This message must be sent just before sending a key event.
     70 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
     71                     int /* browser_plugin_instance_id */,
     72                     std::vector<content::EditCommand> /* edit_commands */)
     73 
     74 // This message is sent from BrowserPlugin to BrowserPluginGuest whenever IME
     75 // composition state is updated.
     76 IPC_MESSAGE_ROUTED5(
     77     BrowserPluginHostMsg_ImeSetComposition,
     78     int /* browser_plugin_instance_id */,
     79     std::string /* text */,
     80     std::vector<blink::WebCompositionUnderline> /* underlines */,
     81     int /* selectiont_start */,
     82     int /* selection_end */)
     83 
     84 // This message is sent from BrowserPlugin to BrowserPluginGuest to notify that
     85 // confirming the current composition is requested.
     86 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_ImeConfirmComposition,
     87                     int /* browser_plugin_instance_id */,
     88                     std::string /* text */,
     89                     bool /* keep selection */)
     90 
     91 // Deletes the current selection plus the specified number of characters before
     92 // and after the selection or caret.
     93 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_ExtendSelectionAndDelete,
     94                     int /* browser_plugin_instance_id */,
     95                     int /* before */,
     96                     int /* after */)
     97 
     98 // This message is sent to the browser process to indicate that a BrowserPlugin
     99 // has taken ownership of the lifetime of the guest of the given
    100 // |browser_plugin_instance_id|. |params| is the state of the BrowserPlugin
    101 // taking ownership of the guest.
    102 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_Attach,
    103                     int /* browser_plugin_instance_id */,
    104                     BrowserPluginHostMsg_Attach_Params /* params */)
    105 
    106 // Tells the guest to focus or defocus itself.
    107 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetFocus,
    108                     int /* browser_plugin_instance_id */,
    109                     bool /* enable */)
    110 
    111 // Sends an input event to the guest.
    112 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_HandleInputEvent,
    113                     int /* browser_plugin_instance_id */,
    114                     gfx::Rect /* guest_window_rect */,
    115                     IPC::WebInputEventPointer /* event */)
    116 
    117 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck,
    118                     int /* browser_plugin_instance_id */,
    119                     int /* request_id */,
    120                     SkBitmap)
    121 
    122 // Notify the guest renderer that some resources given to the embededer
    123 // are not used any more.
    124 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ReclaimCompositorResources,
    125                     int /* browser_plugin_instance_id */,
    126                     FrameHostMsg_ReclaimCompositorResources_Params /* params */)
    127 
    128 // When a BrowserPlugin has been removed from the embedder's DOM, it informs
    129 // the browser process to cleanup the guest.
    130 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_PluginDestroyed,
    131                     int /* browser_plugin_instance_id */)
    132 
    133 // Tells the guest it has been shown or hidden.
    134 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetVisibility,
    135                     int /* browser_plugin_instance_id */,
    136                     bool /* visible */)
    137 
    138 // Tells the guest that a drag event happened on the plugin.
    139 IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_DragStatusUpdate,
    140                     int /* browser_plugin_instance_id */,
    141                     blink::WebDragStatus /* drag_status */,
    142                     content::DropData /* drop_data */,
    143                     blink::WebDragOperationsMask /* operation_mask */,
    144                     gfx::Point /* plugin_location */)
    145 
    146 // Sends a PointerLock Lock ACK to the BrowserPluginGuest.
    147 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_LockMouse_ACK,
    148                     int /* browser_plugin_instance_id */,
    149                     bool /* succeeded */)
    150 
    151 // Sends a PointerLock Unlock ACK to the BrowserPluginGuest.
    152 IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_UnlockMouse_ACK,
    153                     int /* browser_plugin_instance_id */)
    154 
    155 // Sent when plugin's position has changed.
    156 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_UpdateGeometry,
    157                     int /* browser_plugin_instance_id */,
    158                     gfx::Rect /* view_rect */)
    159 
    160 // -----------------------------------------------------------------------------
    161 // These messages are from the guest renderer to the browser process
    162 
    163 // A embedder sends this message to the browser when it wants
    164 // to resize a guest plugin container so that the guest is relaid out
    165 // according to the new size.
    166 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ResizeGuest,
    167                     int /* browser_plugin_instance_id*/,
    168                     BrowserPluginHostMsg_ResizeGuest_Params)
    169 
    170 // -----------------------------------------------------------------------------
    171 // These messages are from the browser process to the embedder.
    172 
    173 // This message is sent in response to a completed attachment of a guest
    174 // to a BrowserPlugin.
    175 IPC_MESSAGE_CONTROL1(BrowserPluginMsg_Attach_ACK,
    176                      int /* browser_plugin_instance_id */)
    177 
    178 // When the guest crashes, the browser process informs the embedder through this
    179 // message.
    180 IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone,
    181                      int /* browser_plugin_instance_id */)
    182 
    183 // When the user tabs to the end of the tab stops of a guest, the browser
    184 // process informs the embedder to tab out of the browser plugin.
    185 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_AdvanceFocus,
    186                      int /* browser_plugin_instance_id */,
    187                      bool /* reverse */)
    188 
    189 // When the guest starts/stops listening to touch events, it needs to notify the
    190 // plugin in the embedder about it.
    191 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_ShouldAcceptTouchEvents,
    192                      int /* browser_plugin_instance_id */,
    193                      bool /* accept */)
    194 
    195 // Tells the guest to change its background opacity.
    196 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetContentsOpaque,
    197                      int /* browser_plugin_instance_id */,
    198                      bool /* opaque */)
    199 
    200 // Inform the embedder of the cursor the guest wishes to display.
    201 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetCursor,
    202                      int /* browser_plugin_instance_id */,
    203                      content::WebCursor /* cursor */)
    204 
    205 IPC_MESSAGE_CONTROL4(BrowserPluginMsg_CopyFromCompositingSurface,
    206                      int /* browser_plugin_instance_id */,
    207                      int /* request_id */,
    208                      gfx::Rect  /* source_rect */,
    209                      gfx::Size  /* dest_size */)
    210 
    211 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_CompositorFrameSwapped,
    212                      int /* browser_plugin_instance_id */,
    213                      FrameMsg_CompositorFrameSwapped_Params /* params */)
    214 
    215 // Forwards a PointerLock Unlock request to the BrowserPlugin.
    216 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock,
    217                      int /* browser_plugin_instance_id */,
    218                      bool /* enable */)
    219 
    220 // Acknowledge that we presented an ubercomp frame.
    221 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_CompositorFrameSwappedACK,
    222                     int /* browser_plugin_instance_id */,
    223                     FrameHostMsg_CompositorFrameSwappedACK_Params /* params */)
    224