OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 ASH_COMMON_ACCELERATORS_ACCELERATOR_TABLE_H_ | |
6 #define ASH_COMMON_ACCELERATORS_ACCELERATOR_TABLE_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "ui/events/event_constants.h" | |
12 #include "ui/events/keycodes/keyboard_codes.h" | |
13 | |
14 namespace ash { | |
15 | |
16 // There are five classes of accelerators in Ash: | |
17 // | |
18 // Ash (OS) reserved: | |
19 // * Neither packaged apps nor web pages can cancel. | |
20 // * For example, power button. | |
21 // * See kReservedActions below. | |
22 // | |
23 // Ash (OS) preferred: | |
24 // * Fullscreen window can consume, but normal window can't. | |
25 // * For example, Alt-Tab window cycling. | |
26 // * See kPreferredActions below. | |
27 // | |
28 // Chrome OS system keys: | |
29 // * For legacy reasons, v1 apps can process and cancel. Otherwise handled | |
30 // directly by Ash. | |
31 // * Brightness, volume control, etc. | |
32 // * See IsSystemKey() in ash/accelerators/accelerator_filter.cc. | |
33 // | |
34 // Browser reserved: | |
35 // * Packaged apps can cancel but web pages cannot. | |
36 // * For example, browser back and forward from first-row function keys. | |
37 // * See IsReservedCommandOrKey() in | |
38 // chrome/browser/ui/browser_command_controller.cc. | |
39 // | |
40 // Browser non-reserved: | |
41 // * Both packaged apps and web pages can cancel. | |
42 // * For example, selecting tabs by number with Ctrl-1 to Ctrl-9. | |
43 // * See kAcceleratorMap in chrome/browser/ui/views/accelerator_table.cc. | |
44 // | |
45 // In particular, there is not an accelerator processing pass for Ash after | |
46 // the browser gets the accelerator. See crbug.com/285308 for details. | |
47 // | |
48 // There are also various restrictions on accelerators allowed at the login | |
49 // screen, when running in "forced app mode" (like a kiosk), etc. See the | |
50 // various kActionsAllowed* below. | |
51 // | |
52 // Please put if/def sections at the end of the bare section and keep the list | |
53 // within each section in alphabetical order. | |
54 enum AcceleratorAction { | |
55 BRIGHTNESS_DOWN, | |
56 BRIGHTNESS_UP, | |
57 CYCLE_BACKWARD_MRU, | |
58 CYCLE_FORWARD_MRU, | |
59 DEBUG_PRINT_LAYER_HIERARCHY, | |
60 DEBUG_PRINT_VIEW_HIERARCHY, | |
61 DEBUG_PRINT_WINDOW_HIERARCHY, | |
62 DEBUG_SHOW_TOAST, | |
63 DEBUG_TOGGLE_DEVICE_SCALE_FACTOR, | |
64 DEBUG_TOGGLE_SHOW_DEBUG_BORDERS, | |
65 DEBUG_TOGGLE_SHOW_FPS_COUNTER, | |
66 DEBUG_TOGGLE_SHOW_PAINT_RECTS, | |
67 DEBUG_TOGGLE_TOUCH_PAD, | |
68 DEBUG_TOGGLE_TOUCH_SCREEN, | |
69 DEBUG_TOGGLE_TOUCH_VIEW, | |
70 DEBUG_TOGGLE_WALLPAPER_MODE, | |
71 DEBUG_TRIGGER_CRASH, // Intentionally crash the ash process. | |
72 DEV_ADD_REMOVE_DISPLAY, | |
73 DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN, | |
74 DEV_TOGGLE_UNIFIED_DESKTOP, | |
75 DISABLE_CAPS_LOCK, | |
76 EXIT, | |
77 FOCUS_NEXT_PANE, | |
78 FOCUS_PREVIOUS_PANE, | |
79 FOCUS_SHELF, | |
80 KEYBOARD_BRIGHTNESS_DOWN, | |
81 KEYBOARD_BRIGHTNESS_UP, | |
82 LAUNCH_APP_0, | |
83 LAUNCH_APP_1, | |
84 LAUNCH_APP_2, | |
85 LAUNCH_APP_3, | |
86 LAUNCH_APP_4, | |
87 LAUNCH_APP_5, | |
88 LAUNCH_APP_6, | |
89 LAUNCH_APP_7, | |
90 LAUNCH_LAST_APP, | |
91 LOCK_PRESSED, | |
92 LOCK_RELEASED, | |
93 LOCK_SCREEN, | |
94 MAGNIFY_SCREEN_ZOOM_IN, | |
95 MAGNIFY_SCREEN_ZOOM_OUT, | |
96 MEDIA_NEXT_TRACK, | |
97 MEDIA_PLAY_PAUSE, | |
98 MEDIA_PREV_TRACK, | |
99 NEW_INCOGNITO_WINDOW, | |
100 NEW_TAB, | |
101 NEW_WINDOW, | |
102 NEXT_IME, | |
103 OPEN_CROSH, | |
104 OPEN_FEEDBACK_PAGE, | |
105 OPEN_FILE_MANAGER, | |
106 OPEN_GET_HELP, | |
107 POWER_PRESSED, | |
108 POWER_RELEASED, | |
109 PREVIOUS_IME, | |
110 PRINT_UI_HIERARCHIES, | |
111 RESTORE_TAB, | |
112 ROTATE_SCREEN, | |
113 ROTATE_WINDOW, | |
114 SCALE_UI_DOWN, | |
115 SCALE_UI_RESET, | |
116 SCALE_UI_UP, | |
117 SHOW_IME_MENU_BUBBLE, | |
118 SHOW_KEYBOARD_OVERLAY, | |
119 SHOW_MESSAGE_CENTER_BUBBLE, | |
120 SHOW_STYLUS_TOOLS, | |
121 SHOW_SYSTEM_TRAY_BUBBLE, | |
122 SHOW_TASK_MANAGER, | |
123 SUSPEND, | |
124 SWAP_PRIMARY_DISPLAY, | |
125 SWITCH_IME, // Switch to another IME depending on the accelerator. | |
126 SWITCH_TO_NEXT_USER, | |
127 SWITCH_TO_PREVIOUS_USER, | |
128 TAKE_PARTIAL_SCREENSHOT, | |
129 TAKE_SCREENSHOT, | |
130 TAKE_WINDOW_SCREENSHOT, | |
131 TOGGLE_APP_LIST, | |
132 TOGGLE_CAPS_LOCK, | |
133 TOGGLE_FULLSCREEN, | |
134 TOGGLE_HIGH_CONTRAST, | |
135 TOGGLE_MAXIMIZED, | |
136 TOGGLE_MIRROR_MODE, | |
137 TOGGLE_OVERVIEW, | |
138 TOGGLE_SPOKEN_FEEDBACK, | |
139 TOGGLE_WIFI, | |
140 TOUCH_HUD_CLEAR, | |
141 TOUCH_HUD_MODE_CHANGE, | |
142 TOUCH_HUD_PROJECTION_TOGGLE, | |
143 UNPIN, | |
144 VOLUME_DOWN, | |
145 VOLUME_MUTE, | |
146 VOLUME_UP, | |
147 WINDOW_CYCLE_SNAP_DOCK_LEFT, | |
148 WINDOW_CYCLE_SNAP_DOCK_RIGHT, | |
149 WINDOW_MINIMIZE, | |
150 WINDOW_POSITION_CENTER, | |
151 }; | |
152 | |
153 struct AcceleratorData { | |
154 bool trigger_on_press; | |
155 ui::KeyboardCode keycode; | |
156 int modifiers; | |
157 AcceleratorAction action; | |
158 }; | |
159 | |
160 // Gathers the needed data to handle deprecated accelerators. | |
161 struct DeprecatedAcceleratorData { | |
162 // The action that has deprecated accelerators. | |
163 AcceleratorAction action; | |
164 | |
165 // The name of the UMA histogram that will be used to measure the deprecated | |
166 // v.s. new accelerator usage. | |
167 const char* uma_histogram_name; | |
168 | |
169 // The ID of the localized notification message to show to users informing | |
170 // them about the deprecation. | |
171 int notification_message_id; | |
172 | |
173 // The ID of the localized old deprecated shortcut key. | |
174 int old_shortcut_id; | |
175 | |
176 // The ID of the localized new shortcut key. | |
177 int new_shortcut_id; | |
178 | |
179 // Specifies whether the deprecated accelerator is still enabled to do its | |
180 // associated action. | |
181 bool deprecated_enabled; | |
182 }; | |
183 | |
184 // This will be used for the UMA stats to measure the how many users are using | |
185 // the old v.s. new accelerators. | |
186 enum DeprecatedAcceleratorUsage { | |
187 DEPRECATED_USED = 0, // The deprecated accelerator is used. | |
188 NEW_USED, // The new accelerator is used. | |
189 DEPRECATED_USAGE_COUNT, // Maximum value of this enum for histogram use. | |
190 }; | |
191 | |
192 // Accelerators handled by AcceleratorController. | |
193 ASH_EXPORT extern const AcceleratorData kAcceleratorData[]; | |
194 ASH_EXPORT extern const size_t kAcceleratorDataLength; | |
195 | |
196 // The list of the deprecated accelerators. | |
197 ASH_EXPORT extern const AcceleratorData kDeprecatedAccelerators[]; | |
198 ASH_EXPORT extern const size_t kDeprecatedAcceleratorsLength; | |
199 | |
200 // The list of the actions with deprecated accelerators and the needed data to | |
201 // handle them. | |
202 ASH_EXPORT extern const DeprecatedAcceleratorData kDeprecatedAcceleratorsData[]; | |
203 ASH_EXPORT extern const size_t kDeprecatedAcceleratorsDataLength; | |
204 | |
205 // Debug accelerators. Debug accelerators are only enabled when the "Debugging | |
206 // keyboard shortcuts" flag (--ash-debug-shortcuts) is enabled. Debug actions | |
207 // are always run (similar to reserved actions). Debug accelerators can be | |
208 // enabled in about:flags. | |
209 ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[]; | |
210 ASH_EXPORT extern const size_t kDebugAcceleratorDataLength; | |
211 | |
212 // Developer accelerators that are enabled only with the command-line switch | |
213 // --ash-dev-shortcuts. They are always run similar to reserved actions. | |
214 ASH_EXPORT extern const AcceleratorData kDeveloperAcceleratorData[]; | |
215 ASH_EXPORT extern const size_t kDeveloperAcceleratorDataLength; | |
216 | |
217 // Actions that should be handled very early in Ash unless the current target | |
218 // window is full-screen. | |
219 ASH_EXPORT extern const AcceleratorAction kPreferredActions[]; | |
220 ASH_EXPORT extern const size_t kPreferredActionsLength; | |
221 | |
222 // Actions that are always handled in Ash. | |
223 ASH_EXPORT extern const AcceleratorAction kReservedActions[]; | |
224 ASH_EXPORT extern const size_t kReservedActionsLength; | |
225 | |
226 // Actions allowed while user is not signed in or screen is locked. | |
227 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[]; | |
228 ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength; | |
229 | |
230 // Actions allowed while screen is locked (in addition to | |
231 // kActionsAllowedAtLoginOrLockScreen). | |
232 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[]; | |
233 ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength; | |
234 | |
235 // Actions allowed while a modal window is up. | |
236 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[]; | |
237 ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength; | |
238 | |
239 // Actions which may be repeated by holding an accelerator key. | |
240 ASH_EXPORT extern const AcceleratorAction kRepeatableActions[]; | |
241 ASH_EXPORT extern const size_t kRepeatableActionsLength; | |
242 | |
243 // Actions allowed in app mode or pinned mode. | |
244 ASH_EXPORT extern const AcceleratorAction | |
245 kActionsAllowedInAppModeOrPinnedMode[]; | |
246 ASH_EXPORT extern const size_t kActionsAllowedInAppModeOrPinnedModeLength; | |
247 | |
248 // Actions that can be performed in pinned mode. | |
249 // In pinned mode, the action listed this or "in app mode or pinned mode" table | |
250 // can be performed. | |
251 ASH_EXPORT extern const AcceleratorAction kActionsAllowedInPinnedMode[]; | |
252 ASH_EXPORT extern const size_t kActionsAllowedInPinnedModeLength; | |
253 | |
254 // Actions that require at least 1 window. | |
255 ASH_EXPORT extern const AcceleratorAction kActionsNeedingWindow[]; | |
256 ASH_EXPORT extern const size_t kActionsNeedingWindowLength; | |
257 | |
258 // Actions that can be performed while keeping the menu open. | |
259 ASH_EXPORT extern const AcceleratorAction kActionsKeepingMenuOpen[]; | |
260 ASH_EXPORT extern const size_t kActionsKeepingMenuOpenLength; | |
261 | |
262 } // namespace ash | |
263 | |
264 #endif // ASH_COMMON_ACCELERATORS_ACCELERATOR_TABLE_H_ | |
OLD | NEW |