Chromium Code Reviews| Index: content/browser/devtools/protocol/input_handler.cc |
| diff --git a/content/browser/devtools/protocol/input_handler.cc b/content/browser/devtools/protocol/input_handler.cc |
| index 04be3a8e487ec7ff0f44b35f1fbaf1e5c8fc5e5e..113728903c594c6ab7ba81b3161fa09b17082b81 100644 |
| --- a/content/browser/devtools/protocol/input_handler.cc |
| +++ b/content/browser/devtools/protocol/input_handler.cc |
| @@ -137,6 +137,15 @@ InputHandler::InputHandler() |
| InputHandler::~InputHandler() { |
| } |
| +void InputHandler::OnInputEventAck(const blink::WebInputEvent& event, |
| + bool is_synthetic) { |
| + if (blink::WebInputEvent::isKeyboardEventType(event.type) && is_synthetic && |
| + !pending_key_event_ids_.empty()) { |
| + SendDispatchKeyEventResponse(pending_key_event_ids_.front()); |
| + pending_key_event_ids_.pop(); |
| + } |
| +} |
| + |
| void InputHandler::SetRenderWidgetHost(RenderWidgetHostImpl* host) { |
| host_ = host; |
| } |
| @@ -152,6 +161,7 @@ void InputHandler::OnSwapCompositorFrame( |
| } |
| Response InputHandler::DispatchKeyEvent( |
| + DevToolsCommandId command_id, |
| const std::string& type, |
| const int* modifiers, |
| const double* timestamp, |
| @@ -167,6 +177,7 @@ Response InputHandler::DispatchKeyEvent( |
| const bool* is_system_key) { |
| NativeWebKeyboardEvent event; |
| event.skip_in_browser = true; |
| + event.is_synthetic = true; |
| if (type == dispatch_key_event::kTypeKeyDown) { |
| event.type = blink::WebInputEvent::KeyDown; |
| @@ -212,7 +223,9 @@ Response InputHandler::DispatchKeyEvent( |
| if (!host_) |
| return Response::ServerError("Could not connect to view"); |
| + pending_key_event_ids_.push(command_id); |
| host_->Focus(); |
| + host_->AddInputEventObserver(this); |
|
dtapuska
2016/10/14 19:06:29
So is it possible to call this API twice in a row?
samuong
2016/10/20 23:36:18
The RWHI will check if the observer has already be
|
| host_->ForwardKeyboardEvent(event); |
| return Response::OK(); |
| } |
| @@ -471,6 +484,12 @@ Response InputHandler::SynthesizeTapGesture( |
| return Response::OK(); |
| } |
| +void InputHandler::SendDispatchKeyEventResponse(DevToolsCommandId command_id) { |
| + client_->SendDispatchKeyEventResponse( |
| + command_id, DispatchKeyEventResponse::Create()); |
| + host_->RemoveInputEventObserver(this); |
| +} |
| + |
| void InputHandler::SendSynthesizePinchGestureResponse( |
| DevToolsCommandId command_id, |
| SyntheticGesture::Result result) { |