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

Unified Diff: content/public/test/browser_test_utils.cc

Issue 494813002: events: keycodes: Remove the stateless singleton instance of KeycodeConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index bbcaf57b67d29ea9e4963a6f8f0a95e2254c8459..a19331b5cd02916d45148f003b4375307ba4e8cd 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -322,8 +322,7 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
bool shift,
bool alt,
bool command) {
- ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
- int native_key_code = key_converter->CodeToNativeKeycode(code);
+ int native_key_code = ui::KeycodeConverter::CodeToNativeKeycode(code);
int modifiers = 0;
@@ -331,42 +330,38 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
// For our simulation we can use either the left keys or the right keys.
if (control) {
modifiers |= blink::WebInputEvent::ControlKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_CONTROL,
- key_converter->CodeToNativeKeycode("ControlLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::RawKeyDown,
+ ui::VKEY_CONTROL,
+ ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"),
+ modifiers);
}
if (shift) {
modifiers |= blink::WebInputEvent::ShiftKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_SHIFT,
- key_converter->CodeToNativeKeycode("ShiftLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::RawKeyDown,
+ ui::VKEY_SHIFT,
+ ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"),
+ modifiers);
}
if (alt) {
modifiers |= blink::WebInputEvent::AltKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_MENU,
- key_converter->CodeToNativeKeycode("AltLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::RawKeyDown,
+ ui::VKEY_MENU,
+ ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"),
+ modifiers);
}
if (command) {
modifiers |= blink::WebInputEvent::MetaKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_COMMAND,
- key_converter->CodeToNativeKeycode("OSLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::RawKeyDown,
+ ui::VKEY_COMMAND,
+ ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"),
+ modifiers);
}
InjectRawKeyEvent(
@@ -393,42 +388,38 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
// The order of these key releases shouldn't matter for our simulation.
if (control) {
modifiers &= ~blink::WebInputEvent::ControlKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_CONTROL,
- key_converter->CodeToNativeKeycode("ControlLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::KeyUp,
+ ui::VKEY_CONTROL,
+ ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"),
+ modifiers);
}
if (shift) {
modifiers &= ~blink::WebInputEvent::ShiftKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_SHIFT,
- key_converter->CodeToNativeKeycode("ShiftLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::KeyUp,
+ ui::VKEY_SHIFT,
+ ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"),
+ modifiers);
}
if (alt) {
modifiers &= ~blink::WebInputEvent::AltKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_MENU,
- key_converter->CodeToNativeKeycode("AltLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::KeyUp,
+ ui::VKEY_MENU,
+ ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"),
+ modifiers);
}
if (command) {
modifiers &= ~blink::WebInputEvent::MetaKey;
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_COMMAND,
- key_converter->CodeToNativeKeycode("OSLeft"),
- modifiers);
+ InjectRawKeyEvent(web_contents,
+ blink::WebInputEvent::KeyUp,
+ ui::VKEY_COMMAND,
+ ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"),
+ modifiers);
}
ASSERT_EQ(modifiers, 0);
« no previous file with comments | « chrome/browser/chromeos/input_method/input_method_engine.cc ('k') | content/renderer/pepper/usb_key_code_conversion_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698