Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: content/browser/frame_host/input/legacy_ipc_frame_input_handler.cc

Issue 2884243003: Add a mojo channel for frame messages. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 #include "content/browser/frame_host/input/legacy_ipc_frame_input_handler.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "content/common/input_messages.h"
10
11 namespace content {
12
13 LegacyIPCFrameInputHandler::LegacyIPCFrameInputHandler(
14 RenderFrameHostImpl* frame_host,
15 int routing_id)
16 : frame_host_(frame_host), routing_id_(routing_id) {
17 DCHECK(frame_host);
18 }
19
20 LegacyIPCFrameInputHandler::~LegacyIPCFrameInputHandler() {}
21
22 void LegacyIPCFrameInputHandler::SetCompositionFromExistingText(
23 int32_t start,
24 int32_t end,
25 const std::vector<ui::CompositionUnderline>& ui_underlines) {
26 std::vector<blink::WebCompositionUnderline> underlines;
27 for (const auto& underline : ui_underlines) {
28 blink::WebCompositionUnderline blink_underline(
29 underline.start_offset, underline.end_offset, underline.color,
30 underline.thick, underline.background_color);
31 underlines.push_back(blink_underline);
32 }
33
34 SendInput(base::WrapUnique(new InputMsg_SetCompositionFromExistingText(
dcheng 2017/05/17 04:49:06 General nit: writing base::MakeUnique<T>(...) is p
dtapuska 2017/05/17 17:08:07 Done.
35 routing_id_, start, end, underlines)));
36 }
37
38 void LegacyIPCFrameInputHandler::ExtendSelectionAndDelete(int32_t before,
39 int32_t after) {
40 SendInput(base::WrapUnique(
41 new InputMsg_ExtendSelectionAndDelete(routing_id_, before, after)));
42 }
43
44 void LegacyIPCFrameInputHandler::DeleteSurroundingText(int32_t before,
45 int32_t after) {
46 SendInput(base::WrapUnique(
47 new InputMsg_DeleteSurroundingText(routing_id_, before, after)));
48 }
49
50 void LegacyIPCFrameInputHandler::DeleteSurroundingTextInCodePoints(
51 int32_t before,
52 int32_t after) {
53 SendInput(base::WrapUnique(new InputMsg_DeleteSurroundingTextInCodePoints(
54 routing_id_, before, after)));
55 }
56
57 void LegacyIPCFrameInputHandler::SetEditableSelectionOffsets(int32_t start,
58 int32_t end) {
59 SendInput(base::WrapUnique(
60 new InputMsg_SetEditableSelectionOffsets(routing_id_, start, end)));
61 }
62
63 void LegacyIPCFrameInputHandler::ExecuteEditCommand(
64 const std::string& command,
65 const base::Optional<std::string>& value) {
66 if (!value.has_value()) {
dcheng 2017/05/17 04:49:06 Nit: this could be written as !value
dtapuska 2017/05/17 17:08:07 Done.
67 SendInput(base::WrapUnique(
68 new InputMsg_ExecuteNoValueEditCommand(routing_id_, command)));
69 }
70 }
71
72 void LegacyIPCFrameInputHandler::Undo() {
73 SendInput(base::WrapUnique(new InputMsg_Undo(routing_id_)));
74 }
75
76 void LegacyIPCFrameInputHandler::Redo() {
77 SendInput(base::WrapUnique(new InputMsg_Redo(routing_id_)));
78 }
79
80 void LegacyIPCFrameInputHandler::Cut() {
81 SendInput(base::WrapUnique(new InputMsg_Cut(routing_id_)));
82 }
83
84 void LegacyIPCFrameInputHandler::Copy() {
85 SendInput(base::WrapUnique(new InputMsg_Copy(routing_id_)));
86 }
87
88 void LegacyIPCFrameInputHandler::CopyToFindPboard() {
89 #if defined(OS_MACOSX)
90 SendInput(base::WrapUnique(new InputMsg_CopyToFindPboard(routing_id_)));
91 #endif
92 }
93
94 void LegacyIPCFrameInputHandler::Paste() {
95 SendInput(base::WrapUnique(new InputMsg_Paste(routing_id_)));
96 }
97
98 void LegacyIPCFrameInputHandler::PasteAndMatchStyle() {
99 SendInput(base::WrapUnique(new InputMsg_PasteAndMatchStyle(routing_id_)));
100 }
101
102 void LegacyIPCFrameInputHandler::Replace(const std::string& word) {
103 SendInput(base::WrapUnique(
104 new InputMsg_Replace(routing_id_, base::UTF8ToUTF16(word))));
105 }
106
107 void LegacyIPCFrameInputHandler::ReplaceMisspelling(const std::string& word) {
108 SendInput(base::WrapUnique(
109 new InputMsg_ReplaceMisspelling(routing_id_, base::UTF8ToUTF16(word))));
110 }
111
112 void LegacyIPCFrameInputHandler::Delete() {
113 SendInput(base::WrapUnique(new InputMsg_Delete(routing_id_)));
114 }
115
116 void LegacyIPCFrameInputHandler::SelectAll() {
117 SendInput(base::WrapUnique(new InputMsg_SelectAll(routing_id_)));
118 }
119
120 void LegacyIPCFrameInputHandler::CollapseSelection() {
121 SendInput(base::WrapUnique(new InputMsg_CollapseSelection(routing_id_)));
122 }
123
124 void LegacyIPCFrameInputHandler::SelectRange(const gfx::Point& point,
125 const gfx::Point& extent) {
126 SendInput(
127 base::WrapUnique(new InputMsg_SelectRange(routing_id_, point, extent)));
128 }
129
130 void LegacyIPCFrameInputHandler::AdjustSelectionByCharacterOffset(int32_t start,
131 int32_t end) {
132 SendInput(base::WrapUnique(
133 new InputMsg_AdjustSelectionByCharacterOffset(routing_id_, start, end)));
134 }
135
136 void LegacyIPCFrameInputHandler::MoveRangeSelectionExtent(
137 const gfx::Point& extent) {
138 SendInput(base::WrapUnique(
139 new InputMsg_MoveRangeSelectionExtent(routing_id_, extent)));
140 }
141
142 void LegacyIPCFrameInputHandler::SendInput(
143 std::unique_ptr<IPC::Message> message) {
144 frame_host_->GetRenderWidgetHost()->input_router()->SendInput(
145 std::move(message));
146 }
147
148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698