Home | History | Annotate | Download | only in accelerators
      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 
     13 namespace ash {
     14 
     15 // There are five classes of accelerators in Ash:
     16 //
     17 // Ash (OS) reserved:
     18 // * Neither packaged apps nor web pages can cancel.
     19 // * For example, power button.
     20 // * See kReservedActions below.
     21 //
     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.
     26 //
     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.
     32 //
     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.
     38 //
     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.
     43 //
     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.
     46 //
     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.
     50 //
     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   BRIGHTNESS_DOWN,
     57   BRIGHTNESS_UP,
     58   CYCLE_BACKWARD_MRU,
     59   CYCLE_FORWARD_MRU,
     60   DEBUG_TOGGLE_DEVICE_SCALE_FACTOR,
     61   DEBUG_TOGGLE_SHOW_DEBUG_BORDERS,
     62   DEBUG_TOGGLE_SHOW_FPS_COUNTER,
     63   DEBUG_TOGGLE_SHOW_PAINT_RECTS,
     64   DISABLE_CAPS_LOCK,
     65   EXIT,
     66   FOCUS_NEXT_PANE,
     67   FOCUS_PREVIOUS_PANE,
     68   FOCUS_SHELF,
     69   KEYBOARD_BRIGHTNESS_DOWN,
     70   KEYBOARD_BRIGHTNESS_UP,
     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   LOCK_PRESSED,
     81   LOCK_RELEASED,
     82   MAGNIFY_SCREEN_ZOOM_IN,
     83   MAGNIFY_SCREEN_ZOOM_OUT,
     84   MEDIA_NEXT_TRACK,
     85   MEDIA_PLAY_PAUSE,
     86   MEDIA_PREV_TRACK,
     87   NEW_INCOGNITO_WINDOW,
     88   NEW_TAB,
     89   NEW_WINDOW,
     90   NEXT_IME,
     91   OPEN_FEEDBACK_PAGE,
     92   POWER_PRESSED,
     93   POWER_RELEASED,
     94   PREVIOUS_IME,
     95   PRINT_LAYER_HIERARCHY,
     96   PRINT_UI_HIERARCHIES,
     97   PRINT_VIEW_HIERARCHY,
     98   PRINT_WINDOW_HIERARCHY,
     99   RESTORE_TAB,
    100   ROTATE_SCREEN,
    101   ROTATE_WINDOW,
    102   SCALE_UI_DOWN,
    103   SCALE_UI_RESET,
    104   SCALE_UI_UP,
    105   SHOW_KEYBOARD_OVERLAY,
    106   SHOW_MESSAGE_CENTER_BUBBLE,
    107   SHOW_SYSTEM_TRAY_BUBBLE,
    108   SHOW_TASK_MANAGER,
    109   SILENCE_SPOKEN_FEEDBACK,
    110   SWAP_PRIMARY_DISPLAY,
    111   SWITCH_IME,  // Switch to another IME depending on the accelerator.
    112   TAKE_PARTIAL_SCREENSHOT,
    113   TAKE_SCREENSHOT,
    114   TOGGLE_APP_LIST,
    115   TOGGLE_CAPS_LOCK,
    116   TOGGLE_CAPS_LOCK_BY_ALT_LWIN,
    117   TOGGLE_DESKTOP_BACKGROUND_MODE,
    118   TOGGLE_FULLSCREEN,
    119   TOGGLE_MAXIMIZED,
    120   TOGGLE_OVERVIEW,
    121   TOGGLE_ROOT_WINDOW_FULL_SCREEN,
    122   TOGGLE_SPOKEN_FEEDBACK,
    123   TOGGLE_TOUCH_VIEW_TESTING,
    124   TOGGLE_WIFI,
    125   TOUCH_HUD_CLEAR,
    126   TOUCH_HUD_MODE_CHANGE,
    127   TOUCH_HUD_PROJECTION_TOGGLE,
    128   VOLUME_DOWN,
    129   VOLUME_MUTE,
    130   VOLUME_UP,
    131   WINDOW_MINIMIZE,
    132   WINDOW_POSITION_CENTER,
    133   WINDOW_SNAP_LEFT,
    134   WINDOW_SNAP_RIGHT,
    135 #if defined(OS_CHROMEOS)
    136   ADD_REMOVE_DISPLAY,
    137   TOGGLE_MIRROR_MODE,
    138   DISABLE_GPU_WATCHDOG,
    139   LOCK_SCREEN,
    140   OPEN_CROSH,
    141   OPEN_FILE_MANAGER,
    142   SWITCH_TO_NEXT_USER,
    143   SWITCH_TO_PREVIOUS_USER,
    144 #else
    145   DUMMY_FOR_RESERVED,
    146 #endif
    147 };
    148 
    149 struct AcceleratorData {
    150   bool trigger_on_press;
    151   ui::KeyboardCode keycode;
    152   int modifiers;
    153   AcceleratorAction action;
    154 };
    155 
    156 // Accelerators handled by AcceleratorController.
    157 ASH_EXPORT extern const AcceleratorData kAcceleratorData[];
    158 ASH_EXPORT extern const size_t kAcceleratorDataLength;
    159 
    160 #if !defined(NDEBUG)
    161 // Accelerators useful when running on desktop. Debug build only.
    162 ASH_EXPORT extern const AcceleratorData kDesktopAcceleratorData[];
    163 ASH_EXPORT extern const size_t kDesktopAcceleratorDataLength;
    164 #endif
    165 
    166 // Debug accelerators enabled only when "Debugging keyboard shortcuts" flag
    167 // (--ash-debug-shortcuts) is enabled.
    168 ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[];
    169 ASH_EXPORT extern const size_t kDebugAcceleratorDataLength;
    170 
    171 // Actions that should be handled very early in Ash unless the current target
    172 // window is full-screen.
    173 ASH_EXPORT extern const AcceleratorAction kPreferredActions[];
    174 ASH_EXPORT extern const size_t kPreferredActionsLength;
    175 
    176 // Actions that are always handled in Ash.
    177 ASH_EXPORT extern const AcceleratorAction kReservedActions[];
    178 ASH_EXPORT extern const size_t kReservedActionsLength;
    179 
    180 // Actions that should be handled very early in Ash unless the current target
    181 // window is full-screen, these actions are only handled if
    182 // DebugShortcutsEnabled is true (command line switch 'ash-debug-shortcuts').
    183 ASH_EXPORT extern const AcceleratorAction kReservedDebugActions[];
    184 ASH_EXPORT extern const size_t kReservedDebugActionsLength;
    185 
    186 // Actions allowed while user is not signed in or screen is locked.
    187 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[];
    188 ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength;
    189 
    190 // Actions allowed while screen is locked (in addition to
    191 // kActionsAllowedAtLoginOrLockScreen).
    192 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[];
    193 ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength;
    194 
    195 // Actions allowed while a modal window is up.
    196 ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[];
    197 ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength;
    198 
    199 // Actions which will not be repeated while holding an accelerator key.
    200 ASH_EXPORT extern const AcceleratorAction kNonrepeatableActions[];
    201 ASH_EXPORT extern const size_t kNonrepeatableActionsLength;
    202 
    203 // Actions allowed in app mode.
    204 ASH_EXPORT extern const AcceleratorAction kActionsAllowedInAppMode[];
    205 ASH_EXPORT extern const size_t kActionsAllowedInAppModeLength;
    206 
    207 // Actions that require at least 1 window.
    208 ASH_EXPORT extern const AcceleratorAction kActionsNeedingWindow[];
    209 ASH_EXPORT extern const size_t kActionsNeedingWindowLength;
    210 
    211 }  // namespace ash
    212 
    213 #endif  // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
    214