Add support for edit commands in OOPIFs.
Previously, edit commands from the browser were sent via
InputMsg_SetEditCommandsForNextKeyEvent to focused RenderWidgets, but
for OOPIFs the IPC was dropped since it was only handled in
RenderViews. To fix this, this CL moves the IPC handling and
associated edit command bookkeeping to RenderWidget.
BUG=640706
Review-Url: https://codereview.chromium.org/2287803002
Cr-Commit-Position: refs/heads/master@{#418126}
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index eb730cd6..30a8722 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -486,6 +486,8 @@
IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition)
IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition)
IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
+ IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
+ OnSetEditCommandsForNextKeyEvent)
IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted,
OnSyntheticGestureCompleted)
@@ -695,6 +697,11 @@
webwidget_->mouseCaptureLost();
}
+void RenderWidget::OnSetEditCommandsForNextKeyEvent(
+ const EditCommands& edit_commands) {
+ edit_commands_ = edit_commands;
+}
+
void RenderWidget::OnSetFocus(bool enable) {
has_focus_ = enable;
@@ -882,8 +889,17 @@
}
void RenderWidget::OnDidHandleKeyEvent() {
- if (owner_delegate_)
- owner_delegate_->RenderWidgetDidHandleKeyEvent();
+ ClearEditCommands();
+}
+
+void RenderWidget::SetEditCommandForNextKeyEvent(const std::string& name,
+ const std::string& value) {
+ ClearEditCommands();
+ edit_commands_.emplace_back(name, value);
+}
+
+void RenderWidget::ClearEditCommands() {
+ edit_commands_.clear();
}
void RenderWidget::OnDidOverscroll(const ui::DidOverscrollParams& params) {