| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_util.h" | 5 #include "ui/keyboard/keyboard_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kKeyDown[] ="keydown"; | 24 const char kKeyDown[] ="keydown"; |
| 25 const char kKeyUp[] = "keyup"; | 25 const char kKeyUp[] = "keyup"; |
| 26 | 26 |
| 27 void SendProcessKeyEvent(ui::EventType type, | 27 void SendProcessKeyEvent(ui::EventType type, |
| 28 aura::WindowEventDispatcher* dispatcher) { | 28 aura::WindowEventDispatcher* dispatcher) { |
| 29 ui::TranslatedKeyEvent event(type == ui::ET_KEY_PRESSED, | 29 ui::TranslatedKeyEvent event(type == ui::ET_KEY_PRESSED, |
| 30 ui::VKEY_PROCESSKEY, | 30 ui::VKEY_PROCESSKEY, |
| 31 ui::EF_NONE); | 31 ui::EF_NONE); |
| 32 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&event); | 32 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&event); |
| 33 CHECK(!details.dispatcher_destroyed); |
| 33 } | 34 } |
| 34 | 35 |
| 35 base::LazyInstance<base::Time> g_keyboard_load_time_start = | 36 base::LazyInstance<base::Time> g_keyboard_load_time_start = |
| 36 LAZY_INSTANCE_INITIALIZER; | 37 LAZY_INSTANCE_INITIALIZER; |
| 37 | 38 |
| 38 bool g_accessibility_keyboard_enabled = false; | 39 bool g_accessibility_keyboard_enabled = false; |
| 39 | 40 |
| 40 } // namespace | 41 } // namespace |
| 41 | 42 |
| 42 namespace keyboard { | 43 namespace keyboard { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 codex = ui::VKEY_LEFT; | 93 codex = ui::VKEY_LEFT; |
| 93 | 94 |
| 94 if (swipe_direction & kCursorMoveUp) | 95 if (swipe_direction & kCursorMoveUp) |
| 95 codey = ui::VKEY_UP; | 96 codey = ui::VKEY_UP; |
| 96 else if (swipe_direction & kCursorMoveDown) | 97 else if (swipe_direction & kCursorMoveDown) |
| 97 codey = ui::VKEY_DOWN; | 98 codey = ui::VKEY_DOWN; |
| 98 | 99 |
| 99 // First deal with the x movement. | 100 // First deal with the x movement. |
| 100 if (codex != ui::VKEY_UNKNOWN) { | 101 if (codex != ui::VKEY_UNKNOWN) { |
| 101 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags, 0); | 102 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags, 0); |
| 102 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&press_event); | 103 ui::EventDispatchDetails details = |
| 104 dispatcher->OnEventFromSource(&press_event); |
| 105 CHECK(!details.dispatcher_destroyed); |
| 103 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags, 0); | 106 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags, 0); |
| 104 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&release_event); | 107 details = dispatcher->OnEventFromSource(&release_event); |
| 108 CHECK(!details.dispatcher_destroyed); |
| 105 } | 109 } |
| 106 | 110 |
| 107 // Then deal with the y movement. | 111 // Then deal with the y movement. |
| 108 if (codey != ui::VKEY_UNKNOWN) { | 112 if (codey != ui::VKEY_UNKNOWN) { |
| 109 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags, 0); | 113 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags, 0); |
| 110 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&press_event); | 114 ui::EventDispatchDetails details = |
| 115 dispatcher->OnEventFromSource(&press_event); |
| 116 CHECK(!details.dispatcher_destroyed); |
| 111 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags, 0); | 117 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags, 0); |
| 112 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&release_event); | 118 details = dispatcher->OnEventFromSource(&release_event); |
| 119 CHECK(!details.dispatcher_destroyed); |
| 113 } | 120 } |
| 114 return true; | 121 return true; |
| 115 } | 122 } |
| 116 | 123 |
| 117 bool SendKeyEvent(const std::string type, | 124 bool SendKeyEvent(const std::string type, |
| 118 int key_value, | 125 int key_value, |
| 119 int key_code, | 126 int key_code, |
| 120 std::string key_name, | 127 std::string key_name, |
| 121 int modifiers, | 128 int modifiers, |
| 122 aura::WindowEventDispatcher* dispatcher) { | 129 aura::WindowEventDispatcher* dispatcher) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 UMA_HISTOGRAM_CUSTOM_COUNTS( | 162 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 156 "VirtualKeyboard.KeystrokesBetweenBackspaces", | 163 "VirtualKeyboard.KeystrokesBetweenBackspaces", |
| 157 keys_seen, 1, 1000, 50); | 164 keys_seen, 1, 1000, 50); |
| 158 keys_seen = 0; | 165 keys_seen = 0; |
| 159 } else { | 166 } else { |
| 160 ++keys_seen; | 167 ++keys_seen; |
| 161 } | 168 } |
| 162 } | 169 } |
| 163 | 170 |
| 164 ui::KeyEvent event(event_type, code, key_name, modifiers, false); | 171 ui::KeyEvent event(event_type, code, key_name, modifiers, false); |
| 165 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&event); | 172 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&event); |
| 173 CHECK(!details.dispatcher_destroyed); |
| 166 } | 174 } |
| 167 return true; | 175 return true; |
| 168 } | 176 } |
| 169 | 177 |
| 170 const void MarkKeyboardLoadStarted() { | 178 const void MarkKeyboardLoadStarted() { |
| 171 if (!g_keyboard_load_time_start.Get().ToInternalValue()) | 179 if (!g_keyboard_load_time_start.Get().ToInternalValue()) |
| 172 g_keyboard_load_time_start.Get() = base::Time::Now(); | 180 g_keyboard_load_time_start.Get() = base::Time::Now(); |
| 173 } | 181 } |
| 174 | 182 |
| 175 const void MarkKeyboardLoadFinished() { | 183 const void MarkKeyboardLoadFinished() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 271 } |
| 264 | 272 |
| 265 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 273 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
| 266 UMA_HISTOGRAM_ENUMERATION( | 274 UMA_HISTOGRAM_ENUMERATION( |
| 267 "VirtualKeyboard.KeyboardControlEvent", | 275 "VirtualKeyboard.KeyboardControlEvent", |
| 268 event, | 276 event, |
| 269 keyboard::KEYBOARD_CONTROL_MAX); | 277 keyboard::KEYBOARD_CONTROL_MAX); |
| 270 } | 278 } |
| 271 | 279 |
| 272 } // namespace keyboard | 280 } // namespace keyboard |
| OLD | NEW |