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 "base/values.h" 12#include "content/common/content_export.h" 13#include "content/common/content_param_traits.h" 14#include "content/common/cursors/webcursor.h" 15#include "content/common/edit_command.h" 16#include "content/common/frame_param_macros.h" 17#include "content/public/common/common_param_traits.h" 18#include "content/public/common/drop_data.h" 19#include "ipc/ipc_channel_handle.h" 20#include "ipc/ipc_message_macros.h" 21#include "ipc/ipc_message_utils.h" 22#include "third_party/WebKit/public/web/WebCompositionUnderline.h" 23#include "third_party/WebKit/public/web/WebDragOperation.h" 24#include "third_party/WebKit/public/web/WebDragStatus.h" 25#include "third_party/skia/include/core/SkBitmap.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 37IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDragStatus, blink::WebDragStatusLast) 38 39IPC_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) 43IPC_STRUCT_END() 44 45IPC_STRUCT_BEGIN(BrowserPluginHostMsg_ResizeGuest_Params) 46 // Indicates whether the parameters have been populated or not. 47 IPC_STRUCT_MEMBER(bool, size_changed) 48 // The new size of guest view. 49 IPC_STRUCT_MEMBER(gfx::Size, view_size) 50 // Indicates the scale factor of the embedder WebView. 51 IPC_STRUCT_MEMBER(float, scale_factor) 52 // Indicates a request for a full repaint of the page. 53 // This is required for switching from compositing to the software 54 // rendering path. 55 IPC_STRUCT_MEMBER(bool, repaint) 56IPC_STRUCT_END() 57 58IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params) 59 IPC_STRUCT_MEMBER(bool, focused) 60 IPC_STRUCT_MEMBER(bool, visible) 61 IPC_STRUCT_MEMBER(bool, opaque) 62 IPC_STRUCT_MEMBER(GURL, embedder_frame_url) 63 IPC_STRUCT_MEMBER(BrowserPluginHostMsg_AutoSize_Params, auto_size_params) 64 IPC_STRUCT_MEMBER(BrowserPluginHostMsg_ResizeGuest_Params, 65 resize_guest_params) 66 IPC_STRUCT_MEMBER(gfx::Point, origin) 67IPC_STRUCT_END() 68 69IPC_STRUCT_BEGIN(BrowserPluginMsg_UpdateRect_Params) 70 // The size of the RenderView when this message was generated. This is 71 // included so the host knows how large the view is from the perspective of 72 // the renderer process. This is necessary in case a resize operation is in 73 // progress. If auto-resize is enabled, this should update the corresponding 74 // view size. 75 IPC_STRUCT_MEMBER(gfx::Size, view_size) 76 77 // All the above coordinates are in DIP. This is the scale factor needed 78 // to convert them to pixels. 79 IPC_STRUCT_MEMBER(float, scale_factor) 80 81 // Is this UpdateRect an ACK to a resize request? 82 IPC_STRUCT_MEMBER(bool, is_resize_ack) 83IPC_STRUCT_END() 84 85// Browser plugin messages 86 87// ----------------------------------------------------------------------------- 88// These messages are from the embedder to the browser process. 89 90// This message is sent from BrowserPlugin to BrowserPluginGuest to issue an 91// edit command. 92IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ExecuteEditCommand, 93 int /* instance_id */, 94 std::string /* command */) 95 96// This message must be sent just before sending a key event. 97IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, 98 int /* instance_id */, 99 std::vector<content::EditCommand> /* edit_commands */) 100 101// This message is sent from BrowserPlugin to BrowserPluginGuest whenever IME 102// composition state is updated. 103IPC_MESSAGE_ROUTED5( 104 BrowserPluginHostMsg_ImeSetComposition, 105 int /* instance_id */, 106 std::string /* text */, 107 std::vector<blink::WebCompositionUnderline> /* underlines */, 108 int /* selectiont_start */, 109 int /* selection_end */) 110 111// This message is sent from BrowserPlugin to BrowserPluginGuest to notify that 112// confirming the current composition is requested. 113IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_ImeConfirmComposition, 114 int /* instance_id */, 115 std::string /* text */, 116 bool /* keep selection */) 117 118// Deletes the current selection plus the specified number of characters before 119// and after the selection or caret. 120IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_ExtendSelectionAndDelete, 121 int /* instance_id */, 122 int /* before */, 123 int /* after */) 124 125// This message is sent to the browser process to enable or disable autosize 126// mode. 127IPC_MESSAGE_ROUTED3( 128 BrowserPluginHostMsg_SetAutoSize, 129 int /* instance_id */, 130 BrowserPluginHostMsg_AutoSize_Params /* auto_size_params */, 131 BrowserPluginHostMsg_ResizeGuest_Params /* resize_guest_params */) 132 133// This message is sent to the browser process to indicate that a BrowserPlugin 134// has taken ownership of the lifetime of the guest of the given |instance_id|. 135// |params| is the state of the BrowserPlugin taking ownership of 136// the guest. If a guest doesn't already exist with the given |instance_id|, 137// a new one will be created. 138IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_Attach, 139 int /* instance_id */, 140 BrowserPluginHostMsg_Attach_Params /* params */, 141 base::DictionaryValue /* extra_params */) 142 143// Tells the guest to focus or defocus itself. 144IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetFocus, 145 int /* instance_id */, 146 bool /* enable */) 147 148// Sends an input event to the guest. 149IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_HandleInputEvent, 150 int /* instance_id */, 151 gfx::Rect /* guest_window_rect */, 152 IPC::WebInputEventPointer /* event */) 153 154IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, 155 int /* instance_id */, 156 int /* request_id */, 157 SkBitmap); 158 159// Notify the guest renderer that some resources given to the embededer 160// are not used any more. 161IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ReclaimCompositorResources, 162 int /* instance_id */, 163 FrameHostMsg_ReclaimCompositorResources_Params /* params */) 164 165// When a BrowserPlugin has been removed from the embedder's DOM, it informs 166// the browser process to cleanup the guest. 167IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_PluginDestroyed, 168 int /* instance_id */) 169 170// Tells the guest it has been shown or hidden. 171IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetVisibility, 172 int /* instance_id */, 173 bool /* visible */) 174 175// Tells the guest to change its background opacity. 176IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetContentsOpaque, 177 int /* instance_id */, 178 bool /* opaque */) 179 180// Tells the guest that a drag event happened on the plugin. 181IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_DragStatusUpdate, 182 int /* instance_id */, 183 blink::WebDragStatus /* drag_status */, 184 content::DropData /* drop_data */, 185 blink::WebDragOperationsMask /* operation_mask */, 186 gfx::Point /* plugin_location */) 187 188// Sends a PointerLock Lock ACK to the BrowserPluginGuest. 189IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_LockMouse_ACK, 190 int /* instance_id */, 191 bool /* succeeded */) 192 193// Sends a PointerLock Unlock ACK to the BrowserPluginGuest. 194IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_UnlockMouse_ACK, int /* instance_id */) 195 196// Sent when plugin's position has changed without UpdateRect. 197IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_UpdateGeometry, 198 int /* instance_id */, 199 gfx::Rect /* view_rect */) 200 201// ----------------------------------------------------------------------------- 202// These messages are from the guest renderer to the browser process 203 204// A embedder sends this message to the browser when it wants 205// to resize a guest plugin container so that the guest is relaid out 206// according to the new size. 207IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ResizeGuest, 208 int /* instance_id*/, 209 BrowserPluginHostMsg_ResizeGuest_Params) 210 211// ----------------------------------------------------------------------------- 212// These messages are from the browser process to the embedder. 213 214// This message is sent in response to a completed attachment of a guest 215// to a BrowserPlugin. 216IPC_MESSAGE_CONTROL1(BrowserPluginMsg_Attach_ACK, int /* instance_id */); 217 218// Once the swapped out guest RenderView has been created in the embedder render 219// process, the browser process informs the embedder of its routing ID. 220IPC_MESSAGE_CONTROL2(BrowserPluginMsg_GuestContentWindowReady, 221 int /* instance_id */, 222 int /* source_routing_id */) 223 224// When the guest crashes, the browser process informs the embedder through this 225// message. 226IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone, 227 int /* instance_id */) 228 229// When the user tabs to the end of the tab stops of a guest, the browser 230// process informs the embedder to tab out of the browser plugin. 231IPC_MESSAGE_CONTROL2(BrowserPluginMsg_AdvanceFocus, 232 int /* instance_id */, 233 bool /* reverse */) 234 235// When the guest starts/stops listening to touch events, it needs to notify the 236// plugin in the embedder about it. 237IPC_MESSAGE_CONTROL2(BrowserPluginMsg_ShouldAcceptTouchEvents, 238 int /* instance_id */, 239 bool /* accept */) 240 241// Inform the embedder of the cursor the guest wishes to display. 242IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetCursor, 243 int /* instance_id */, 244 content::WebCursor /* cursor */) 245 246// The guest has damage it wants to convey to the embedder so that it can 247// update its backing store. 248IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdateRect, 249 int /* instance_id */, 250 BrowserPluginMsg_UpdateRect_Params) 251 252IPC_MESSAGE_CONTROL4(BrowserPluginMsg_CopyFromCompositingSurface, 253 int /* instance_id */, 254 int /* request_id */, 255 gfx::Rect /* source_rect */, 256 gfx::Size /* dest_size */) 257 258// Guest renders into an FBO with textures provided by the embedder. 259// BrowserPlugin shares mostly the same logic as out-of-process RenderFrames but 260// because BrowserPlugins implement custom a second level of routing logic, 261// the IPCs need to be annotated with an extra instance_id. These messages 262// provide that extra id. 263IPC_MESSAGE_CONTROL2(BrowserPluginMsg_BuffersSwapped, 264 int /* instance_id */, 265 FrameMsg_BuffersSwapped_Params /* params */) 266 267IPC_MESSAGE_CONTROL2(BrowserPluginMsg_CompositorFrameSwapped, 268 int /* instance_id */, 269 FrameMsg_CompositorFrameSwapped_Params /* params */) 270 271// Forwards a PointerLock Unlock request to the BrowserPlugin. 272IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock, 273 int /* instance_id */, 274 bool /* enable */) 275 276// See comment about BrowserPluginMsg_BuffersSwapped and 277// BrowserPluginMsg_CompositorFrameSwapped for how these related 278// to the FrameHostMsg variants. 279IPC_MESSAGE_ROUTED1(BrowserPluginHostMsg_BuffersSwappedACK, 280 FrameHostMsg_BuffersSwappedACK_Params /* params */) 281 282// Acknowledge that we presented an ubercomp frame. 283IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_CompositorFrameSwappedACK, 284 int /* instance_id */, 285 FrameHostMsg_CompositorFrameSwappedACK_Params /* params */) 286