1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/renderer_host/input/web_input_event_util.h"
7 #include "base/strings/string_util.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h"
12 const char* GetKeyIdentifier(ui::KeyboardCode key_code
) {
16 case ui::VKEY_CONTROL
:
20 case ui::VKEY_CAPITAL
:
33 case ui::VKEY_EXECUTE
:
97 case ui::VKEY_SNAPSHOT
:
101 case ui::VKEY_SCROLL
:
103 case ui::VKEY_SELECT
:
107 case ui::VKEY_DELETE
:
108 return "U+007F"; // Standard says that DEL becomes U+007F.
109 case ui::VKEY_MEDIA_NEXT_TRACK
:
110 return "MediaNextTrack";
111 case ui::VKEY_MEDIA_PREV_TRACK
:
112 return "MediaPreviousTrack";
113 case ui::VKEY_MEDIA_STOP
:
115 case ui::VKEY_MEDIA_PLAY_PAUSE
:
116 return "MediaPlayPause";
117 case ui::VKEY_VOLUME_MUTE
:
119 case ui::VKEY_VOLUME_DOWN
:
121 case ui::VKEY_VOLUME_UP
:
132 void UpdateWindowsKeyCodeAndKeyIdentifier(blink::WebKeyboardEvent
* event
,
133 ui::KeyboardCode windows_key_code
) {
134 event
->windowsKeyCode
= windows_key_code
;
136 const char* id
= GetKeyIdentifier(windows_key_code
);
138 base::strlcpy(event
->keyIdentifier
, id
, sizeof(event
->keyIdentifier
) - 1);
140 base::snprintf(event
->keyIdentifier
, sizeof(event
->keyIdentifier
), "U+%04X",
141 base::ToUpperASCII(static_cast<int>(windows_key_code
)));
145 } // namespace content