Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / ash / accelerators / accelerator_table.h
blob077ab4e9edfc11a1990ce421da3d53824eab80c8
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.
5 #ifndef ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
6 #define ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "ui/events/event_constants.h"
11 #include "ui/events/keycodes/keyboard_codes.h"
13 namespace ash {
15 // There are five classes of accelerators in Ash:
17 // Ash (OS) reserved:
18 // * Neither packaged apps nor web pages can cancel.
19 // * For example, power button.
20 // * See kReservedActions below.
22 // Ash (OS) preferred:
23 // * Fullscreen window can consume, but normal window can't.
24 // * For example, Alt-Tab window cycling.
25 // * See kPreferredActions below.
27 // Chrome OS system keys:
28 // * For legacy reasons, v1 apps can process and cancel. Otherwise handled
29 // directly by Ash.
30 // * Brightness, volume control, etc.
31 // * See IsSystemKey() in ash/accelerators/accelerator_filter.cc.
33 // Browser reserved:
34 // * Packaged apps can cancel but web pages cannot.
35 // * For example, browser back and forward from first-row function keys.
36 // * See IsReservedCommandOrKey() in
37 // chrome/browser/ui/browser_command_controller.cc.
39 // Browser non-reserved:
40 // * Both packaged apps and web pages can cancel.
41 // * For example, selecting tabs by number with Ctrl-1 to Ctrl-9.
42 // * See kAcceleratorMap in chrome/browser/ui/views/accelerator_table.cc.
44 // In particular, there is not an accelerator processing pass for Ash after
45 // the browser gets the accelerator. See crbug.com/285308 for details.
47 // There are also various restrictions on accelerators allowed at the login
48 // screen, when running in "forced app mode" (like a kiosk), etc. See the
49 // various kActionsAllowed* below.
51 // Please put if/def sections at the end of the bare section and keep the list
52 // within each section in alphabetical order.
53 enum AcceleratorAction {
54 ACCESSIBLE_FOCUS_NEXT,
55 ACCESSIBLE_FOCUS_PREVIOUS,
56 CYCLE_BACKWARD_MRU,
57 CYCLE_FORWARD_MRU,
58 DEBUG_PRINT_LAYER_HIERARCHY,
59 DEBUG_PRINT_VIEW_HIERARCHY,
60 DEBUG_PRINT_WINDOW_HIERARCHY,
61 DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN,
62 DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE,
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 EXIT,
68 FOCUS_NEXT_PANE,
69 FOCUS_PREVIOUS_PANE,
70 FOCUS_SHELF,
71 LAUNCH_APP_0,
72 LAUNCH_APP_1,
73 LAUNCH_APP_2,
74 LAUNCH_APP_3,
75 LAUNCH_APP_4,
76 LAUNCH_APP_5,
77 LAUNCH_APP_6,
78 LAUNCH_APP_7,
79 LAUNCH_LAST_APP,
80 MAGNIFY_SCREEN_ZOOM_IN,
81 MAGNIFY_SCREEN_ZOOM_OUT,
82 MEDIA_NEXT_TRACK,
83 MEDIA_PLAY_PAUSE,
84 MEDIA_PREV_TRACK,
85 NEW_INCOGNITO_WINDOW,
86 NEW_TAB,
87 NEW_WINDOW,
88 NEXT_IME,
89 OPEN_FEEDBACK_PAGE,
90 PREVIOUS_IME,
91 PRINT_UI_HIERARCHIES,
92 RESTORE_TAB,
93 ROTATE_SCREEN,
94 ROTATE_WINDOW,
95 SCALE_UI_DOWN,
96 SCALE_UI_RESET,
97 SCALE_UI_UP,
98 SHOW_KEYBOARD_OVERLAY,
99 SHOW_MESSAGE_CENTER_BUBBLE,
100 SHOW_SYSTEM_TRAY_BUBBLE,
101 SHOW_TASK_MANAGER,
102 SWITCH_IME, // Switch to another IME depending on the accelerator.
103 TAKE_PARTIAL_SCREENSHOT,
104 TAKE_SCREENSHOT,
105 TOGGLE_APP_LIST,
106 TOGGLE_FULLSCREEN,
107 TOGGLE_MAXIMIZED,
108 TOGGLE_OVERVIEW,
109 WINDOW_MINIMIZE,
110 WINDOW_POSITION_CENTER,
111 WINDOW_CYCLE_SNAP_DOCK_LEFT,
112 WINDOW_CYCLE_SNAP_DOCK_RIGHT,
113 #if defined(OS_CHROMEOS)
114 BRIGHTNESS_DOWN,
115 BRIGHTNESS_UP,
116 DEBUG_ADD_REMOVE_DISPLAY,
117 DISABLE_CAPS_LOCK,
118 DISABLE_GPU_WATCHDOG,
119 KEYBOARD_BRIGHTNESS_DOWN,
120 KEYBOARD_BRIGHTNESS_UP,
121 LOCK_PRESSED,
122 LOCK_RELEASED,
123 LOCK_SCREEN,
124 OPEN_CROSH,
125 OPEN_FILE_MANAGER,
126 OPEN_GET_HELP,
127 POWER_PRESSED,
128 POWER_RELEASED,
129 SILENCE_SPOKEN_FEEDBACK,
130 SWAP_PRIMARY_DISPLAY,
131 SWITCH_TO_NEXT_USER,
132 SWITCH_TO_PREVIOUS_USER,
133 TOGGLE_CAPS_LOCK,
134 TOGGLE_MIRROR_MODE,
135 TOGGLE_SPOKEN_FEEDBACK,
136 TOGGLE_TOUCH_VIEW_TESTING,
137 TOGGLE_WIFI,
138 TOUCH_HUD_CLEAR,
139 TOUCH_HUD_MODE_CHANGE,
140 TOUCH_HUD_PROJECTION_TOGGLE,
141 VOLUME_DOWN,
142 VOLUME_MUTE,
143 VOLUME_UP,
144 #else
145 DUMMY_FOR_RESERVED,
146 #endif
149 struct AcceleratorData {
150 bool trigger_on_press;
151 ui::KeyboardCode keycode;
152 int modifiers;
153 AcceleratorAction action;
156 // Gathers the needed data to handle deprecated accelerators.
157 struct DeprecatedAcceleratorData {
158 // The old deprecated accelerator.
159 AcceleratorData deprecated_accelerator;
161 // The name of the UMA histogram that will be used to measure the deprecated
162 // v.s. new accelerator usage.
163 const char* uma_histogram_name;
165 // The ID of the localized notification message to show to users informing
166 // them about the deprecation.
167 int notification_message_id;
169 // Specifies whether the deprecated accelerator is still enabled to do its
170 // associated action.
171 bool deprecated_enabled;
174 // The ID of the MessageCenter notifications of deprecated accelerators.
175 const char kDeprecatedAcceleratorNotificationId[] = "deprecated_accelerator";
177 // This will be used for the UMA stats to measure the how many users are using
178 // the old v.s. new accelerators.
179 enum DeprecatedAcceleratorUsage {
180 DEPRECATED_USED = 0, // The deprecated accelerator is used.
181 NEW_USED, // The new accelerator is used.
182 DEPRECATED_USAGE_COUNT, // Maximum value of this enum for histogram use.
185 // Accelerators handled by AcceleratorController.
186 ASH_EXPORT extern const AcceleratorData kAcceleratorData[];
187 ASH_EXPORT extern const size_t kAcceleratorDataLength;
189 #if defined(OS_CHROMEOS)
190 // The list of the deprecated accelerators along with their new replacing ones
191 // and how to handle them.
192 ASH_EXPORT extern const DeprecatedAcceleratorData kDeprecatedAccelerators[];
193 ASH_EXPORT extern const size_t kDeprecatedAcceleratorsLength;
194 #endif // defined(OS_CHROMEOS)
196 // Debug accelerators. Debug accelerators are only enabled when the "Debugging
197 // keyboard shortcuts" flag (--ash-debug-shortcuts) is enabled. Debug actions
198 // are always run (similar to reserved actions).
199 ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[];
200 ASH_EXPORT extern const size_t kDebugAcceleratorDataLength;
202 // Actions that should be handled very early in Ash unless the current target
203 // window is full-screen.
204 ASH_EXPORT extern const AcceleratorAction kPreferredActions[];
205 ASH_EXPORT extern const size_t kPreferredActionsLength;
207 // Actions that are always handled in Ash.
208 ASH_EXPORT extern const AcceleratorAction kReservedActions[];
209 ASH_EXPORT extern const size_t kReservedActionsLength;
211 // Actions allowed while user is not signed in or screen is locked.
212 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[];
213 ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength;
215 // Actions allowed while screen is locked (in addition to
216 // kActionsAllowedAtLoginOrLockScreen).
217 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[];
218 ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength;
220 // Actions allowed while a modal window is up.
221 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[];
222 ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength;
224 // Actions which will not be repeated while holding an accelerator key.
225 ASH_EXPORT extern const AcceleratorAction kNonrepeatableActions[];
226 ASH_EXPORT extern const size_t kNonrepeatableActionsLength;
228 // Actions allowed in app mode.
229 ASH_EXPORT extern const AcceleratorAction kActionsAllowedInAppMode[];
230 ASH_EXPORT extern const size_t kActionsAllowedInAppModeLength;
232 // Actions that require at least 1 window.
233 ASH_EXPORT extern const AcceleratorAction kActionsNeedingWindow[];
234 ASH_EXPORT extern const size_t kActionsNeedingWindowLength;
236 } // namespace ash
238 #endif // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_