| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/devtools/protocol/input_handler.h" | 5 #include "content/browser/devtools/protocol/input_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "cc/output/compositor_frame_metadata.h" | 13 #include "cc/output/compositor_frame_metadata.h" |
| 14 #include "content/browser/devtools/devtools_session.h" | 14 #include "content/browser/devtools/devtools_session.h" |
| 15 #include "content/browser/devtools/protocol/native_input_event_builder.h" |
| 15 #include "content/browser/frame_host/render_frame_host_impl.h" | 16 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_impl.h" | 17 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 17 #include "content/common/input/synthetic_pinch_gesture_params.h" | 18 #include "content/common/input/synthetic_pinch_gesture_params.h" |
| 18 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 19 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 19 #include "content/common/input/synthetic_tap_gesture_params.h" | 20 #include "content/common/input/synthetic_tap_gesture_params.h" |
| 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 21 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 21 #include "ui/events/keycodes/dom/keycode_converter.h" | 22 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 22 #include "ui/gfx/geometry/point.h" | 23 #include "ui/gfx/geometry/point.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 base::StringPrintf("Unexpected event type '%s'", type.c_str()))); | 280 base::StringPrintf("Unexpected event type '%s'", type.c_str()))); |
| 280 return; | 281 return; |
| 281 } | 282 } |
| 282 | 283 |
| 283 NativeWebKeyboardEvent event( | 284 NativeWebKeyboardEvent event( |
| 284 web_event_type, | 285 web_event_type, |
| 285 GetEventModifiers(modifiers.fromMaybe(blink::WebInputEvent::NoModifiers), | 286 GetEventModifiers(modifiers.fromMaybe(blink::WebInputEvent::NoModifiers), |
| 286 auto_repeat.fromMaybe(false), | 287 auto_repeat.fromMaybe(false), |
| 287 is_keypad.fromMaybe(false)), | 288 is_keypad.fromMaybe(false)), |
| 288 GetEventTimeTicks(std::move(timestamp))); | 289 GetEventTimeTicks(std::move(timestamp))); |
| 289 event.skip_in_browser = true; | 290 |
| 290 if (!SetKeyboardEventText(event.text, std::move(text))) { | 291 if (!SetKeyboardEventText(event.text, std::move(text))) { |
| 291 callback->sendFailure(Response::InvalidParams("Invalid 'text' parameter")); | 292 callback->sendFailure(Response::InvalidParams("Invalid 'text' parameter")); |
| 292 return; | 293 return; |
| 293 } | 294 } |
| 294 if (!SetKeyboardEventText(event.unmodifiedText, std::move(unmodified_text))) { | 295 if (!SetKeyboardEventText(event.unmodifiedText, std::move(unmodified_text))) { |
| 295 callback->sendFailure( | 296 callback->sendFailure( |
| 296 Response::InvalidParams("Invalid 'unmodifiedText' parameter")); | 297 Response::InvalidParams("Invalid 'unmodifiedText' parameter")); |
| 297 return; | 298 return; |
| 298 } | 299 } |
| 299 | 300 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 311 | 312 |
| 312 if (key.isJust()) { | 313 if (key.isJust()) { |
| 313 event.domKey = static_cast<int>( | 314 event.domKey = static_cast<int>( |
| 314 ui::KeycodeConverter::KeyStringToDomKey(key.fromJust())); | 315 ui::KeycodeConverter::KeyStringToDomKey(key.fromJust())); |
| 315 } | 316 } |
| 316 | 317 |
| 317 if (!host_ || !host_->GetRenderWidgetHost()) { | 318 if (!host_ || !host_->GetRenderWidgetHost()) { |
| 318 callback->sendFailure(Response::InternalError()); | 319 callback->sendFailure(Response::InternalError()); |
| 319 return; | 320 return; |
| 320 } | 321 } |
| 321 | 322 event.os_event = NativeInputEventBuilder::Build(event); |
| 322 host_->GetRenderWidgetHost()->Focus(); | 323 host_->GetRenderWidgetHost()->Focus(); |
| 323 input_queued_ = false; | 324 input_queued_ = false; |
| 324 pending_key_callbacks_.push_back(std::move(callback)); | 325 pending_key_callbacks_.push_back(std::move(callback)); |
| 325 host_->GetRenderWidgetHost()->ForwardKeyboardEvent(event); | 326 host_->GetRenderWidgetHost()->ForwardKeyboardEvent(event); |
| 326 if (!input_queued_) { | 327 if (!input_queued_) { |
| 327 pending_key_callbacks_.back()->sendSuccess(); | 328 pending_key_callbacks_.back()->sendSuccess(); |
| 328 pending_key_callbacks_.pop_back(); | 329 pending_key_callbacks_.pop_back(); |
| 329 } | 330 } |
| 330 } | 331 } |
| 331 | 332 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 for (auto& callback : pending_key_callbacks_) | 644 for (auto& callback : pending_key_callbacks_) |
| 644 callback->sendSuccess(); | 645 callback->sendSuccess(); |
| 645 pending_key_callbacks_.clear(); | 646 pending_key_callbacks_.clear(); |
| 646 for (auto& callback : pending_mouse_callbacks_) | 647 for (auto& callback : pending_mouse_callbacks_) |
| 647 callback->sendSuccess(); | 648 callback->sendSuccess(); |
| 648 pending_mouse_callbacks_.clear(); | 649 pending_mouse_callbacks_.clear(); |
| 649 } | 650 } |
| 650 | 651 |
| 651 } // namespace protocol | 652 } // namespace protocol |
| 652 } // namespace content | 653 } // namespace content |
| OLD | NEW |