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_ACCELERATORS_ACCELERATOR_TABLE_H_
6#define ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
7
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"
12
13namespace ash {
14
15// There are four classes of accelerators in Ash:
16//
17// Ash (OS) reserved:
18// * Neither packaged apps nor web pages can cancel.
19// * For example, Alt-Tab window cycling.
20// * See kReservedActions below.
21//
22// Chrome OS system keys:
23// * For legacy reasons, v1 apps can process and cancel. Otherwise handled
24//   directly by Ash.
25// * Brightness, volume control, etc.
26// * See IsSystemKey() in ash/accelerators/accelerator_filter.cc.
27//
28// Browser reserved:
29// * Packaged apps can cancel but web pages cannot.
30// * For example, browser back and forward from first-row function keys.
31// * See IsReservedCommandOrKey() in
32//   chrome/browser/ui/browser_command_controller.cc.
33//
34// Browser non-reserved:
35// * Both packaged apps and web pages can cancel.
36// * For example, selecting tabs by number with Ctrl-1 to Ctrl-9.
37// * See kAcceleratorMap in chrome/browser/ui/views/accelerator_table.cc.
38//
39// In particular, there is not an accelerator processing pass for Ash after
40// the browser gets the accelerator.  See crbug.com/285308 for details.
41//
42// There are also various restrictions on accelerators allowed at the login
43// screen, when running in "forced app mode" (like a kiosk), etc. See the
44// various kActionsAllowed* below.
45//
46// Please put if/def sections at the end of the bare section and keep the list
47// within each section in alphabetical order.
48enum AcceleratorAction {
49  ACCESSIBLE_FOCUS_NEXT,
50  ACCESSIBLE_FOCUS_PREVIOUS,
51  BRIGHTNESS_DOWN,
52  BRIGHTNESS_UP,
53  CYCLE_BACKWARD_MRU,
54  CYCLE_FORWARD_MRU,
55  CYCLE_LINEAR,
56  DEBUG_TOGGLE_DEVICE_SCALE_FACTOR,
57  DEBUG_TOGGLE_SHOW_DEBUG_BORDERS,
58  DEBUG_TOGGLE_SHOW_FPS_COUNTER,
59  DEBUG_TOGGLE_SHOW_PAINT_RECTS,
60  DISABLE_CAPS_LOCK,
61  EXIT,
62  FOCUS_LAUNCHER,
63  FOCUS_NEXT_PANE,
64  FOCUS_PREVIOUS_PANE,
65  KEYBOARD_BRIGHTNESS_DOWN,
66  KEYBOARD_BRIGHTNESS_UP,
67  LAUNCH_APP_0,
68  LAUNCH_APP_1,
69  LAUNCH_APP_2,
70  LAUNCH_APP_3,
71  LAUNCH_APP_4,
72  LAUNCH_APP_5,
73  LAUNCH_APP_6,
74  LAUNCH_APP_7,
75  LAUNCH_LAST_APP,
76  LOCK_PRESSED,
77  LOCK_RELEASED,
78  MAGNIFY_SCREEN_ZOOM_IN,
79  MAGNIFY_SCREEN_ZOOM_OUT,
80  MEDIA_NEXT_TRACK,
81  MEDIA_PLAY_PAUSE,
82  MEDIA_PREV_TRACK,
83  NEW_INCOGNITO_WINDOW,
84  NEW_TAB,
85  NEW_WINDOW,
86  NEXT_IME,
87  OPEN_FEEDBACK_PAGE,
88  POWER_PRESSED,
89  POWER_RELEASED,
90  PREVIOUS_IME,
91  PRINT_LAYER_HIERARCHY,
92  PRINT_UI_HIERARCHIES,
93  PRINT_VIEW_HIERARCHY,
94  PRINT_WINDOW_HIERARCHY,
95  RESTORE_TAB,
96  ROTATE_SCREEN,
97  ROTATE_WINDOW,
98  SCALE_UI_DOWN,
99  SCALE_UI_RESET,
100  SCALE_UI_UP,
101  SHOW_KEYBOARD_OVERLAY,
102  SHOW_MESSAGE_CENTER_BUBBLE,
103  SHOW_OAK,
104  SHOW_SYSTEM_TRAY_BUBBLE,
105  SHOW_TASK_MANAGER,
106  SILENCE_SPOKEN_FEEDBACK,
107  SWAP_PRIMARY_DISPLAY,
108  SWITCH_IME,  // Switch to another IME depending on the accelerator.
109  TAKE_PARTIAL_SCREENSHOT,
110  TAKE_SCREENSHOT,
111  TOGGLE_APP_LIST,
112  TOGGLE_CAPS_LOCK,
113  TOGGLE_CAPS_LOCK_BY_ALT_LWIN,
114  TOGGLE_DESKTOP_BACKGROUND_MODE,
115  TOGGLE_FULLSCREEN,
116  TOGGLE_MAXIMIZED,
117  TOGGLE_ROOT_WINDOW_FULL_SCREEN,
118  TOGGLE_SPOKEN_FEEDBACK,
119  TOGGLE_WIFI,
120  TOUCH_HUD_CLEAR,
121  TOUCH_HUD_MODE_CHANGE,
122  TOUCH_HUD_PROJECTION_TOGGLE,
123  VOLUME_DOWN,
124  VOLUME_MUTE,
125  VOLUME_UP,
126  WINDOW_MINIMIZE,
127  WINDOW_POSITION_CENTER,
128  WINDOW_SNAP_LEFT,
129  WINDOW_SNAP_RIGHT,
130#if defined(OS_CHROMEOS)
131  ADD_REMOVE_DISPLAY,
132  TOGGLE_MIRROR_MODE,
133  DISABLE_GPU_WATCHDOG,
134  LOCK_SCREEN,
135  OPEN_CROSH,
136  OPEN_FILE_MANAGER,
137  SWITCH_TO_NEXT_USER,
138  SWITCH_TO_PREVIOUS_USER,
139#endif
140};
141
142struct AcceleratorData {
143  bool trigger_on_press;
144  ui::KeyboardCode keycode;
145  int modifiers;
146  AcceleratorAction action;
147};
148
149// Accelerators handled by AcceleratorController.
150ASH_EXPORT extern const AcceleratorData kAcceleratorData[];
151ASH_EXPORT extern const size_t kAcceleratorDataLength;
152
153#if !defined(NDEBUG)
154// Accelerators useful when running on desktop. Debug build only.
155ASH_EXPORT extern const AcceleratorData kDesktopAcceleratorData[];
156ASH_EXPORT extern const size_t kDesktopAcceleratorDataLength;
157#endif
158
159// Debug accelerators enabled only when "Debugging keyboard shortcuts" flag
160// (--ash-debug-shortcuts) is enabled.
161ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[];
162ASH_EXPORT extern const size_t kDebugAcceleratorDataLength;
163
164// Actions that should be handled very early in Ash unless the current target
165// window is full-screen.
166ASH_EXPORT extern const AcceleratorAction kReservedActions[];
167ASH_EXPORT extern const size_t kReservedActionsLength;
168
169// Actions that should be handled very early in Ash unless the current target
170// window is full-screen, these actions are only handled if
171// DebugShortcutsEnabled is true (command line switch 'ash-debug-shortcuts').
172ASH_EXPORT extern const AcceleratorAction kReservedDebugActions[];
173ASH_EXPORT extern const size_t kReservedDebugActionsLength;
174
175// Actions allowed while user is not signed in or screen is locked.
176ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[];
177ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength;
178
179// Actions allowed while screen is locked (in addition to
180// kActionsAllowedAtLoginOrLockScreen).
181ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[];
182ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength;
183
184// Actions allowed while a modal window is up.
185ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[];
186ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength;
187
188// Actions which will not be repeated while holding an accelerator key.
189ASH_EXPORT extern const AcceleratorAction kNonrepeatableActions[];
190ASH_EXPORT extern const size_t kNonrepeatableActionsLength;
191
192// Actions allowed in app mode.
193ASH_EXPORT extern const AcceleratorAction kActionsAllowedInAppMode[];
194ASH_EXPORT extern const size_t kActionsAllowedInAppModeLength;
195
196// Actions that require at least 1 window.
197ASH_EXPORT extern const AcceleratorAction kActionsNeedingWindow[];
198ASH_EXPORT extern const size_t kActionsNeedingWindowLength;
199
200}  // namespace ash
201
202#endif  // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
203