accelerator_table.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #ifndef ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
  5. #define ASH_ACCELERATORS_ACCELERATOR_TABLE_H_
  6. #include <stddef.h>
  7. #include "ash/ash_export.h"
  8. #include "ash/public/cpp/accelerators.h"
  9. #include "ui/events/event_constants.h"
  10. #include "ui/events/keycodes/keyboard_codes.h"
  11. namespace ash {
  12. // The complete list of Ash accelerators is in ash/public/cpp/accelerators.h.
  13. // This file mainly keeps track of special categories of accelerator.
  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. // Gathers the needed data to handle deprecated accelerators.
  51. struct DeprecatedAcceleratorData {
  52. // The action that has deprecated accelerators.
  53. AcceleratorAction action;
  54. // The name of the UMA histogram that will be used to measure the deprecated
  55. // v.s. new accelerator usage.
  56. const char* uma_histogram_name;
  57. // The ID of the localized notification message to show to users informing
  58. // them about the deprecation.
  59. int notification_message_id;
  60. // The ID of the localized old deprecated shortcut key.
  61. int old_shortcut_id;
  62. // The ID of the localized new shortcut key.
  63. int new_shortcut_id;
  64. // Specifies whether the deprecated accelerator is still enabled to do its
  65. // associated action.
  66. bool deprecated_enabled;
  67. };
  68. // This will be used for the UMA stats to measure the how many users are using
  69. // the old v.s. new accelerators.
  70. enum DeprecatedAcceleratorUsage {
  71. DEPRECATED_USED = 0, // The deprecated accelerator is used.
  72. NEW_USED, // The new accelerator is used.
  73. DEPRECATED_USAGE_COUNT, // Maximum value of this enum for histogram use.
  74. };
  75. // The list of the deprecated accelerators.
  76. ASH_EXPORT extern const AcceleratorData kDeprecatedAccelerators[];
  77. ASH_EXPORT extern const size_t kDeprecatedAcceleratorsLength;
  78. // The list of the actions with deprecated accelerators and the needed data to
  79. // handle them.
  80. ASH_EXPORT extern const DeprecatedAcceleratorData kDeprecatedAcceleratorsData[];
  81. ASH_EXPORT extern const size_t kDeprecatedAcceleratorsDataLength;
  82. // Debug accelerators. Debug accelerators are only enabled when the "Debugging
  83. // keyboard shortcuts" flag (--ash-debug-shortcuts) is enabled. Debug actions
  84. // are always run (similar to reserved actions). Debug accelerators can be
  85. // enabled in about:flags.
  86. ASH_EXPORT extern const AcceleratorData kDebugAcceleratorData[];
  87. ASH_EXPORT extern const size_t kDebugAcceleratorDataLength;
  88. // Developer accelerators that are enabled only with the command-line switch
  89. // --ash-dev-shortcuts. They are always run similar to reserved actions.
  90. ASH_EXPORT extern const AcceleratorData kDeveloperAcceleratorData[];
  91. ASH_EXPORT extern const size_t kDeveloperAcceleratorDataLength;
  92. // Actions that should be handled very early in Ash unless the current target
  93. // window is full-screen.
  94. ASH_EXPORT extern const AcceleratorAction kPreferredActions[];
  95. ASH_EXPORT extern const size_t kPreferredActionsLength;
  96. // Actions that are always handled in Ash.
  97. ASH_EXPORT extern const AcceleratorAction kReservedActions[];
  98. ASH_EXPORT extern const size_t kReservedActionsLength;
  99. // Actions allowed while user is not signed in or screen is locked.
  100. ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[];
  101. ASH_EXPORT extern const size_t kActionsAllowedAtLoginOrLockScreenLength;
  102. // Actions allowed while screen is locked (in addition to
  103. // kActionsAllowedAtLoginOrLockScreen).
  104. ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtLockScreen[];
  105. ASH_EXPORT extern const size_t kActionsAllowedAtLockScreenLength;
  106. // Actions allowed while power menu is opened.
  107. ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtPowerMenu[];
  108. ASH_EXPORT extern const size_t kActionsAllowedAtPowerMenuLength;
  109. // Actions allowed while a modal window is up.
  110. ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[];
  111. ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength;
  112. // Actions which may be repeated by holding an accelerator key.
  113. ASH_EXPORT extern const AcceleratorAction kRepeatableActions[];
  114. ASH_EXPORT extern const size_t kRepeatableActionsLength;
  115. // Actions allowed in app mode or pinned mode.
  116. ASH_EXPORT extern const AcceleratorAction
  117. kActionsAllowedInAppModeOrPinnedMode[];
  118. ASH_EXPORT extern const size_t kActionsAllowedInAppModeOrPinnedModeLength;
  119. // Actions that can be performed in pinned mode.
  120. // In pinned mode, the action listed in this or "in app mode or pinned mode"
  121. // table can be performed.
  122. ASH_EXPORT extern const AcceleratorAction kActionsAllowedInPinnedMode[];
  123. ASH_EXPORT extern const size_t kActionsAllowedInPinnedModeLength;
  124. // Actions that can be performed in app mode.
  125. // In app mode, the action listed in this or "in app mode or pinned mode" table
  126. // can be performed.
  127. ASH_EXPORT extern const AcceleratorAction kActionsAllowedInAppMode[];
  128. ASH_EXPORT extern const size_t kActionsAllowedInAppModeLength;
  129. // Actions that require at least 1 window.
  130. ASH_EXPORT extern const AcceleratorAction kActionsNeedingWindow[];
  131. ASH_EXPORT extern const size_t kActionsNeedingWindowLength;
  132. // Actions that can be performed while keeping the menu open.
  133. ASH_EXPORT extern const AcceleratorAction kActionsKeepingMenuOpen[];
  134. ASH_EXPORT extern const size_t kActionsKeepingMenuOpenLength;
  135. // Actions that are duplicated with browser shortcuts.
  136. ASH_EXPORT extern const AcceleratorAction kActionsDuplicatedWithBrowser[];
  137. ASH_EXPORT extern const size_t kActionsDuplicatedWithBrowserLength;
  138. // Actions that are interceptable by browser.
  139. // These actions are ash's shortcuts, but they are sent to the browser
  140. // once in order to make it interceptable by webpage/apps.
  141. ASH_EXPORT extern const AcceleratorAction kActionsInterceptableByBrowser[];
  142. ASH_EXPORT extern const size_t kActionsInterceptableByBrowserLength;
  143. } // namespace ash
  144. #endif // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_