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 610b71cd3390c4d0cf403ba2afe5e3f1ae713c3b..a75685f8087bdd27486488e0ee99c7bf3ec67790 100644 | 
| --- a/content/browser/devtools/protocol/input_handler.cc | 
| +++ b/content/browser/devtools/protocol/input_handler.cc | 
| @@ -212,6 +212,82 @@ Response InputHandler::DispatchKeyEvent( | 
| return Response::OK(); | 
| } | 
| +Response InputHandler::DispatchKeyEvent( | 
| 
 
dgozman
2015/06/02 13:22:01
Please implement one of the methods using another
 
Habib Virji
2015/06/02 14:15:19
Done.
 
 | 
| + const std::string& type, | 
| + const int* modifiers, | 
| + const double* timestamp, | 
| + const std::string* text, | 
| + const std::string* unmodified_text, | 
| + const std::string* key_identifier, | 
| + const std::string* code, | 
| + const std::string* key, | 
| + const int* windows_virtual_key_code, | 
| + const int* native_virtual_key_code, | 
| + const bool* auto_repeat, | 
| + const bool* is_keypad, | 
| + const bool* is_system_key) { | 
| + NativeWebKeyboardEvent event; | 
| + | 
| + if (type == dispatch_key_event::kTypeKeyDown) { | 
| + event.type = blink::WebInputEvent::KeyDown; | 
| + } else if (type == dispatch_key_event::kTypeKeyUp) { | 
| + event.type = blink::WebInputEvent::KeyUp; | 
| + } else if (type == dispatch_key_event::kTypeChar) { | 
| + event.type = blink::WebInputEvent::Char; | 
| + } else if (type == dispatch_key_event::kTypeRawKeyDown) { | 
| + event.type = blink::WebInputEvent::RawKeyDown; | 
| + } else { | 
| + return Response::InvalidParams( | 
| + base::StringPrintf("Unexpected event type '%s'", type.c_str())); | 
| + } | 
| + | 
| + SetEventModifiers(&event, modifiers); | 
| + SetEventTimestamp(&event, timestamp); | 
| + if (!SetKeyboardEventText(event.text, text)) | 
| + return Response::InvalidParams("Invalid 'text' parameter"); | 
| + if (!SetKeyboardEventText(event.unmodifiedText, unmodified_text)) | 
| + return Response::InvalidParams("Invalid 'unmodifiedText' parameter"); | 
| + | 
| + if (windows_virtual_key_code) | 
| + event.windowsKeyCode = *windows_virtual_key_code; | 
| + if (native_virtual_key_code) | 
| + event.nativeKeyCode = *native_virtual_key_code; | 
| + if (auto_repeat && *auto_repeat) | 
| + event.modifiers |= blink::WebInputEvent::IsAutoRepeat; | 
| + if (is_keypad && *is_keypad) | 
| + event.modifiers |= blink::WebInputEvent::IsKeyPad; | 
| + if (is_system_key) | 
| + event.isSystemKey = *is_system_key; | 
| + | 
| + if (key_identifier) { | 
| + if (key_identifier->size() > | 
| + blink::WebKeyboardEvent::keyIdentifierLengthCap) { | 
| + return Response::InvalidParams("Invalid 'keyIdentifier' parameter"); | 
| + } | 
| + for (size_t i = 0; i < key_identifier->size(); ++i) | 
| + event.keyIdentifier[i] = (*key_identifier)[i]; | 
| + } else if (event.type != blink::WebInputEvent::Char) { | 
| + event.setKeyIdentifierFromWindowsKeyCode(); | 
| + } | 
| + | 
| + if (code) { | 
| + event.domCode = static_cast<int>( | 
| + ui::KeycodeConverter::CodeStringToDomCode(code->c_str())); | 
| + } | 
| + | 
| + if (key) { | 
| + event.domKey = static_cast<int>( | 
| + ui::KeycodeConverter::KeyStringToDomKey(key->c_str())); | 
| + } | 
| + | 
| + if (!host_) | 
| + return Response::ServerError("Could not connect to view"); | 
| + | 
| + host_->Focus(); | 
| + host_->ForwardKeyboardEvent(event); | 
| + return Response::OK(); | 
| +} | 
| + | 
| Response InputHandler::DispatchMouseEvent( | 
| const std::string& type, | 
| int x, |