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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 | 144 |
145 Response InputHandler::DispatchKeyEvent( | 145 Response InputHandler::DispatchKeyEvent( |
146 const std::string& type, | 146 const std::string& type, |
147 const int* modifiers, | 147 const int* modifiers, |
148 const double* timestamp, | 148 const double* timestamp, |
149 const std::string* text, | 149 const std::string* text, |
150 const std::string* unmodified_text, | 150 const std::string* unmodified_text, |
151 const std::string* key_identifier, | 151 const std::string* key_identifier, |
152 const std::string* code, | 152 const std::string* code, |
| 153 const std::string* key, |
153 const int* windows_virtual_key_code, | 154 const int* windows_virtual_key_code, |
154 const int* native_virtual_key_code, | 155 const int* native_virtual_key_code, |
155 const bool* auto_repeat, | 156 const bool* auto_repeat, |
156 const bool* is_keypad, | 157 const bool* is_keypad, |
157 const bool* is_system_key) { | 158 const bool* is_system_key) { |
158 NativeWebKeyboardEvent event; | 159 NativeWebKeyboardEvent event; |
159 | 160 |
160 if (type == dispatch_key_event::kTypeKeyDown) { | 161 if (type == dispatch_key_event::kTypeKeyDown) { |
161 event.type = blink::WebInputEvent::KeyDown; | 162 event.type = blink::WebInputEvent::KeyDown; |
162 } else if (type == dispatch_key_event::kTypeKeyUp) { | 163 } else if (type == dispatch_key_event::kTypeKeyUp) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 event.keyIdentifier[i] = (*key_identifier)[i]; | 198 event.keyIdentifier[i] = (*key_identifier)[i]; |
198 } else if (event.type != blink::WebInputEvent::Char) { | 199 } else if (event.type != blink::WebInputEvent::Char) { |
199 event.setKeyIdentifierFromWindowsKeyCode(); | 200 event.setKeyIdentifierFromWindowsKeyCode(); |
200 } | 201 } |
201 | 202 |
202 if (code) { | 203 if (code) { |
203 event.domCode = static_cast<int>( | 204 event.domCode = static_cast<int>( |
204 ui::KeycodeConverter::CodeStringToDomCode(code->c_str())); | 205 ui::KeycodeConverter::CodeStringToDomCode(code->c_str())); |
205 } | 206 } |
206 | 207 |
| 208 if (key) { |
| 209 event.domKey = static_cast<int>( |
| 210 ui::KeycodeConverter::KeyStringToDomKey(key->c_str())); |
| 211 } |
| 212 |
207 if (!host_) | 213 if (!host_) |
208 return Response::ServerError("Could not connect to view"); | 214 return Response::ServerError("Could not connect to view"); |
209 | 215 |
210 host_->Focus(); | 216 host_->Focus(); |
211 host_->ForwardKeyboardEvent(event); | 217 host_->ForwardKeyboardEvent(event); |
212 return Response::OK(); | 218 return Response::OK(); |
213 } | 219 } |
214 | 220 |
| 221 Response InputHandler::DispatchKeyEvent( |
| 222 const std::string& type, |
| 223 const int* modifiers, |
| 224 const double* timestamp, |
| 225 const std::string* text, |
| 226 const std::string* unmodified_text, |
| 227 const std::string* key_identifier, |
| 228 const std::string* code, |
| 229 const int* windows_virtual_key_code, |
| 230 const int* native_virtual_key_code, |
| 231 const bool* auto_repeat, |
| 232 const bool* is_keypad, |
| 233 const bool* is_system_key) { |
| 234 std::string dom_key; |
| 235 return InputHandler::DispatchKeyEvent(type, modifiers, timestamp, text, |
| 236 unmodified_text, key_identifier, code, &dom_key, |
| 237 windows_virtual_key_code, native_virtual_key_code, auto_repeat, |
| 238 is_keypad, is_system_key); |
| 239 } |
| 240 |
215 Response InputHandler::DispatchMouseEvent( | 241 Response InputHandler::DispatchMouseEvent( |
216 const std::string& type, | 242 const std::string& type, |
217 int x, | 243 int x, |
218 int y, | 244 int y, |
219 const int* modifiers, | 245 const int* modifiers, |
220 const double* timestamp, | 246 const double* timestamp, |
221 const std::string* button, | 247 const std::string* button, |
222 const int* click_count) { | 248 const int* click_count) { |
223 blink::WebMouseEvent event; | 249 blink::WebMouseEvent event; |
224 | 250 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } else { | 483 } else { |
458 client_->SendError(command_id, | 484 client_->SendError(command_id, |
459 Response::InternalError(base::StringPrintf( | 485 Response::InternalError(base::StringPrintf( |
460 "Synthetic tap failed, result was %d", result))); | 486 "Synthetic tap failed, result was %d", result))); |
461 } | 487 } |
462 } | 488 } |
463 | 489 |
464 } // namespace input | 490 } // namespace input |
465 } // namespace devtools | 491 } // namespace devtools |
466 } // namespace content | 492 } // namespace content |
OLD | NEW |