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. | 11 // TODO(beng): replace with forward decl once RootWindow is renamed. |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/keyboard/keyboard_export.h" | 13 #include "ui/keyboard/keyboard_export.h" |
14 | 14 |
15 struct GritResourceMap; | 15 struct GritResourceMap; |
16 | 16 |
17 namespace aura { | 17 namespace aura { |
18 class WindowEventDispatcher; | 18 class WindowTreeHost; |
19 } | 19 } |
20 | 20 |
21 class GURL; | 21 class GURL; |
22 | 22 |
23 namespace keyboard { | 23 namespace keyboard { |
24 | 24 |
25 // Enumeration of swipe directions. | 25 // Enumeration of swipe directions. |
26 enum CursorMoveDirection { | 26 enum CursorMoveDirection { |
27 kCursorMoveRight = 0x01, | 27 kCursorMoveRight = 0x01, |
28 kCursorMoveLeft = 0x02, | 28 kCursorMoveLeft = 0x02, |
(...skipping 28 matching lines...) Expand all Loading... |
57 // if there is one. Returns true if |text| was successfully inserted. Note | 57 // if there is one. Returns true if |text| was successfully inserted. Note |
58 // that this may convert |text| into ui::KeyEvents for injection in some | 58 // that this may convert |text| into ui::KeyEvents for injection in some |
59 // special circumstances (i.e. VKEY_RETURN, VKEY_BACK). | 59 // special circumstances (i.e. VKEY_RETURN, VKEY_BACK). |
60 KEYBOARD_EXPORT bool InsertText(const base::string16& text, | 60 KEYBOARD_EXPORT bool InsertText(const base::string16& text, |
61 aura::Window* root_window); | 61 aura::Window* root_window); |
62 | 62 |
63 // Move cursor when swipe on the virtualkeyboard. Returns true if cursor was | 63 // Move cursor when swipe on the virtualkeyboard. Returns true if cursor was |
64 // successfully moved according to |swipe_direction|. | 64 // successfully moved according to |swipe_direction|. |
65 KEYBOARD_EXPORT bool MoveCursor(int swipe_direction, | 65 KEYBOARD_EXPORT bool MoveCursor(int swipe_direction, |
66 int modifier_flags, | 66 int modifier_flags, |
67 aura::WindowEventDispatcher* dispatcher); | 67 aura::WindowTreeHost* host); |
68 | 68 |
69 // Sends a fabricated key event, where |type| is the event type, |key_value| | 69 // Sends a fabricated key event, where |type| is the event type, |key_value| |
70 // is the unicode value of the character, |key_code| is the legacy key code | 70 // is the unicode value of the character, |key_code| is the legacy key code |
71 // value, |key_name| is the name of the key as defined in the DOM3 key event | 71 // value, |key_name| is the name of the key as defined in the DOM3 key event |
72 // specification, and |modifier| indicates if any modifier keys are being | 72 // specification, and |modifier| indicates if any modifier keys are being |
73 // virtually pressed. The event is dispatched to the active TextInputClient | 73 // virtually pressed. The event is dispatched to the active TextInputClient |
74 // associated with |root_window|. The type may be "keydown" or "keyup". | 74 // associated with |root_window|. The type may be "keydown" or "keyup". |
75 KEYBOARD_EXPORT bool SendKeyEvent(std::string type, | 75 KEYBOARD_EXPORT bool SendKeyEvent(std::string type, |
76 int key_value, | 76 int key_value, |
77 int key_code, | 77 int key_code, |
78 std::string key_name, | 78 std::string key_name, |
79 int modifiers, | 79 int modifiers, |
80 aura::WindowEventDispatcher* dispatcher); | 80 aura::WindowTreeHost* host); |
81 | 81 |
82 // Marks that the keyboard load has started. This is used to measure the time it | 82 // Marks that the keyboard load has started. This is used to measure the time it |
83 // takes to fully load the keyboard. This should be called before | 83 // takes to fully load the keyboard. This should be called before |
84 // MarkKeyboardLoadFinished. | 84 // MarkKeyboardLoadFinished. |
85 KEYBOARD_EXPORT const void MarkKeyboardLoadStarted(); | 85 KEYBOARD_EXPORT const void MarkKeyboardLoadStarted(); |
86 | 86 |
87 // Marks that the keyboard load has ended. This finishes measuring that the | 87 // Marks that the keyboard load has ended. This finishes measuring that the |
88 // keyboard is loaded. | 88 // keyboard is loaded. |
89 KEYBOARD_EXPORT const void MarkKeyboardLoadFinished(); | 89 KEYBOARD_EXPORT const void MarkKeyboardLoadFinished(); |
90 | 90 |
91 // Get the list of keyboard resources. |size| is populated with the number of | 91 // Get the list of keyboard resources. |size| is populated with the number of |
92 // resources in the returned array. | 92 // resources in the returned array. |
93 KEYBOARD_EXPORT const GritResourceMap* GetKeyboardExtensionResources( | 93 KEYBOARD_EXPORT const GritResourceMap* GetKeyboardExtensionResources( |
94 size_t* size); | 94 size_t* size); |
95 | 95 |
96 // Sets the override content url. | 96 // Sets the override content url. |
97 // This is used by for input view for extension IMEs. | 97 // This is used by for input view for extension IMEs. |
98 KEYBOARD_EXPORT void SetOverrideContentUrl(const GURL& url); | 98 KEYBOARD_EXPORT void SetOverrideContentUrl(const GURL& url); |
99 | 99 |
100 // Gets the override content url. | 100 // Gets the override content url. |
101 KEYBOARD_EXPORT const GURL& GetOverrideContentUrl(); | 101 KEYBOARD_EXPORT const GURL& GetOverrideContentUrl(); |
102 | 102 |
103 // Logs the keyboard control event as a UMA stat. | 103 // Logs the keyboard control event as a UMA stat. |
104 void LogKeyboardControlEvent(KeyboardControlEvent event); | 104 void LogKeyboardControlEvent(KeyboardControlEvent event); |
105 | 105 |
106 } // namespace keyboard | 106 } // namespace keyboard |
107 | 107 |
108 #endif // UI_KEYBOARD_KEYBOARD_UTIL_H_ | 108 #endif // UI_KEYBOARD_KEYBOARD_UTIL_H_ |
OLD | NEW |