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

Unified Diff: ui/events/keycodes/platform_key_map_win.cc

Issue 1716913002: Add fail check for GetKeyboardState() in Windows KeyMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/keycodes/platform_key_map_win.cc
diff --git a/ui/events/keycodes/platform_key_map_win.cc b/ui/events/keycodes/platform_key_map_win.cc
index 52a44d55838d9c301c8d8caa13ad91f7e55fed1c..6a95fd7b2f3cdb6a2f3a89047bec7690ba372ec2 100644
--- a/ui/events/keycodes/platform_key_map_win.cc
+++ b/ui/events/keycodes/platform_key_map_win.cc
@@ -163,6 +163,10 @@ void PlatformKeyMap::UpdateLayout(HKL layout) {
if (layout == keyboard_layout_)
return;
+ BYTE keyboard_state_to_restore[256];
+ if (!::GetKeyboardState(keyboard_state_to_restore))
+ return;
+
// TODO(chongz): Optimize layout switching (see crbug.com/587147).
keyboard_layout_ = layout;
code_to_key_.clear();
@@ -170,9 +174,6 @@ void PlatformKeyMap::UpdateLayout(HKL layout) {
// US: 428, French: 554, Persian: 434, Vietnamese: 1388
code_to_key_.reserve(500);
- BYTE keyboard_state_to_restore[256];
- ::GetKeyboardState(keyboard_state_to_restore);
-
for (int eindex = 0; eindex <= kModifierFlagsCombinations; ++eindex) {
BYTE keyboard_state[256];
memset(keyboard_state, 0, sizeof(keyboard_state));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698