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_params.h"
16 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
17 #include "content/port/common/input_event_ack_state.h"
18 #include "content/public/common/common_param_traits.h"
19 #include "ipc/ipc_message_macros.h"
20 #include "third_party/WebKit/public/web/WebInputEvent.h"
21 #include "ui/events/latency_info.h"
22 #include "ui/gfx/point.h"
23 #include "ui/gfx/rect.h"
25 #undef IPC_MESSAGE_EXPORT
26 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
28 #ifdef IPC_MESSAGE_START
29 #error IPC_MESSAGE_START
32 #define IPC_MESSAGE_START InputMsgStart
34 IPC_ENUM_TRAITS_MAX_VALUE(content::InputEventAckState
,
35 content::INPUT_EVENT_ACK_STATE_MAX
)
36 IPC_ENUM_TRAITS_MAX_VALUE(
37 content::SyntheticGestureParams::GestureSourceType
,
38 content::SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX
)
39 IPC_ENUM_TRAITS_MAX_VALUE(
40 content::SyntheticGestureParams::GestureType
,
41 content::SyntheticGestureParams::SYNTHETIC_GESTURE_TYPE_MAX
)
43 IPC_STRUCT_TRAITS_BEGIN(content::EditCommand
)
44 IPC_STRUCT_TRAITS_MEMBER(name
)
45 IPC_STRUCT_TRAITS_MEMBER(value
)
46 IPC_STRUCT_TRAITS_END()
48 IPC_STRUCT_TRAITS_BEGIN(content::InputEvent
)
49 IPC_STRUCT_TRAITS_MEMBER(web_event
)
50 IPC_STRUCT_TRAITS_MEMBER(latency_info
)
51 IPC_STRUCT_TRAITS_MEMBER(is_keyboard_shortcut
)
52 IPC_STRUCT_TRAITS_END()
54 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticGestureParams
)
55 IPC_STRUCT_TRAITS_MEMBER(gesture_source_type
)
56 IPC_STRUCT_TRAITS_END()
58 IPC_STRUCT_TRAITS_BEGIN(content::SyntheticSmoothScrollGestureParams
)
59 IPC_STRUCT_TRAITS_PARENT(content::SyntheticGestureParams
)
60 IPC_STRUCT_TRAITS_MEMBER(distance
)
61 IPC_STRUCT_TRAITS_MEMBER(anchor_x
)
62 IPC_STRUCT_TRAITS_MEMBER(anchor_y
)
63 IPC_STRUCT_TRAITS_END()
65 // Sends an input event to the render widget.
66 IPC_MESSAGE_ROUTED3(InputMsg_HandleInputEvent
,
67 IPC::WebInputEventPointer
/* event */,
68 ui::LatencyInfo
/* latency_info */,
69 bool /* is_keyboard_shortcut */)
71 // Sends the cursor visibility state to the render widget.
72 IPC_MESSAGE_ROUTED1(InputMsg_CursorVisibilityChange
,
73 bool /* is_visible */)
75 // This message notifies the renderer that the next key event is bound to one
76 // or more pre-defined edit commands. If the next key event is not handled
77 // by webkit, the specified edit commands shall be executed against current
80 // * edit_commands (see chrome/common/edit_command_types.h)
81 // Contains one or more edit commands.
82 // See third_party/WebKit/Source/WebCore/editing/EditorCommand.cpp for detailed
83 // definition of webkit edit commands.
85 // This message must be sent just before sending a key event.
86 IPC_MESSAGE_ROUTED1(InputMsg_SetEditCommandsForNextKeyEvent
,
87 std::vector
<content::EditCommand
> /* edit_commands */)
89 // Message payload is the name/value of a WebCore edit command to execute.
90 IPC_MESSAGE_ROUTED2(InputMsg_ExecuteEditCommand
,
91 std::string
, /* name */
92 std::string
/* value */)
94 IPC_MESSAGE_ROUTED0(InputMsg_MouseCaptureLost
)
96 // TODO(darin): figure out how this meshes with RestoreFocus
97 IPC_MESSAGE_ROUTED1(InputMsg_SetFocus
,
100 // Tells the renderer to focus the first (last if reverse is true) focusable
102 IPC_MESSAGE_ROUTED1(InputMsg_SetInitialFocus
,
105 // Tells the renderer to scroll the currently focused node into rect only if
106 // the currently focused node is a Text node (textfield, text area or content
108 IPC_MESSAGE_ROUTED1(InputMsg_ScrollFocusedEditableNodeIntoRect
, gfx::Rect
)
110 // These messages are typically generated from context menus and request the
111 // renderer to apply the specified operation to the current selection.
112 IPC_MESSAGE_ROUTED0(InputMsg_Undo
)
113 IPC_MESSAGE_ROUTED0(InputMsg_Redo
)
114 IPC_MESSAGE_ROUTED0(InputMsg_Cut
)
115 IPC_MESSAGE_ROUTED0(InputMsg_Copy
)
116 #if defined(OS_MACOSX)
117 IPC_MESSAGE_ROUTED0(InputMsg_CopyToFindPboard
)
119 IPC_MESSAGE_ROUTED0(InputMsg_Paste
)
120 IPC_MESSAGE_ROUTED0(InputMsg_PasteAndMatchStyle
)
121 // Replaces the selected region or a word around the cursor with the
123 IPC_MESSAGE_ROUTED1(InputMsg_Replace
,
125 // Replaces the misspelling in the selected region with the specified string.
126 IPC_MESSAGE_ROUTED1(InputMsg_ReplaceMisspelling
,
128 IPC_MESSAGE_ROUTED0(InputMsg_Delete
)
129 IPC_MESSAGE_ROUTED0(InputMsg_SelectAll
)
131 IPC_MESSAGE_ROUTED0(InputMsg_Unselect
)
133 // Requests the renderer to select the region between two points.
134 // Expects a SelectRange_ACK message when finished.
135 IPC_MESSAGE_ROUTED2(InputMsg_SelectRange
,
136 gfx::Point
/* start */,
137 gfx::Point
/* end */)
139 // Requests the renderer to move the caret selection toward the point.
140 // Expects a MoveCaret_ACK message when finished.
141 IPC_MESSAGE_ROUTED1(InputMsg_MoveCaret
,
142 gfx::Point
/* location */)
144 #if defined(OS_ANDROID)
145 // Sent when the user clicks on the find result bar to activate a find result.
146 // The point (x,y) is in fractions of the content document's width and height.
147 IPC_MESSAGE_ROUTED3(InputMsg_ActivateNearestFindResult
,
148 int /* request_id */,
153 // -----------------------------------------------------------------------------
154 // Messages sent from the renderer to the browser.
156 // Acknowledges receipt of a InputMsg_HandleInputEvent message.
157 IPC_MESSAGE_ROUTED3(InputHostMsg_HandleInputEvent_ACK
,
158 WebKit::WebInputEvent::Type
,
159 content::InputEventAckState
/* ack_result */,
160 ui::LatencyInfo
/* latency_info */)
163 // Adding a new message? Stick to the sort order above: first platform
164 // independent InputMsg, then ifdefs for platform specific InputMsg, then
165 // platform independent InputHostMsg, then ifdefs for platform specific