OLD | NEW |
| (Empty) |
1 // Copyright 2016 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. | |
4 | |
5 #ifndef UI_EVENTS_TEST_KEYBOARD_LAYOUT_H_ | |
6 #define UI_EVENTS_TEST_KEYBOARD_LAYOUT_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "build/build_config.h" | |
10 | |
11 #if defined(OS_WIN) | |
12 #include <windows.h> | |
13 #elif defined(OS_MACOSX) && !defined(OS_IOS) | |
14 #include <Carbon/Carbon.h> | |
15 #include "base/mac/scoped_cftyperef.h" | |
16 #endif | |
17 | |
18 namespace ui { | |
19 | |
20 enum KeyboardLayout { | |
21 KEYBOARD_LAYOUT_ENGLISH_US, | |
22 KEYBOARD_LAYOUT_FRENCH, | |
23 KEYBOARD_LAYOUT_GERMAN, | |
24 KEYBOARD_LAYOUT_GREEK, | |
25 KEYBOARD_LAYOUT_JAPANESE, | |
26 KEYBOARD_LAYOUT_KOREAN, | |
27 KEYBOARD_LAYOUT_RUSSIAN, | |
28 }; | |
29 | |
30 #if defined(OS_WIN) | |
31 using PlatformKeyboardLayout = HKL; | |
32 #elif defined(OS_MACOSX) && !defined(OS_IOS) | |
33 using PlatformKeyboardLayout = base::ScopedCFTypeRef<TISInputSourceRef>; | |
34 #else | |
35 // Dummy type for unsupported platforms. | |
36 using PlatformKeyboardLayout = void*; | |
37 #endif | |
38 | |
39 PlatformKeyboardLayout GetPlatformKeyboardLayout(KeyboardLayout layout); | |
40 | |
41 // Changes the active keyboard layout for the scope of this object. | |
42 class ScopedKeyboardLayout { | |
43 public: | |
44 explicit ScopedKeyboardLayout(KeyboardLayout layout); | |
45 ~ScopedKeyboardLayout(); | |
46 | |
47 private: | |
48 static PlatformKeyboardLayout GetActiveLayout(); | |
49 static void ActivateLayout(PlatformKeyboardLayout layout); | |
50 | |
51 PlatformKeyboardLayout original_layout_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(ScopedKeyboardLayout); | |
54 }; | |
55 | |
56 } // namespace ui | |
57 | |
58 #endif // UI_EVENTS_TEST_KEYBOARD_LAYOUT_H_ | |
OLD | NEW |