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

Unified Diff: ui/events/keycodes/dom4/keycode_converter.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
« no previous file with comments | « ui/events/keycodes/dom4/keycode_converter.h ('k') | ui/events/keycodes/dom4/keycode_converter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/keycodes/dom4/keycode_converter.cc
diff --git a/ui/events/keycodes/dom4/keycode_converter.cc b/ui/events/keycodes/dom4/keycode_converter.cc
index 53f9a129783f01f829e7748f5ec0162eabeb060d..b7958dd0db19e93ed6785f721b16538445170cf6 100644
--- a/ui/events/keycodes/dom4/keycode_converter.cc
+++ b/ui/events/keycodes/dom4/keycode_converter.cc
@@ -23,29 +23,27 @@ const size_t kKeycodeMapEntries = arraysize(usb_keycode_map);
} // namespace
-KeycodeConverter::KeycodeConverter() {
-}
-
-KeycodeConverter* KeycodeConverter::GetInstance() {
- return Singleton<KeycodeConverter>::get();
-}
-
+// static
size_t KeycodeConverter::NumKeycodeMapEntriesForTest() {
return kKeycodeMapEntries;
}
+// static
const KeycodeMapEntry* KeycodeConverter::GetKeycodeMapForTest() {
return &usb_keycode_map[0];
}
+// static
uint16_t KeycodeConverter::InvalidNativeKeycode() {
return usb_keycode_map[0].native_keycode;
}
+// static
const char* KeycodeConverter::InvalidKeyboardEventCode() {
return "Unidentified";
}
+// static
const char* KeycodeConverter::NativeKeycodeToCode(uint16_t native_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].native_keycode == native_keycode) {
@@ -57,6 +55,7 @@ const char* KeycodeConverter::NativeKeycodeToCode(uint16_t native_keycode) {
return InvalidKeyboardEventCode();
}
+// static
uint16_t KeycodeConverter::CodeToNativeKeycode(const char* code) {
if (!code ||
strcmp(code, InvalidKeyboardEventCode()) == 0) {
@@ -76,10 +75,12 @@ uint16_t KeycodeConverter::CodeToNativeKeycode(const char* code) {
// Note that USB keycodes are not part of any web standard.
// Please don't use USB keycodes in new code.
+// static
uint16_t KeycodeConverter::InvalidUsbKeycode() {
return usb_keycode_map[0].usb_keycode;
}
+// static
uint16_t KeycodeConverter::UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
// Deal with some special-cases that don't fit the 1:1 mapping.
if (usb_keycode == 0x070032) // non-US hash.
@@ -96,6 +97,7 @@ uint16_t KeycodeConverter::UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
return InvalidNativeKeycode();
}
+// static
uint32_t KeycodeConverter::NativeKeycodeToUsbKeycode(uint16_t native_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].native_keycode == native_keycode)
@@ -104,6 +106,7 @@ uint32_t KeycodeConverter::NativeKeycodeToUsbKeycode(uint16_t native_keycode) {
return InvalidUsbKeycode();
}
+// static
const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].usb_keycode == usb_keycode)
@@ -112,6 +115,7 @@ const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) {
return InvalidKeyboardEventCode();
}
+// static
uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) {
if (!code ||
strcmp(code, InvalidKeyboardEventCode()) == 0) {
« no previous file with comments | « ui/events/keycodes/dom4/keycode_converter.h ('k') | ui/events/keycodes/dom4/keycode_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698