Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: ui/keyboard/keyboard_util.cc

Issue 404203003: Distinguish between keystroke and character events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IsCharFromNative() for Mac build Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/x/events_x_unittest.cc ('k') | ui/platform_window/win/win_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 #include "ui/keyboard/keyboard_switches.h" 21 #include "ui/keyboard/keyboard_switches.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 namespace { 24 namespace {
25 25
26 const char kKeyDown[] ="keydown"; 26 const char kKeyDown[] ="keydown";
27 const char kKeyUp[] = "keyup"; 27 const char kKeyUp[] = "keyup";
28 28
29 void SendProcessKeyEvent(ui::EventType type, 29 void SendProcessKeyEvent(ui::EventType type,
30 aura::WindowTreeHost* host) { 30 aura::WindowTreeHost* host) {
31 ui::KeyEvent event(type, ui::VKEY_PROCESSKEY, ui::EF_NONE, false); 31 ui::KeyEvent event(type, ui::VKEY_PROCESSKEY, ui::EF_NONE);
32 event.SetTranslated(true); 32 event.SetTranslated(true);
33 ui::EventDispatchDetails details = 33 ui::EventDispatchDetails details =
34 host->event_processor()->OnEventFromSource(&event); 34 host->event_processor()->OnEventFromSource(&event);
35 CHECK(!details.dispatcher_destroyed); 35 CHECK(!details.dispatcher_destroyed);
36 } 36 }
37 37
38 base::LazyInstance<base::Time> g_keyboard_load_time_start = 38 base::LazyInstance<base::Time> g_keyboard_load_time_start =
39 LAZY_INSTANCE_INITIALIZER; 39 LAZY_INSTANCE_INITIALIZER;
40 40
41 bool g_accessibility_keyboard_enabled = false; 41 bool g_accessibility_keyboard_enabled = false;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 else if (swipe_direction & kCursorMoveLeft) 201 else if (swipe_direction & kCursorMoveLeft)
202 codex = ui::VKEY_LEFT; 202 codex = ui::VKEY_LEFT;
203 203
204 if (swipe_direction & kCursorMoveUp) 204 if (swipe_direction & kCursorMoveUp)
205 codey = ui::VKEY_UP; 205 codey = ui::VKEY_UP;
206 else if (swipe_direction & kCursorMoveDown) 206 else if (swipe_direction & kCursorMoveDown)
207 codey = ui::VKEY_DOWN; 207 codey = ui::VKEY_DOWN;
208 208
209 // First deal with the x movement. 209 // First deal with the x movement.
210 if (codex != ui::VKEY_UNKNOWN) { 210 if (codex != ui::VKEY_UNKNOWN) {
211 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags, 0); 211 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags);
212 ui::EventDispatchDetails details = 212 ui::EventDispatchDetails details =
213 host->event_processor()->OnEventFromSource(&press_event); 213 host->event_processor()->OnEventFromSource(&press_event);
214 CHECK(!details.dispatcher_destroyed); 214 CHECK(!details.dispatcher_destroyed);
215 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags, 0); 215 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags);
216 details = host->event_processor()->OnEventFromSource(&release_event); 216 details = host->event_processor()->OnEventFromSource(&release_event);
217 CHECK(!details.dispatcher_destroyed); 217 CHECK(!details.dispatcher_destroyed);
218 } 218 }
219 219
220 // Then deal with the y movement. 220 // Then deal with the y movement.
221 if (codey != ui::VKEY_UNKNOWN) { 221 if (codey != ui::VKEY_UNKNOWN) {
222 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags, 0); 222 ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags);
223 ui::EventDispatchDetails details = 223 ui::EventDispatchDetails details =
224 host->event_processor()->OnEventFromSource(&press_event); 224 host->event_processor()->OnEventFromSource(&press_event);
225 CHECK(!details.dispatcher_destroyed); 225 CHECK(!details.dispatcher_destroyed);
226 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags, 0); 226 ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags);
227 details = host->event_processor()->OnEventFromSource(&release_event); 227 details = host->event_processor()->OnEventFromSource(&release_event);
228 CHECK(!details.dispatcher_destroyed); 228 CHECK(!details.dispatcher_destroyed);
229 } 229 }
230 return true; 230 return true;
231 } 231 }
232 232
233 bool SendKeyEvent(const std::string type, 233 bool SendKeyEvent(const std::string type,
234 int key_value, 234 int key_value,
235 int key_code, 235 int key_code,
236 std::string key_name, 236 std::string key_name,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // metric will be used to determine the error rate for the keyboard. 270 // metric will be used to determine the error rate for the keyboard.
271 UMA_HISTOGRAM_CUSTOM_COUNTS( 271 UMA_HISTOGRAM_CUSTOM_COUNTS(
272 "VirtualKeyboard.KeystrokesBetweenBackspaces", 272 "VirtualKeyboard.KeystrokesBetweenBackspaces",
273 keys_seen, 1, 1000, 50); 273 keys_seen, 1, 1000, 50);
274 keys_seen = 0; 274 keys_seen = 0;
275 } else { 275 } else {
276 ++keys_seen; 276 ++keys_seen;
277 } 277 }
278 } 278 }
279 279
280 ui::KeyEvent event(event_type, code, key_name, modifiers, false); 280 ui::KeyEvent event(event_type, code, key_name, modifiers);
281 ui::EventDispatchDetails details = 281 ui::EventDispatchDetails details =
282 host->event_processor()->OnEventFromSource(&event); 282 host->event_processor()->OnEventFromSource(&event);
283 CHECK(!details.dispatcher_destroyed); 283 CHECK(!details.dispatcher_destroyed);
284 } 284 }
285 return true; 285 return true;
286 } 286 }
287 287
288 const void MarkKeyboardLoadStarted() { 288 const void MarkKeyboardLoadStarted() {
289 if (!g_keyboard_load_time_start.Get().ToInternalValue()) 289 if (!g_keyboard_load_time_start.Get().ToInternalValue())
290 g_keyboard_load_time_start.Get() = base::Time::Now(); 290 g_keyboard_load_time_start.Get() = base::Time::Now();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 void LogKeyboardControlEvent(KeyboardControlEvent event) { 377 void LogKeyboardControlEvent(KeyboardControlEvent event) {
378 UMA_HISTOGRAM_ENUMERATION( 378 UMA_HISTOGRAM_ENUMERATION(
379 "VirtualKeyboard.KeyboardControlEvent", 379 "VirtualKeyboard.KeyboardControlEvent",
380 event, 380 event,
381 keyboard::KEYBOARD_CONTROL_MAX); 381 keyboard::KEYBOARD_CONTROL_MAX);
382 } 382 }
383 383
384 } // namespace keyboard 384 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/events/x/events_x_unittest.cc ('k') | ui/platform_window/win/win_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698