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

Unified Diff: ui/events/keycodes/dom/keycode_converter.cc

Issue 2910873002: [System-Keyboard-Lock] Add KeycodeConverter::CodeStringToNativeKeycode() function (Closed)
Patch Set: Resolve review comments Created 3 years, 7 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/dom/keycode_converter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/keycodes/dom/keycode_converter.cc
diff --git a/ui/events/keycodes/dom/keycode_converter.cc b/ui/events/keycodes/dom/keycode_converter.cc
index 94792e57bbcbba03e5a944a714b2fe53e04af6e1..1d5408c6da361ac086646e5d93336a70973d160e 100644
--- a/ui/events/keycodes/dom/keycode_converter.cc
+++ b/ui/events/keycodes/dom/keycode_converter.cc
@@ -75,6 +75,9 @@ int KeycodeConverter::InvalidNativeKeycode() {
return usb_keycode_map[0].native_keycode;
}
+// TODO(zijiehe): Most of the following functions can be optimized by using
+// either multiple arrays or unordered_map.
+
// static
DomCode KeycodeConverter::NativeKeycodeToDomCode(int native_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
@@ -297,7 +300,7 @@ uint32_t KeycodeConverter::DomCodeToUsbKeycode(DomCode dom_code) {
}
// static
-uint32_t KeycodeConverter::CodeToUsbKeycode(const std::string& code) {
+uint32_t KeycodeConverter::CodeStringToUsbKeycode(const std::string& code) {
if (code.empty())
return InvalidUsbKeycode();
@@ -309,4 +312,9 @@ uint32_t KeycodeConverter::CodeToUsbKeycode(const std::string& code) {
return InvalidUsbKeycode();
}
+// static
+int KeycodeConverter::CodeStringToNativeKeycode(const std::string& code) {
+ return UsbKeycodeToNativeKeycode(CodeStringToUsbKeycode(code));
+}
+
} // namespace ui
« no previous file with comments | « ui/events/keycodes/dom/keycode_converter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698