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->AsRootWindowHostDelegate()->OnHostKeyEvent(&event); | 32 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&event); |
33 } | 33 } |
34 | 34 |
35 base::LazyInstance<base::Time> g_keyboard_load_time_start = | 35 base::LazyInstance<base::Time> g_keyboard_load_time_start = |
36 LAZY_INSTANCE_INITIALIZER; | 36 LAZY_INSTANCE_INITIALIZER; |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 namespace keyboard { | 40 namespace keyboard { |
41 | 41 |
42 bool IsKeyboardEnabled() { | 42 bool IsKeyboardEnabled() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 codex = ui::VKEY_LEFT; | 85 codex = ui::VKEY_LEFT; |
86 | 86 |
87 if (swipe_direction & kCursorMoveUp) | 87 if (swipe_direction & kCursorMoveUp) |
88 codey = ui::VKEY_UP; | 88 codey = ui::VKEY_UP; |
89 else if (swipe_direction & kCursorMoveDown) | 89 else if (swipe_direction & kCursorMoveDown) |
90 codey = ui::VKEY_DOWN; | 90 codey = ui::VKEY_DOWN; |
91 | 91 |
92 // First deal with the x movement. | 92 // First deal with the x movement. |
93 if (codex != ui::VKEY_UNKNOWN) { | 93 if (codex != ui::VKEY_UNKNOWN) { |
94 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags, 0); | 94 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags, 0); |
95 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&press_event); | 95 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&press_event); |
96 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags, 0); | 96 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags, 0); |
97 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&release_event); | 97 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&release_event); |
98 } | 98 } |
99 | 99 |
100 // Then deal with the y movement. | 100 // Then deal with the y movement. |
101 if (codey != ui::VKEY_UNKNOWN) { | 101 if (codey != ui::VKEY_UNKNOWN) { |
102 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags, 0); | 102 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags, 0); |
103 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&press_event); | 103 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&press_event); |
104 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags, 0); | 104 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags, 0); |
105 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&release_event); | 105 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&release_event); |
106 } | 106 } |
107 return true; | 107 return true; |
108 } | 108 } |
109 | 109 |
110 bool SendKeyEvent(const std::string type, | 110 bool SendKeyEvent(const std::string type, |
111 int key_value, | 111 int key_value, |
112 int key_code, | 112 int key_code, |
113 std::string key_name, | 113 std::string key_name, |
114 int modifiers, | 114 int modifiers, |
115 aura::WindowEventDispatcher* dispatcher) { | 115 aura::WindowEventDispatcher* dispatcher) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 UMA_HISTOGRAM_CUSTOM_COUNTS( | 148 UMA_HISTOGRAM_CUSTOM_COUNTS( |
149 "VirtualKeyboard.KeystrokesBetweenBackspaces", | 149 "VirtualKeyboard.KeystrokesBetweenBackspaces", |
150 keys_seen, 1, 1000, 50); | 150 keys_seen, 1, 1000, 50); |
151 keys_seen = 0; | 151 keys_seen = 0; |
152 } else { | 152 } else { |
153 ++keys_seen; | 153 ++keys_seen; |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 ui::KeyEvent event(event_type, code, key_name, modifiers, false); | 157 ui::KeyEvent event(event_type, code, key_name, modifiers, false); |
158 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&event); | 158 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&event); |
159 } | 159 } |
160 return true; | 160 return true; |
161 } | 161 } |
162 | 162 |
163 const void MarkKeyboardLoadStarted() { | 163 const void MarkKeyboardLoadStarted() { |
164 if (!g_keyboard_load_time_start.Get().ToInternalValue()) | 164 if (!g_keyboard_load_time_start.Get().ToInternalValue()) |
165 g_keyboard_load_time_start.Get() = base::Time::Now(); | 165 g_keyboard_load_time_start.Get() = base::Time::Now(); |
166 } | 166 } |
167 | 167 |
168 const void MarkKeyboardLoadFinished() { | 168 const void MarkKeyboardLoadFinished() { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 251 } |
252 | 252 |
253 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 253 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
254 UMA_HISTOGRAM_ENUMERATION( | 254 UMA_HISTOGRAM_ENUMERATION( |
255 "VirtualKeyboard.KeyboardControlEvent", | 255 "VirtualKeyboard.KeyboardControlEvent", |
256 event, | 256 event, |
257 keyboard::KEYBOARD_CONTROL_MAX); | 257 keyboard::KEYBOARD_CONTROL_MAX); |
258 } | 258 } |
259 | 259 |
260 } // namespace keyboard | 260 } // namespace keyboard |
OLD | NEW |