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 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&press_event); | 95 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&release_event); | 97 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&press_event); | 103 dispatcher->AsRootWindowHostDelegate()->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->AsWindowTreeHostDelegate()->OnHostKeyEvent(&release_event); | 105 dispatcher->AsRootWindowHostDelegate()->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 int modifiers, | 113 int modifiers, |
114 aura::WindowEventDispatcher* dispatcher) { | 114 aura::WindowEventDispatcher* dispatcher) { |
115 ui::EventType event_type = ui::ET_UNKNOWN; | 115 ui::EventType event_type = ui::ET_UNKNOWN; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 UMA_HISTOGRAM_CUSTOM_COUNTS( | 147 UMA_HISTOGRAM_CUSTOM_COUNTS( |
148 "VirtualKeyboard.KeystrokesBetweenBackspaces", | 148 "VirtualKeyboard.KeystrokesBetweenBackspaces", |
149 keys_seen, 1, 1000, 50); | 149 keys_seen, 1, 1000, 50); |
150 keys_seen = 0; | 150 keys_seen = 0; |
151 } else { | 151 } else { |
152 ++keys_seen; | 152 ++keys_seen; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 ui::KeyEvent event(event_type, code, modifiers, false); | 156 ui::KeyEvent event(event_type, code, modifiers, false); |
157 dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent(&event); | 157 dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&event); |
158 } | 158 } |
159 return true; | 159 return true; |
160 } | 160 } |
161 | 161 |
162 const void MarkKeyboardLoadStarted() { | 162 const void MarkKeyboardLoadStarted() { |
163 if (!g_keyboard_load_time_start.Get().ToInternalValue()) | 163 if (!g_keyboard_load_time_start.Get().ToInternalValue()) |
164 g_keyboard_load_time_start.Get() = base::Time::Now(); | 164 g_keyboard_load_time_start.Get() = base::Time::Now(); |
165 } | 165 } |
166 | 166 |
167 const void MarkKeyboardLoadFinished() { | 167 const void MarkKeyboardLoadFinished() { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 250 } |
251 | 251 |
252 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 252 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
253 UMA_HISTOGRAM_ENUMERATION( | 253 UMA_HISTOGRAM_ENUMERATION( |
254 "VirtualKeyboard.KeyboardControlEvent", | 254 "VirtualKeyboard.KeyboardControlEvent", |
255 event, | 255 event, |
256 keyboard::KEYBOARD_CONTROL_MAX); | 256 keyboard::KEYBOARD_CONTROL_MAX); |
257 } | 257 } |
258 | 258 |
259 } // namespace keyboard | 259 } // namespace keyboard |
OLD | NEW |