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 header, no traditional include guard.
9 #include "base/basictypes.h"
10 #include "base/process/process.h"
11 #include "cc/surfaces/surface.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/platform/WebFocusType.h"
23 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
24 #include "third_party/WebKit/public/web/WebDragOperation.h"
25 #include "third_party/WebKit/public/web/WebDragStatus.h"
26 #include "third_party/skia/include/core/SkBitmap.h"
27 #include "ui/gfx/geometry/point.h"
28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/size.h"
30 #include "ui/gfx/ipc/gfx_param_traits.h"
33 #undef IPC_MESSAGE_EXPORT
34 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
36 #define IPC_MESSAGE_START BrowserPluginMsgStart
39 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDragStatus
, blink::WebDragStatusLast
)
40 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebFocusType
, blink::WebFocusTypeLast
)
42 IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params
)
43 IPC_STRUCT_MEMBER(bool, focused
)
44 IPC_STRUCT_MEMBER(bool, visible
)
45 // The new size of the guest view.
46 IPC_STRUCT_MEMBER(gfx::Rect
, view_rect
)
47 // Whether the browser plugin is a full page plugin document.
48 IPC_STRUCT_MEMBER(bool, is_full_page_plugin
)
51 // Browser plugin messages
53 // -----------------------------------------------------------------------------
54 // These messages are from the embedder to the browser process.
55 // Most messages from the embedder to the browser process are CONTROL because
56 // they are routed to the appropriate BrowserPluginGuest based on the
57 // browser_plugin_instance_id which is unique per embedder process.
59 // This message is sent from BrowserPlugin to BrowserPluginGuest to issue an
61 IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_ExecuteEditCommand
,
62 int /* browser_plugin_instance_id */,
63 std::string
/* command */)
65 // This message must be sent just before sending a key event.
66 IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent
,
67 int /* browser_plugin_instance_id */,
68 std::vector
<content::EditCommand
> /* edit_commands */)
70 // This message is sent from BrowserPlugin to BrowserPluginGuest whenever IME
71 // composition state is updated.
73 BrowserPluginHostMsg_ImeSetComposition
,
74 int /* browser_plugin_instance_id */,
75 std::string
/* text */,
76 std::vector
<blink::WebCompositionUnderline
> /* underlines */,
77 int /* selectiont_start */,
78 int /* selection_end */)
80 // This message is sent from BrowserPlugin to BrowserPluginGuest to notify that
81 // confirming the current composition is requested.
82 IPC_MESSAGE_CONTROL3(BrowserPluginHostMsg_ImeConfirmComposition
,
83 int /* browser_plugin_instance_id */,
84 std::string
/* text */,
85 bool /* keep selection */)
87 // Deletes the current selection plus the specified number of characters before
88 // and after the selection or caret.
89 IPC_MESSAGE_CONTROL3(BrowserPluginHostMsg_ExtendSelectionAndDelete
,
90 int /* browser_plugin_instance_id */,
94 // This message is sent to the browser process to indicate that the
95 // BrowserPlugin identified by |browser_plugin_instance_id| is ready to serve
96 // as container for a guest. |params| is the state of the BrowserPlugin.
97 // This message is routed because we create a BrowserPluginEmbedder object
98 // the first time we see this message arrive to a WebContents. We need a routing
99 // ID to get this message to a particular WebContents.
100 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_Attach
,
101 int /* browser_plugin_instance_id */,
102 BrowserPluginHostMsg_Attach_Params
/* params */)
104 // This message is sent to the browser process to indicate that the
105 // BrowserPlugin identified by |browser_plugin_instance_id| will no longer serve
106 // as a container for a guest.
107 IPC_MESSAGE_CONTROL1(BrowserPluginHostMsg_Detach
,
108 int /* browser_plugin_instance_id */)
110 // Tells the guest to focus or defocus itself.
111 IPC_MESSAGE_CONTROL3(BrowserPluginHostMsg_SetFocus
,
112 int /* browser_plugin_instance_id */,
114 blink::WebFocusType
/* focus_type */)
116 // Sends an input event to the guest.
117 IPC_MESSAGE_CONTROL3(BrowserPluginHostMsg_HandleInputEvent
,
118 int /* browser_plugin_instance_id */,
119 gfx::Rect
/* guest_window_rect */,
120 IPC::WebInputEventPointer
/* event */)
122 // Notify the guest renderer that some resources given to the embededer
123 // are not used any more.
124 IPC_MESSAGE_CONTROL2(
125 BrowserPluginHostMsg_ReclaimCompositorResources
,
126 int /* browser_plugin_instance_id */,
127 FrameHostMsg_ReclaimCompositorResources_Params
/* params */)
129 // Tells the guest it has been shown or hidden.
130 IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_SetVisibility
,
131 int /* browser_plugin_instance_id */,
134 // Tells the guest that a drag event happened on the plugin.
135 IPC_MESSAGE_CONTROL5(BrowserPluginHostMsg_DragStatusUpdate
,
136 int /* browser_plugin_instance_id */,
137 blink::WebDragStatus
/* drag_status */,
138 content::DropData
/* drop_data */,
139 blink::WebDragOperationsMask
/* operation_mask */,
140 gfx::Point
/* plugin_location */)
142 // Sends a PointerLock Lock ACK to the BrowserPluginGuest.
143 IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_LockMouse_ACK
,
144 int /* browser_plugin_instance_id */,
145 bool /* succeeded */)
147 // Sends a PointerLock Unlock ACK to the BrowserPluginGuest.
148 IPC_MESSAGE_CONTROL1(BrowserPluginHostMsg_UnlockMouse_ACK
,
149 int /* browser_plugin_instance_id */)
151 // Sent when plugin's position has changed.
152 IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_UpdateGeometry
,
153 int /* browser_plugin_instance_id */,
154 gfx::Rect
/* view_rect */)
156 IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SatisfySequence
,
157 int /* browser_plugin_instance_id */,
158 cc::SurfaceSequence
/* sequence */)
160 IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_RequireSequence
,
161 int /* browser_plugin_instance_id */,
162 cc::SurfaceId
/* surface_id */,
163 cc::SurfaceSequence
/* sequence */)
165 // -----------------------------------------------------------------------------
166 // These messages are from the browser process to the embedder.
168 // When the guest crashes, the browser process informs the embedder through this
170 IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone
,
171 int /* browser_plugin_instance_id */)
173 // When the user tabs to the end of the tab stops of a guest, the browser
174 // process informs the embedder to tab out of the browser plugin.
175 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_AdvanceFocus
,
176 int /* browser_plugin_instance_id */,
179 // When the guest starts/stops listening to touch events, it needs to notify the
180 // plugin in the embedder about it.
181 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_ShouldAcceptTouchEvents
,
182 int /* browser_plugin_instance_id */,
185 // Tells the guest to change its background opacity.
186 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetContentsOpaque
,
187 int /* browser_plugin_instance_id */,
190 // Inform the embedder of the cursor the guest wishes to display.
191 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetCursor
,
192 int /* browser_plugin_instance_id */,
193 content::WebCursor
/* cursor */)
195 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_CompositorFrameSwapped
,
196 int /* browser_plugin_instance_id */,
197 FrameMsg_CompositorFrameSwapped_Params
/* params */)
199 IPC_MESSAGE_CONTROL5(BrowserPluginMsg_SetChildFrameSurface
,
200 int /* browser_plugin_instance_id */,
201 cc::SurfaceId
/* surface_id */,
202 gfx::Size
/* frame_size */,
203 float /* scale_factor */,
204 cc::SurfaceSequence
/* sequence */)
206 // Forwards a PointerLock Unlock request to the BrowserPlugin.
207 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock
,
208 int /* browser_plugin_instance_id */,
211 // Sends text to be displayed in tooltip.
212 IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetTooltipText
,
213 int /* browser_plugin_instance_id */,
214 base::string16
/* tooltip_text */)
216 // Acknowledge that we presented an ubercomp frame.
217 IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_CompositorFrameSwappedACK
,
218 int /* browser_plugin_instance_id */,
219 FrameHostMsg_CompositorFrameSwappedACK_Params
/* params */)