OLD | NEW |
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 #ifndef UI_KEYBOARD_KEYBOARD_UTIL_H_ | 5 #ifndef UI_KEYBOARD_KEYBOARD_UTIL_H_ |
6 #define UI_KEYBOARD_KEYBOARD_UTIL_H_ | 6 #define UI_KEYBOARD_KEYBOARD_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 // TODO(beng): replace with forward decl once RootWindow is renamed. |
| 12 #include "ui/aura/window.h" |
11 #include "ui/keyboard/keyboard_export.h" | 13 #include "ui/keyboard/keyboard_export.h" |
12 | 14 |
13 namespace aura { | |
14 class RootWindow; | |
15 } | |
16 struct GritResourceMap; | 15 struct GritResourceMap; |
17 | 16 |
18 namespace keyboard { | 17 namespace keyboard { |
19 | 18 |
20 // Enumeration of swipe directions. | 19 // Enumeration of swipe directions. |
21 enum CursorMoveDirection { | 20 enum CursorMoveDirection { |
22 kCursorMoveRight = 0x01, | 21 kCursorMoveRight = 0x01, |
23 kCursorMoveLeft = 0x02, | 22 kCursorMoveLeft = 0x02, |
24 kCursorMoveUp = 0x04, | 23 kCursorMoveUp = 0x04, |
25 kCursorMoveDown = 0x08 | 24 kCursorMoveDown = 0x08 |
26 }; | 25 }; |
27 | 26 |
28 // An enumeration of different keyboard control events that should be logged. | 27 // An enumeration of different keyboard control events that should be logged. |
29 enum KeyboardControlEvent { | 28 enum KeyboardControlEvent { |
30 KEYBOARD_CONTROL_SHOW = 0, | 29 KEYBOARD_CONTROL_SHOW = 0, |
31 KEYBOARD_CONTROL_HIDE_AUTO, | 30 KEYBOARD_CONTROL_HIDE_AUTO, |
32 KEYBOARD_CONTROL_HIDE_USER, | 31 KEYBOARD_CONTROL_HIDE_USER, |
33 KEYBOARD_CONTROL_MAX, | 32 KEYBOARD_CONTROL_MAX, |
34 }; | 33 }; |
35 | 34 |
36 // Returns true if the virtual keyboard is enabled. | 35 // Returns true if the virtual keyboard is enabled. |
37 KEYBOARD_EXPORT bool IsKeyboardEnabled(); | 36 KEYBOARD_EXPORT bool IsKeyboardEnabled(); |
38 | 37 |
39 // Insert |text| into the active TextInputClient associated with |root_window|, | 38 // Insert |text| into the active TextInputClient associated with |root_window|, |
40 // if there is one. Returns true if |text| was successfully inserted. Note | 39 // if there is one. Returns true if |text| was successfully inserted. Note |
41 // that this may convert |text| into ui::KeyEvents for injection in some | 40 // that this may convert |text| into ui::KeyEvents for injection in some |
42 // special circumstances (i.e. VKEY_RETURN, VKEY_BACK). | 41 // special circumstances (i.e. VKEY_RETURN, VKEY_BACK). |
43 KEYBOARD_EXPORT bool InsertText(const base::string16& text, | 42 KEYBOARD_EXPORT bool InsertText(const base::string16& text, |
44 aura::RootWindow* root_window); | 43 aura::Window* root_window); |
45 | 44 |
46 // Move cursor when swipe on the virtualkeyboard. Returns true if cursor was | 45 // Move cursor when swipe on the virtualkeyboard. Returns true if cursor was |
47 // successfully moved according to |swipe_direction|. | 46 // successfully moved according to |swipe_direction|. |
48 KEYBOARD_EXPORT bool MoveCursor(int swipe_direction, | 47 KEYBOARD_EXPORT bool MoveCursor(int swipe_direction, |
49 int modifier_flags, | 48 int modifier_flags, |
50 aura::RootWindow* root_window); | 49 aura::WindowEventDispatcher* dispatcher); |
51 | 50 |
52 // Sends a fabricated key event, where |type| is the event type, |key_value| | 51 // Sends a fabricated key event, where |type| is the event type, |key_value| |
53 // is the unicode value of the character, |key_code| is the legacy key code | 52 // is the unicode value of the character, |key_code| is the legacy key code |
54 // value, and |shift_modifier| indicates if the shift key is being virtually | 53 // value, and |shift_modifier| indicates if the shift key is being virtually |
55 // pressed. The event is dispatched to the active TextInputClient associated | 54 // pressed. The event is dispatched to the active TextInputClient associated |
56 // with |root_window|. The type may be "keydown" or "keyup". | 55 // with |root_window|. The type may be "keydown" or "keyup". |
57 KEYBOARD_EXPORT bool SendKeyEvent(std::string type, | 56 KEYBOARD_EXPORT bool SendKeyEvent(std::string type, |
58 int key_value, | 57 int key_value, |
59 int key_code, | 58 int key_code, |
60 bool shift_modifier, | 59 bool shift_modifier, |
61 aura::RootWindow* root_window); | 60 aura::WindowEventDispatcher* dispatcher); |
62 | 61 |
63 // Get the list of keyboard resources. |size| is populated with the number of | 62 // Get the list of keyboard resources. |size| is populated with the number of |
64 // resources in the returned array. | 63 // resources in the returned array. |
65 KEYBOARD_EXPORT const GritResourceMap* GetKeyboardExtensionResources( | 64 KEYBOARD_EXPORT const GritResourceMap* GetKeyboardExtensionResources( |
66 size_t* size); | 65 size_t* size); |
67 | 66 |
68 // Logs the keyboard control event as a UMA stat. | 67 // Logs the keyboard control event as a UMA stat. |
69 void LogKeyboardControlEvent(KeyboardControlEvent event); | 68 void LogKeyboardControlEvent(KeyboardControlEvent event); |
70 | 69 |
71 } // namespace keyboard | 70 } // namespace keyboard |
72 | 71 |
73 #endif // UI_KEYBOARD_KEYBOARD_UTIL_H_ | 72 #endif // UI_KEYBOARD_KEYBOARD_UTIL_H_ |
OLD | NEW |