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 // TODO(beng): replace with forward decl once RootWindow is renamed. | 10 // TODO(beng): replace with forward decl once RootWindow is renamed. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 KEYBOARD_STATE_AUTO = 0, | 55 KEYBOARD_STATE_AUTO = 0, |
56 // Request virtual keyboard be deployed. | 56 // Request virtual keyboard be deployed. |
57 KEYBOARD_STATE_ENABLED, | 57 KEYBOARD_STATE_ENABLED, |
58 // Request virtual keyboard be suppressed. | 58 // Request virtual keyboard be suppressed. |
59 KEYBOARD_STATE_DISABLED, | 59 KEYBOARD_STATE_DISABLED, |
60 }; | 60 }; |
61 | 61 |
62 // Gets the calculated keyboard bounds from |root_bounds|. The keyboard height | 62 // Gets the calculated keyboard bounds from |root_bounds|. The keyboard height |
63 // is specified by |keyboard_height|. This should be only called when keyboard | 63 // is specified by |keyboard_height|. This should be only called when keyboard |
64 // is in FULL_WDITH mode. | 64 // is in FULL_WDITH mode. |
65 KEYBOARD_EXPORT gfx::Rect FullWidthKeyboardBoundsFromRootBounds( | 65 gfx::Rect FullWidthKeyboardBoundsFromRootBounds( |
66 const gfx::Rect& root_bounds, int keyboard_height); | 66 const gfx::Rect& root_bounds, int keyboard_height); |
67 | 67 |
68 // Sets the state of the a11y onscreen keyboard. | 68 // Sets the state of the a11y onscreen keyboard. |
69 KEYBOARD_EXPORT void SetAccessibilityKeyboardEnabled(bool enabled); | 69 void SetAccessibilityKeyboardEnabled(bool enabled); |
70 | 70 |
71 // Gets the state of the a11y onscreen keyboard. | 71 // Gets the state of the a11y onscreen keyboard. |
72 KEYBOARD_EXPORT bool GetAccessibilityKeyboardEnabled(); | 72 bool GetAccessibilityKeyboardEnabled(); |
73 | 73 |
74 // Sets the state of the hotrod onscreen keyboard. | 74 // Sets the state of the hotrod onscreen keyboard. |
75 KEYBOARD_EXPORT void SetHotrodKeyboardEnabled(bool enabled); | 75 void SetHotrodKeyboardEnabled(bool enabled); |
76 | 76 |
77 // Gets the state of the hotrod onscreen keyboard. | 77 // Gets the state of the hotrod onscreen keyboard. |
78 KEYBOARD_EXPORT bool GetHotrodKeyboardEnabled(); | 78 bool GetHotrodKeyboardEnabled(); |
79 | 79 |
80 // Sets the state of the touch onscreen keyboard. | 80 // Sets the state of the touch onscreen keyboard. |
81 KEYBOARD_EXPORT void SetTouchKeyboardEnabled(bool enabled); | 81 void SetTouchKeyboardEnabled(bool enabled); |
82 | 82 |
83 // Gets the state of the touch onscreen keyboard. | 83 // Gets the state of the touch onscreen keyboard. |
84 KEYBOARD_EXPORT bool GetTouchKeyboardEnabled(); | 84 bool GetTouchKeyboardEnabled(); |
85 | 85 |
86 // Sets the requested state of the keyboard. | 86 // Sets the requested state of the keyboard. |
87 KEYBOARD_EXPORT void SetRequestedKeyboardState(KeyboardState state); | 87 void SetRequestedKeyboardState(KeyboardState state); |
88 | 88 |
89 // Gets the requested state of the keyboard. | 89 // Gets the requested state of the keyboard. |
90 KEYBOARD_EXPORT int GetRequestedKeyboardState(); | 90 int GetRequestedKeyboardState(); |
91 | 91 |
92 // Gets the default keyboard layout. | 92 // Gets the default keyboard layout. |
93 KEYBOARD_EXPORT std::string GetKeyboardLayout(); | 93 std::string GetKeyboardLayout(); |
94 | 94 |
95 // Returns true if the virtual keyboard is enabled. | 95 // Returns true if the virtual keyboard is enabled. |
96 KEYBOARD_EXPORT bool IsKeyboardEnabled(); | 96 bool IsKeyboardEnabled(); |
97 | 97 |
98 // Returns true if smart deployment of the virtual keyboard is enabled. | 98 // Returns true if smart deployment of the virtual keyboard is enabled. |
99 KEYBOARD_EXPORT bool IsSmartDeployEnabled(); | 99 bool IsSmartDeployEnabled(); |
100 | 100 |
101 // Returns true if keyboard overscroll mode is enabled. | 101 // Returns true if keyboard overscroll mode is enabled. |
102 KEYBOARD_EXPORT bool IsKeyboardOverscrollEnabled(); | 102 bool IsKeyboardOverscrollEnabled(); |
103 | 103 |
104 // Sets temporary keyboard overscroll override. | 104 // Sets temporary keyboard overscroll override. |
105 KEYBOARD_EXPORT void SetKeyboardOverscrollOverride( | 105 void SetKeyboardOverscrollOverride( |
106 KeyboardOverscrolOverride override); | 106 KeyboardOverscrolOverride override); |
107 | 107 |
108 // Sets policy override on whether to show the keyboard. | 108 // Sets policy override on whether to show the keyboard. |
109 KEYBOARD_EXPORT void SetKeyboardShowOverride(KeyboardShowOverride override); | 109 void SetKeyboardShowOverride(KeyboardShowOverride override); |
110 | 110 |
111 // Returns true if an IME extension can specify a custom input view for the | 111 // Returns true if an IME extension can specify a custom input view for the |
112 // virtual keyboard window. | 112 // virtual keyboard window. |
113 KEYBOARD_EXPORT bool IsInputViewEnabled(); | 113 bool IsInputViewEnabled(); |
114 | 114 |
115 // Sets whehther the keyboards is in restricted state - state where advanced | 115 // Sets whehther the keyboards is in restricted state - state where advanced |
116 // virtual keyboard features are disabled. | 116 // virtual keyboard features are disabled. |
117 KEYBOARD_EXPORT void SetKeyboardRestricted(bool restricted); | 117 void SetKeyboardRestricted(bool restricted); |
118 | 118 |
119 // Returns whether the keyboard is in restricted state. | 119 // Returns whether the keyboard is in restricted state. |
120 KEYBOARD_EXPORT bool GetKeyboardRestricted(); | 120 bool GetKeyboardRestricted(); |
121 | 121 |
122 // Returns true if experimental features are enabled for IME input-views. | 122 // Returns true if experimental features are enabled for IME input-views. |
123 KEYBOARD_EXPORT bool IsExperimentalInputViewEnabled(); | 123 bool IsExperimentalInputViewEnabled(); |
124 | 124 |
125 // Returns true if floating virtual keyboard feature is enabled. | 125 // Returns true if floating virtual keyboard feature is enabled. |
126 KEYBOARD_EXPORT bool IsFloatingVirtualKeyboardEnabled(); | 126 bool IsFloatingVirtualKeyboardEnabled(); |
127 | 127 |
128 // Returns true if gesture typing option is enabled for virtual keyboard. | 128 // Returns true if gesture typing option is enabled for virtual keyboard. |
129 KEYBOARD_EXPORT bool IsGestureTypingEnabled(); | 129 bool IsGestureTypingEnabled(); |
130 | 130 |
131 // Returns true if gesture editing option is enabled for virtual keyboard. | 131 // Returns true if gesture editing option is enabled for virtual keyboard. |
132 KEYBOARD_EXPORT bool IsGestureEditingEnabled(); | 132 bool IsGestureEditingEnabled(); |
133 | 133 |
134 // Returns true if voice input is not disabled for the keyboard by the command | 134 // Returns true if voice input is not disabled for the keyboard by the command |
135 // line switch. It's up to the client to check if there is an input device | 135 // line switch. It's up to the client to check if there is an input device |
136 // available. | 136 // available. |
137 KEYBOARD_EXPORT bool IsVoiceInputEnabled(); | 137 bool IsVoiceInputEnabled(); |
138 | 138 |
139 // Insert |text| into the active TextInputClient if there is one. Returns true | 139 // Insert |text| into the active TextInputClient if there is one. Returns true |
140 // if |text| was successfully inserted. | 140 // if |text| was successfully inserted. |
141 KEYBOARD_EXPORT bool InsertText(const base::string16& text); | 141 bool InsertText(const base::string16& text); |
142 | 142 |
143 // Move cursor when swipe on the virtualkeyboard. Returns true if cursor was | 143 // Move cursor when swipe on the virtualkeyboard. Returns true if cursor was |
144 // successfully moved according to |swipe_direction|. | 144 // successfully moved according to |swipe_direction|. |
145 KEYBOARD_EXPORT bool MoveCursor(int swipe_direction, | 145 bool MoveCursor(int swipe_direction, |
146 int modifier_flags, | 146 int modifier_flags, |
147 aura::WindowTreeHost* host); | 147 aura::WindowTreeHost* host); |
148 | 148 |
149 // Sends a fabricated key event, where |type| is the event type, |key_value| | 149 // Sends a fabricated key event, where |type| is the event type, |key_value| |
150 // is the unicode value of the character, |key_code| is the legacy key code | 150 // is the unicode value of the character, |key_code| is the legacy key code |
151 // value, |key_name| is the name of the key as defined in the DOM3 key event | 151 // value, |key_name| is the name of the key as defined in the DOM3 key event |
152 // specification, and |modifier| indicates if any modifier keys are being | 152 // specification, and |modifier| indicates if any modifier keys are being |
153 // virtually pressed. The event is dispatched to the active TextInputClient | 153 // virtually pressed. The event is dispatched to the active TextInputClient |
154 // associated with |root_window|. The type may be "keydown" or "keyup". | 154 // associated with |root_window|. The type may be "keydown" or "keyup". |
155 KEYBOARD_EXPORT bool SendKeyEvent(std::string type, | 155 bool SendKeyEvent(std::string type, |
156 int key_value, | 156 int key_value, |
157 int key_code, | 157 int key_code, |
158 std::string key_name, | 158 std::string key_name, |
159 int modifiers, | 159 int modifiers, |
160 aura::WindowTreeHost* host); | 160 aura::WindowTreeHost* host); |
161 | 161 |
162 // Marks that the keyboard load has started. This is used to measure the time it | 162 // Marks that the keyboard load has started. This is used to measure the time it |
163 // takes to fully load the keyboard. This should be called before | 163 // takes to fully load the keyboard. This should be called before |
164 // MarkKeyboardLoadFinished. | 164 // MarkKeyboardLoadFinished. |
165 KEYBOARD_EXPORT void MarkKeyboardLoadStarted(); | 165 void MarkKeyboardLoadStarted(); |
166 | 166 |
167 // Marks that the keyboard load has ended. This finishes measuring that the | 167 // Marks that the keyboard load has ended. This finishes measuring that the |
168 // keyboard is loaded. | 168 // keyboard is loaded. |
169 KEYBOARD_EXPORT void MarkKeyboardLoadFinished(); | 169 void MarkKeyboardLoadFinished(); |
170 | 170 |
171 // Sets the override content url. | 171 // Sets the override content url. |
172 // This is used by for input view for extension IMEs. | 172 // This is used by for input view for extension IMEs. |
173 KEYBOARD_EXPORT void SetOverrideContentUrl(const GURL& url); | 173 void SetOverrideContentUrl(const GURL& url); |
174 | 174 |
175 // Gets the override content url. | 175 // Gets the override content url. |
176 KEYBOARD_EXPORT const GURL& GetOverrideContentUrl(); | 176 const GURL& GetOverrideContentUrl(); |
177 | 177 |
178 // Logs the keyboard control event as a UMA stat. | 178 // Logs the keyboard control event as a UMA stat. |
179 void LogKeyboardControlEvent(KeyboardControlEvent event); | 179 void LogKeyboardControlEvent(KeyboardControlEvent event); |
180 | 180 |
181 // Sets true if keyboard overscrolling is enabled with accessibility keyboard. | 181 // Sets true if keyboard overscrolling is enabled with accessibility keyboard. |
182 KEYBOARD_EXPORT void SetOverscrollEnabledWithAccessibilityKeyboard( | 182 void SetOverscrollEnabledWithAccessibilityKeyboard( |
183 bool enabled); | 183 bool enabled); |
184 | 184 |
185 } // namespace keyboard | 185 } // namespace keyboard |
186 | 186 |
187 #endif // UI_KEYBOARD_KEYBOARD_UTIL_H_ | 187 #endif // UI_KEYBOARD_KEYBOARD_UTIL_H_ |
OLD | NEW |