| 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 "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "cc/output/compositor_frame_metadata.h" | 9 #include "cc/output/compositor_frame_metadata.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 base::StringPrintf("Unexpected event type '%s'", type.c_str())); | 170 base::StringPrintf("Unexpected event type '%s'", type.c_str())); |
| 171 } | 171 } |
| 172 | 172 |
| 173 SetEventModifiers(&event, modifiers); | 173 SetEventModifiers(&event, modifiers); |
| 174 SetEventTimestamp(&event, timestamp); | 174 SetEventTimestamp(&event, timestamp); |
| 175 if (!SetKeyboardEventText(event.text, text)) | 175 if (!SetKeyboardEventText(event.text, text)) |
| 176 return Response::InvalidParams("Invalid 'text' parameter"); | 176 return Response::InvalidParams("Invalid 'text' parameter"); |
| 177 if (!SetKeyboardEventText(event.unmodifiedText, unmodified_text)) | 177 if (!SetKeyboardEventText(event.unmodifiedText, unmodified_text)) |
| 178 return Response::InvalidParams("Invalid 'unmodifiedText' parameter"); | 178 return Response::InvalidParams("Invalid 'unmodifiedText' parameter"); |
| 179 | 179 |
| 180 if (windows_virtual_key_code) |
| 181 event.windowsKeyCode = *windows_virtual_key_code; |
| 182 if (native_virtual_key_code) |
| 183 event.nativeKeyCode = *native_virtual_key_code; |
| 184 if (auto_repeat && *auto_repeat) |
| 185 event.modifiers |= blink::WebInputEvent::IsAutoRepeat; |
| 186 if (is_keypad && *is_keypad) |
| 187 event.modifiers |= blink::WebInputEvent::IsKeyPad; |
| 188 if (is_system_key) |
| 189 event.isSystemKey = *is_system_key; |
| 190 |
| 180 if (key_identifier) { | 191 if (key_identifier) { |
| 181 if (key_identifier->size() > | 192 if (key_identifier->size() > |
| 182 blink::WebKeyboardEvent::keyIdentifierLengthCap) { | 193 blink::WebKeyboardEvent::keyIdentifierLengthCap) { |
| 183 return Response::InvalidParams("Invalid 'keyIdentifier' parameter"); | 194 return Response::InvalidParams("Invalid 'keyIdentifier' parameter"); |
| 184 } | 195 } |
| 185 for (size_t i = 0; i < key_identifier->size(); ++i) | 196 for (size_t i = 0; i < key_identifier->size(); ++i) |
| 186 event.keyIdentifier[i] = (*key_identifier)[i]; | 197 event.keyIdentifier[i] = (*key_identifier)[i]; |
| 198 } else if (event.type != blink::WebInputEvent::Char) { |
| 199 event.setKeyIdentifierFromWindowsKeyCode(); |
| 187 } | 200 } |
| 188 | 201 |
| 189 if (code) { | 202 if (code) { |
| 190 event.domCode = static_cast<int>( | 203 event.domCode = static_cast<int>( |
| 191 ui::KeycodeConverter::CodeStringToDomCode(code->c_str())); | 204 ui::KeycodeConverter::CodeStringToDomCode(code->c_str())); |
| 192 } | 205 } |
| 193 | 206 |
| 194 if (windows_virtual_key_code) | |
| 195 event.windowsKeyCode = *windows_virtual_key_code; | |
| 196 if (native_virtual_key_code) | |
| 197 event.nativeKeyCode = *native_virtual_key_code; | |
| 198 if (auto_repeat && *auto_repeat) | |
| 199 event.modifiers |= blink::WebInputEvent::IsAutoRepeat; | |
| 200 if (is_keypad && *is_keypad) | |
| 201 event.modifiers |= blink::WebInputEvent::IsKeyPad; | |
| 202 if (is_system_key) | |
| 203 event.isSystemKey = *is_system_key; | |
| 204 | |
| 205 if (!host_) | 207 if (!host_) |
| 206 return Response::ServerError("Could not connect to view"); | 208 return Response::ServerError("Could not connect to view"); |
| 207 | 209 |
| 208 host_->Focus(); | 210 host_->Focus(); |
| 209 host_->ForwardKeyboardEvent(event); | 211 host_->ForwardKeyboardEvent(event); |
| 210 return Response::OK(); | 212 return Response::OK(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 Response InputHandler::DispatchMouseEvent( | 215 Response InputHandler::DispatchMouseEvent( |
| 214 const std::string& type, | 216 const std::string& type, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } else { | 457 } else { |
| 456 client_->SendError(command_id, | 458 client_->SendError(command_id, |
| 457 Response::InternalError(base::StringPrintf( | 459 Response::InternalError(base::StringPrintf( |
| 458 "Synthetic tap failed, result was %d", result))); | 460 "Synthetic tap failed, result was %d", result))); |
| 459 } | 461 } |
| 460 } | 462 } |
| 461 | 463 |
| 462 } // namespace input | 464 } // namespace input |
| 463 } // namespace devtools | 465 } // namespace devtools |
| 464 } // namespace content | 466 } // namespace content |
| OLD | NEW |