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

Side by Side Diff: chrome/test/chromedriver/keycode_text_conversion_win.cc

Issue 858353002: [chromedriver] Fixed window SendKeys (single quote missing) problem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove one debug print statement Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/chromedriver/keycode_text_conversion.h" 5 #include "chrome/test/chromedriver/keycode_text_conversion.h"
6 6
7 #include <VersionHelpers.h>
7 #include <stdlib.h> 8 #include <stdlib.h>
8 #include <windows.h> 9 #include <windows.h>
9 10
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/test/chromedriver/chrome/ui_events.h" 12 #include "chrome/test/chromedriver/chrome/ui_events.h"
12 13
13 bool ConvertKeyCodeToText( 14 bool ConvertKeyCodeToText(
14 ui::KeyboardCode key_code, int modifiers, std::string* text, 15 ui::KeyboardCode key_code, int modifiers, std::string* text,
15 std::string* error_msg) { 16 std::string* error_msg) {
16 UINT scan_code = ::MapVirtualKeyW(key_code, MAPVK_VK_TO_VSC); 17 UINT scan_code = ::MapVirtualKeyW(key_code, MAPVK_VK_TO_VSC);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 modifiers |= kShiftKeyModifierMask; 51 modifiers |= kShiftKeyModifierMask;
51 if (win_modifiers & 0x02) 52 if (win_modifiers & 0x02)
52 modifiers |= kControlKeyModifierMask; 53 modifiers |= kControlKeyModifierMask;
53 if (win_modifiers & 0x04) 54 if (win_modifiers & 0x04)
54 modifiers |= kAltKeyModifierMask; 55 modifiers |= kAltKeyModifierMask;
55 // Ignore bit 0x08: It is for Hankaku key. 56 // Ignore bit 0x08: It is for Hankaku key.
56 *necessary_modifiers = modifiers; 57 *necessary_modifiers = modifiers;
57 } 58 }
58 return translated; 59 return translated;
59 } 60 }
61
62 bool SwitchToUSKeyboardLayout() {
63 bool switch_status = false;
64
65 // For LoadKeyboardLayout - Prior to Windows 8: If the specified input
66 // locale identifier is not already loaded, the function loads and
67 // activates the input locale identifier for the current thread.
68 // Beginning in Windows 8: If the specified input locale identifier is not
69 // already loaded, the function loads and activates the input
70 // locale identifier for the system.
71 // For Windows 8 - Use ActivateKeyboardLayout instead of LoadKeyboardLayout
72 if (IsWindows8OrGreater()) {
73 int size;
74 HKL * keyBoard_handles_list;
samuong 2015/01/23 19:36:58 Can we use a scoped_ptr here instead? If you do, y
andrewcheng1 2015/01/24 01:40:00 1. my initial approach do not have switch_status,
andrewcheng1 2015/02/19 00:56:59 Done.
75 TCHAR active_keyboard[KL_NAMELENGTH];
76
77 if ((size = ::GetKeyboardLayoutList(0, NULL)) > 0)
78 keyBoard_handles_list = new HKL[size];
79 else
80 return switch_status;
81
82 ::GetKeyboardLayoutList(size, keyBoard_handles_list);
83
84 for (int keyboard_index = 0; keyboard_index < size; keyboard_index++) {
85 ::ActivateKeyboardLayout(keyBoard_handles_list[keyboard_index],
86 KLF_SETFORPROCESS);
87 ::GetKeyboardLayoutName(active_keyboard);
88 // if active keyboard match US keyboard layout - 00000409
89 if (wcscmp(active_keyboard, L"00000409") == 0) {
90 switch_status = true;
91 break;
samuong 2015/01/23 19:36:58 What happens if none of the HKLs match the US keyb
andrewcheng1 2015/01/24 01:40:00 I verified this already two weeks ago - in lan
andrewcheng1 2015/01/24 01:40:00 Done.
92 }
93 }
94 delete [] keyBoard_handles_list;
95 } else {
96 HKL layout = ::LoadKeyboardLayout((LPCTSTR)"00000409", KLF_ACTIVATE);
samuong 2015/01/23 19:36:58 Can you define a for "00000409" (or use an existin
andrewcheng1 2015/01/24 01:40:00 Done. I can not find any pre-defined constant for
andrewcheng1 2015/02/19 00:56:59 Done.
andrewcheng1 2015/02/19 00:56:59 Done.
97 if (!layout)
98 switch_status = false;
99 else
100 switch_status = true;
101 }
102 return switch_status;
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698