| 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_ACCELERATORS_ACCELERATOR_TABLE_H_ | |
| 6 #define ASH_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 CYCLE_BACKWARD_MRU, | |
| 56 CYCLE_FORWARD_MRU, | |
| 57 DEBUG_PRINT_LAYER_HIERARCHY, | |
| 58 DEBUG_PRINT_VIEW_HIERARCHY, | |
| 59 DEBUG_PRINT_WINDOW_HIERARCHY, | |
| 60 DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN, | |
| 61 DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE, | |
| 62 DEBUG_TOGGLE_DEVICE_SCALE_FACTOR, | |
| 63 DEBUG_TOGGLE_SHOW_DEBUG_BORDERS, | |
| 64 DEBUG_TOGGLE_SHOW_FPS_COUNTER, | |
| 65 DEBUG_TOGGLE_SHOW_PAINT_RECTS, | |
| 66 EXIT, | |
| 67 FOCUS_NEXT_PANE, | |
| 68 FOCUS_PREVIOUS_PANE, | |
| 69 FOCUS_SHELF, | |
| 70 LAUNCH_APP_0, | |
| 71 LAUNCH_APP_1, | |
| 72 LAUNCH_APP_2, | |
| 73 LAUNCH_APP_3, | |
| 74 LAUNCH_APP_4, | |
| 75 LAUNCH_APP_5, | |
| 76 LAUNCH_APP_6, | |
| 77 LAUNCH_APP_7, | |
| 78 LAUNCH_LAST_APP, | |
| 79 MAGNIFY_SCREEN_ZOOM_IN, | |
| 80 MAGNIFY_SCREEN_ZOOM_OUT, | |
| 81 MEDIA_NEXT_TRACK, | |
| 82 MEDIA_PLAY_PAUSE, | |
| 83 MEDIA_PREV_TRACK, | |
| 84 NEW_INCOGNITO_WINDOW, | |
| 85 NEW_TAB, | |
| 86 NEW_WINDOW, | |
| 87 NEXT_IME, | |
| 88 OPEN_FEEDBACK_PAGE, | |
| 89 PREVIOUS_IME, | |
| 90 PRINT_UI_HIERARCHIES, | |
| 91 RESTORE_TAB, | |
| 92 ROTATE_SCREEN, | |
| 93 ROTATE_WINDOW, | |
| 94 SCALE_UI_DOWN, | |
| 95 SCALE_UI_RESET, | |
| 96 SCALE_UI_UP, | |
| 97 SHOW_KEYBOARD_OVERLAY, | |
| 98 SHOW_MESSAGE_CENTER_BUBBLE, | |
| 99 SHOW_SYSTEM_TRAY_BUBBLE, | |
| 100 SHOW_TASK_MANAGER, | |
| 101 SWITCH_IME, // Switch to another IME depending on the accelerator. | |
| 102 TAKE_WINDOW_SCREENSHOT, | |
| 103 TAKE_PARTIAL_SCREENSHOT, | |
| 104 TAKE_SCREENSHOT, | |
| 105 TOGGLE_APP_LIST, | |
| 106 TOGGLE_FULLSCREEN, | |
| 107 TOGGLE_MAXIMIZED, | |
| 108 TOGGLE_OVERVIEW, | |
| 109 UNPIN, | |
| 110 WINDOW_MINIMIZE, | |
| 111 WINDOW_POSITION_CENTER, | |
| 112 WINDOW_CYCLE_SNAP_DOCK_LEFT, | |
| 113 WINDOW_CYCLE_SNAP_DOCK_RIGHT, | |
| 114 #if defined(OS_CHROMEOS) | |
| 115 BRIGHTNESS_DOWN, | |
| 116 BRIGHTNESS_UP, | |
| 117 DEBUG_ADD_REMOVE_DISPLAY, | |
| 118 DEBUG_SHOW_TOAST, | |
| 119 DEBUG_TOGGLE_TOUCH_PAD, | |
| 120 DEBUG_TOGGLE_TOUCH_SCREEN, | |
| 121 DEBUG_TOGGLE_TOUCH_VIEW, | |
| 122 DEBUG_TOGGLE_UNIFIED_DESKTOP, | |
| 123 DISABLE_CAPS_LOCK, | |
| 124 DISABLE_GPU_WATCHDOG, | |
| 125 KEYBOARD_BRIGHTNESS_DOWN, | |
| 126 KEYBOARD_BRIGHTNESS_UP, | |
| 127 LOCK_PRESSED, | |
| 128 LOCK_RELEASED, | |
| 129 LOCK_SCREEN, | |
| 130 OPEN_CROSH, | |
| 131 OPEN_FILE_MANAGER, | |
| 132 OPEN_GET_HELP, | |
| 133 POWER_PRESSED, | |
| 134 POWER_RELEASED, | |
| 135 SUSPEND, | |
| 136 SWAP_PRIMARY_DISPLAY, | |
| 137 SWITCH_TO_NEXT_USER, | |
| 138 SWITCH_TO_PREVIOUS_USER, | |
| 139 TOGGLE_CAPS_LOCK, | |
| 140 TOGGLE_MIRROR_MODE, | |
| 141 TOGGLE_SPOKEN_FEEDBACK, | |
| 142 TOGGLE_WIFI, | |
| 143 TOUCH_HUD_CLEAR, | |
| 144 TOUCH_HUD_MODE_CHANGE, | |
| 145 TOUCH_HUD_PROJECTION_TOGGLE, | |
| 146 VOLUME_DOWN, | |
| 147 VOLUME_MUTE, | |
| 148 VOLUME_UP, | |
| 149 #else | |
| 150 DUMMY_FOR_RESERVED, | |
| 151 #endif | |
| 152 }; | |
| 153 | |
| 154 struct AcceleratorData { | |
| 155 bool trigger_on_press; | |
| 156 ui::KeyboardCode keycode; | |
| 157 int modifiers; | |
| 158 AcceleratorAction action; | |
| 159 }; | |
| 160 | |
| 161 // Gathers the needed data to handle deprecated accelerators. | |
| 162 struct DeprecatedAcceleratorData { | |
| 163 // The action that has deprecated accelerators. | |
| 164 AcceleratorAction action; | |
| 165 | |
| 166 // The name of the UMA histogram that will be used to measure the deprecated | |
| 167 // v.s. new accelerator usage. | |
| 168 const char* uma_histogram_name; | |
| 169 | |
| 170 // The ID of the localized notification message to show to users informing | |
| 171 // them about the deprecation. | |
| 172 int notification_message_id; | |
| 173 | |
| 174 // The ID of the localized old deprecated shortcut key. | |
| 175 int old_shortcut_id; | |
| 176 | |
| 177 // The ID of the localized new shortcut key. | |
| 178 int new_shortcut_id; | |
| 179 | |
| 180 // Specifies whether the deprecated accelerator is still enabled to do its | |
| 181 // associated action. | |
| 182 bool deprecated_enabled; | |
| 183 }; | |
| 184 | |
| 185 // This will be used for the UMA stats to measure the how many users are using | |
| 186 // the old v.s. new accelerators. | |
| 187 enum DeprecatedAcceleratorUsage { | |
| 188 DEPRECATED_USED = 0, // The deprecated accelerator is used. | |
| 189 NEW_USED, // The new accelerator is used. | |
| 190 DEPRECATED_USAGE_COUNT, // Maximum value of this enum for histogram use. | |
| 191 }; | |
| 192 | |
| 193 // Accelerators handled by AcceleratorController. | |
| 194 ASH_EXPORT extern const AcceleratorData kAcceleratorData[]; | |
| 195 ASH_EXPORT extern const size_t kAcceleratorDataLength; | |
| 196 | |
| 197 #if defined(OS_CHROMEOS) | |
| 198 // The list of the deprecated accelerators. | |
| 199 ASH_EXPORT extern const AcceleratorData kDeprecatedAccelerators[]; | |
| 200 ASH_EXPORT extern const size_t kDeprecatedAcceleratorsLength; | |
| 201 | |
| 202 // The list of the actions with deprecated accelerators and the needed data to | |
| 203 // handle them. | |
| 204 ASH_EXPORT extern const DeprecatedAcceleratorData kDeprecatedAcceleratorsData[]; | |
| 205 ASH_EXPORT extern const size_t kDeprecatedAcceleratorsDataLength; | |
| 206 #endif // defined(OS_CHROMEOS) | |
| 207 | |
| 208 // Debug accelerators. Debug accelerators are only enabled when the "Debugging | |
| 209 // keyboard shortcuts" flag (--ash-debug-shortcuts) is enabled. Debug actions | |
| 210 // are always run (similar to reserved actions). | |
| 211 ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[]; | |
| 212 ASH_EXPORT extern const size_t kDebugAcceleratorDataLength; | |
| 213 | |
| 214 // Actions that should be handled very early in Ash unless the current target | |
| 215 // window is full-screen. | |
| 216 ASH_EXPORT extern const AcceleratorAction kPreferredActions[]; | |
| 217 ASH_EXPORT extern const size_t kPreferredActionsLength; | |
| 218 | |
| 219 // Actions that are always handled in Ash. | |
| 220 ASH_EXPORT extern const AcceleratorAction kReservedActions[]; | |
| 221 ASH_EXPORT extern const size_t kReservedActionsLength; | |
| 222 | |
| 223 // Actions allowed while user is not signed in or screen is locked. | |
| 224 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[]; | |
| 225 ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength; | |
| 226 | |
| 227 // Actions allowed while screen is locked (in addition to | |
| 228 // kActionsAllowedAtLoginOrLockScreen). | |
| 229 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[]; | |
| 230 ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength; | |
| 231 | |
| 232 // Actions allowed while a modal window is up. | |
| 233 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[]; | |
| 234 ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength; | |
| 235 | |
| 236 // Actions which may be repeated by holding an accelerator key. | |
| 237 ASH_EXPORT extern const AcceleratorAction kRepeatableActions[]; | |
| 238 ASH_EXPORT extern const size_t kRepeatableActionsLength; | |
| 239 | |
| 240 // Actions allowed in app mode or pinned mode. | |
| 241 ASH_EXPORT extern const AcceleratorAction | |
| 242 kActionsAllowedInAppModeOrPinnedMode[]; | |
| 243 ASH_EXPORT extern const size_t kActionsAllowedInAppModeOrPinnedModeLength; | |
| 244 | |
| 245 // Actions that can be performed in pinned mode. | |
| 246 // In pinned mode, the action listed this or "in app mode or pinned mode" table | |
| 247 // can be performed. | |
| 248 ASH_EXPORT extern const AcceleratorAction kActionsAllowedInPinnedMode[]; | |
| 249 ASH_EXPORT extern const size_t kActionsAllowedInPinnedModeLength; | |
| 250 | |
| 251 // Actions that require at least 1 window. | |
| 252 ASH_EXPORT extern const AcceleratorAction kActionsNeedingWindow[]; | |
| 253 ASH_EXPORT extern const size_t kActionsNeedingWindowLength; | |
| 254 | |
| 255 // Actions that can be performed while keeping the menu open. | |
| 256 ASH_EXPORT extern const AcceleratorAction kActionsKeepingMenuOpen[]; | |
| 257 ASH_EXPORT extern const size_t kActionsKeepingMenuOpenLength; | |
| 258 | |
| 259 } // namespace ash | |
| 260 | |
| 261 #endif // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_ | |
| OLD | NEW |