1 // Copyright (c) 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.
5 // IPC messages for input events and other messages that require processing in
6 // order relative to input events.
7 // Multiply-included message file, hence no include guard.
9 #include "base/strings/string16.h"
10 #include "content/common/content_export.h"
11 #include "content/common/content_param_traits.h"
12 #include "content/common/edit_command.h"
13 #include "content/common/input/input_event.h"
14 #include "content/common/input/input_param_traits.h"
15 #include "content/common/input/synthetic_gesture_packet.h"
16 #include "content/common/input/synthetic_gesture_params.h"
17 #include "content/common/input/synthetic_pinch_gesture_params.h"
18 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
19 #include "content/port/common/input_event_ack_state.h"
20 #include "content/public/common/common_param_traits.h"
21 #include "ipc/ipc_message_macros.h"
22 #include "third_party/WebKit/public/web/WebInputEvent.h"
23 #include "ui/events/latency_info.h"
24 #include "ui/gfx/point.h"
25 #include "ui/gfx/rect.h"
27 #undef IPC_MESSAGE_EXPORT
28 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
30 #ifdef IPC_MESSAGE_START
31 #error IPC_MESSAGE_START
34 #define IPC_MESSAGE_START InputMsgStart
36 IPC_ENUM_TRAITS_MAX_VALUE(content::InputEventAckState
,
37 content::INPUT_EVENT_ACK_STATE_MAX
)
38 IPC_ENUM_TRAITS_MAX_VALUE(
39 content::SyntheticGestureParams::GestureSourceType
,
40 content::SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX
)
41 IPC_ENUM_TRAITS_MAX_VALUE(
42 content::SyntheticGestureParams::GestureType
,
43 content::SyntheticGestureParams::SYNTHETIC_GESTURE_TYPE_MAX
)
45 IPC_STRUCT_TRAITS_BEGIN(content::EditCommand
)
46 IPC_STRUCT_TRAITS_MEMBER(name
)
47 IPC_STRUCT_TRAITS_MEMBER(value
)
48 IPC_STRUCT_TRAITS_END()
50 IPC_STRUCT_TRAITS_BEGIN(content::InputEvent
)
51 IPC_STRUCT_TRAITS_MEMBER(web_event
)
52 IPC_STRUCT_TRAITS_MEMBER(latency_info
)
53 IPC_STRUCT_TRAITS_MEMBER(is_keyboard_shortcut
)
54 IPC_STRUCT_TRAITS_END()
56 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticGestureParams
)
57 IPC_STRUCT_TRAITS_MEMBER(gesture_source_type
)
58 IPC_STRUCT_TRAITS_END()
60 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticSmoothScrollGestureParams
)
61 IPC_STRUCT_TRAITS_PARENT(content::SyntheticGestureParams
)
62 IPC_STRUCT_TRAITS_MEMBER(distance
)
63 IPC_STRUCT_TRAITS_MEMBER(anchor
)
64 IPC_STRUCT_TRAITS_MEMBER(speed_in_pixels_s
)
65 IPC_STRUCT_TRAITS_END()
67 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPinchGestureParams
)
68 IPC_STRUCT_TRAITS_PARENT(content::SyntheticGestureParams
)
69 IPC_STRUCT_TRAITS_MEMBER(zoom_in
)
70 IPC_STRUCT_TRAITS_MEMBER(total_num_pixels_covered
)
71 IPC_STRUCT_TRAITS_MEMBER(anchor
)
72 IPC_STRUCT_TRAITS_MEMBER(relative_pointer_speed_in_pixels_s
)
73 IPC_STRUCT_TRAITS_END()
75 // Sends an input event to the render widget.
76 IPC_MESSAGE_ROUTED3(InputMsg_HandleInputEvent
,
77 IPC::WebInputEventPointer
/* event */,
78 ui::LatencyInfo
/* latency_info */,
79 bool /* is_keyboard_shortcut */)
81 // Sends the cursor visibility state to the render widget.
82 IPC_MESSAGE_ROUTED1(InputMsg_CursorVisibilityChange
,
83 bool /* is_visible */)
85 // This message notifies the renderer that the next key event is bound to one
86 // or more pre-defined edit commands. If the next key event is not handled
87 // by webkit, the specified edit commands shall be executed against current
90 // * edit_commands (see chrome/common/edit_command_types.h)
91 // Contains one or more edit commands.
92 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed
93 // definition of webkit edit commands.
95 // This message must be sent just before sending a key event.
96 IPC_MESSAGE_ROUTED1(InputMsg_SetEditCommandsForNextKeyEvent
,
97 std::vector
<content::EditCommand
> /* edit_commands */)
99 // Message payload is the name/value of a WebCore edit command to execute.
100 IPC_MESSAGE_ROUTED2(InputMsg_ExecuteEditCommand
,
101 std::string
, /* name */
102 std::string
/* value */)
104 IPC_MESSAGE_ROUTED0(InputMsg_MouseCaptureLost
)
106 // TODO(darin): figure out how this meshes with RestoreFocus
107 IPC_MESSAGE_ROUTED1(InputMsg_SetFocus
,
110 // Tells the renderer to focus the first (last if reverse is true) focusable
112 IPC_MESSAGE_ROUTED1(InputMsg_SetInitialFocus
,
115 // Tells the renderer to scroll the currently focused node into rect only if
116 // the currently focused node is a Text node (textfield, text area or content
118 IPC_MESSAGE_ROUTED1(InputMsg_ScrollFocusedEditableNodeIntoRect
, gfx::Rect
)
120 // These messages are typically generated from context menus and request the
121 // renderer to apply the specified operation to the current selection.
122 IPC_MESSAGE_ROUTED0(InputMsg_Undo
)
123 IPC_MESSAGE_ROUTED0(InputMsg_Redo
)
124 IPC_MESSAGE_ROUTED0(InputMsg_Cut
)
125 IPC_MESSAGE_ROUTED0(InputMsg_Copy
)
126 #if defined(OS_MACOSX)
127 IPC_MESSAGE_ROUTED0(InputMsg_CopyToFindPboard
)
129 IPC_MESSAGE_ROUTED0(InputMsg_Paste
)
130 IPC_MESSAGE_ROUTED0(InputMsg_PasteAndMatchStyle
)
131 // Replaces the selected region or a word around the cursor with the
133 IPC_MESSAGE_ROUTED1(InputMsg_Replace
,
135 // Replaces the misspelling in the selected region with the specified string.
136 IPC_MESSAGE_ROUTED1(InputMsg_ReplaceMisspelling
,
138 IPC_MESSAGE_ROUTED0(InputMsg_Delete
)
139 IPC_MESSAGE_ROUTED0(InputMsg_SelectAll
)
141 IPC_MESSAGE_ROUTED0(InputMsg_Unselect
)
143 // Requests the renderer to select the region between two points.
144 // Expects a SelectRange_ACK message when finished.
145 IPC_MESSAGE_ROUTED2(InputMsg_SelectRange
,
146 gfx::Point
/* start */,
147 gfx::Point
/* end */)
149 // Requests the renderer to move the caret selection toward the point.
150 // Expects a MoveCaret_ACK message when finished.
151 IPC_MESSAGE_ROUTED1(InputMsg_MoveCaret
,
152 gfx::Point
/* location */)
154 #if defined(OS_ANDROID)
155 // Sent when the user clicks on the find result bar to activate a find result.
156 // The point (x,y) is in fractions of the content document's width and height.
157 IPC_MESSAGE_ROUTED3(InputMsg_ActivateNearestFindResult
,
158 int /* request_id */,
163 IPC_MESSAGE_ROUTED0(InputMsg_SyntheticGestureCompleted
);
165 // -----------------------------------------------------------------------------
166 // Messages sent from the renderer to the browser.
168 // Acknowledges receipt of a InputMsg_HandleInputEvent message.
169 IPC_MESSAGE_ROUTED3(InputHostMsg_HandleInputEvent_ACK
,
170 blink::WebInputEvent::Type
,
171 content::InputEventAckState
/* ack_result */,
172 ui::LatencyInfo
/* latency_info */)
174 IPC_MESSAGE_ROUTED1(InputHostMsg_QueueSyntheticGesture
,
175 content::SyntheticGesturePacket
)
178 // Adding a new message? Stick to the sort order above: first platform
179 // independent InputMsg, then ifdefs for platform specific InputMsg, then
180 // platform independent InputHostMsg, then ifdefs for platform specific