| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 5 #ifndef ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| 6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Returns true if the |accelerator| is preferred. A preferred accelerator | 82 // Returns true if the |accelerator| is preferred. A preferred accelerator |
| 83 // is handled before being passed to an window/web contents, unless | 83 // is handled before being passed to an window/web contents, unless |
| 84 // the window is in fullscreen state. | 84 // the window is in fullscreen state. |
| 85 bool IsPreferred(const ui::Accelerator& accelerator) const; | 85 bool IsPreferred(const ui::Accelerator& accelerator) const; |
| 86 | 86 |
| 87 // Returns true if the |accelerator| is reserved. A reserved accelerator | 87 // Returns true if the |accelerator| is reserved. A reserved accelerator |
| 88 // is always handled and will never be passed to an window/web contents. | 88 // is always handled and will never be passed to an window/web contents. |
| 89 bool IsReserved(const ui::Accelerator& accelerator) const; | 89 bool IsReserved(const ui::Accelerator& accelerator) const; |
| 90 | 90 |
| 91 // Returns true if the |accelerator| is deprecated. Deprecated accelerators |
| 92 // can be consumed by web contents if needed. |
| 93 bool IsDeprecated(const ui::Accelerator& accelerator) const; |
| 94 |
| 91 // Performs the specified action if it is enabled. Returns whether the action | 95 // Performs the specified action if it is enabled. Returns whether the action |
| 92 // was performed successfully. | 96 // was performed successfully. |
| 93 bool PerformActionIfEnabled(AcceleratorAction action); | 97 bool PerformActionIfEnabled(AcceleratorAction action); |
| 94 | 98 |
| 95 // Returns the restriction for the current context. | 99 // Returns the restriction for the current context. |
| 96 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); | 100 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); |
| 97 | 101 |
| 98 void SetBrightnessControlDelegate( | 102 void SetBrightnessControlDelegate( |
| 99 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); | 103 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); |
| 100 void SetImeControlDelegate( | 104 void SetImeControlDelegate( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 126 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, | 130 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, |
| 127 DontRepeatToggleFullscreen); | 131 DontRepeatToggleFullscreen); |
| 128 | 132 |
| 129 // Initializes the accelerators this class handles as a target. | 133 // Initializes the accelerators this class handles as a target. |
| 130 void Init(); | 134 void Init(); |
| 131 | 135 |
| 132 // Registers the specified accelerators. | 136 // Registers the specified accelerators. |
| 133 void RegisterAccelerators(const AcceleratorData accelerators[], | 137 void RegisterAccelerators(const AcceleratorData accelerators[], |
| 134 size_t accelerators_length); | 138 size_t accelerators_length); |
| 135 | 139 |
| 140 // Registers the deprecated and their replacing accelerators. |
| 141 void RegisterDeprecatedAccelerators( |
| 142 const DeprecatedAcceleratorData deprecated_accelerators[], |
| 143 size_t length); |
| 144 |
| 136 // Returns whether |action| can be performed. The |accelerator| may provide | 145 // Returns whether |action| can be performed. The |accelerator| may provide |
| 137 // additional data the action needs. | 146 // additional data the action needs. |
| 138 bool CanPerformAction(AcceleratorAction action, | 147 bool CanPerformAction(AcceleratorAction action, |
| 139 const ui::Accelerator& accelerator); | 148 const ui::Accelerator& accelerator); |
| 140 | 149 |
| 141 // Performs the specified action. The |accelerator| may provide additional | 150 // Performs the specified action. The |accelerator| may provide additional |
| 142 // data the action needs. | 151 // data the action needs. |
| 143 void PerformAction(AcceleratorAction action, | 152 void PerformAction(AcceleratorAction action, |
| 144 const ui::Accelerator& accelerator); | 153 const ui::Accelerator& accelerator); |
| 145 | 154 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 169 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 178 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; |
| 170 | 179 |
| 171 // Handles the exit accelerator which requires a double press to exit and | 180 // Handles the exit accelerator which requires a double press to exit and |
| 172 // shows a popup with an explanation. | 181 // shows a popup with an explanation. |
| 173 ExitWarningHandler exit_warning_handler_; | 182 ExitWarningHandler exit_warning_handler_; |
| 174 | 183 |
| 175 // A map from accelerators to the AcceleratorAction values, which are used in | 184 // A map from accelerators to the AcceleratorAction values, which are used in |
| 176 // the implementation. | 185 // the implementation. |
| 177 std::map<ui::Accelerator, AcceleratorAction> accelerators_; | 186 std::map<ui::Accelerator, AcceleratorAction> accelerators_; |
| 178 | 187 |
| 188 std::map<AcceleratorAction, const DeprecatedAcceleratorData*> |
| 189 actions_with_deprecations_; |
| 190 std::set<ui::Accelerator> deprecated_accelerators_; |
| 191 |
| 179 // Actions allowed when the user is not signed in. | 192 // Actions allowed when the user is not signed in. |
| 180 std::set<int> actions_allowed_at_login_screen_; | 193 std::set<int> actions_allowed_at_login_screen_; |
| 181 // Actions allowed when the screen is locked. | 194 // Actions allowed when the screen is locked. |
| 182 std::set<int> actions_allowed_at_lock_screen_; | 195 std::set<int> actions_allowed_at_lock_screen_; |
| 183 // Actions allowed when a modal window is up. | 196 // Actions allowed when a modal window is up. |
| 184 std::set<int> actions_allowed_at_modal_window_; | 197 std::set<int> actions_allowed_at_modal_window_; |
| 185 // Preferred actions. See accelerator_table.h for details. | 198 // Preferred actions. See accelerator_table.h for details. |
| 186 std::set<int> preferred_actions_; | 199 std::set<int> preferred_actions_; |
| 187 // Reserved actions. See accelerator_table.h for details. | 200 // Reserved actions. See accelerator_table.h for details. |
| 188 std::set<int> reserved_actions_; | 201 std::set<int> reserved_actions_; |
| 189 // Actions which will not be repeated while holding the accelerator key. | 202 // Actions which will not be repeated while holding the accelerator key. |
| 190 std::set<int> nonrepeatable_actions_; | 203 std::set<int> nonrepeatable_actions_; |
| 191 // Actions allowed in app mode. | 204 // Actions allowed in app mode. |
| 192 std::set<int> actions_allowed_in_app_mode_; | 205 std::set<int> actions_allowed_in_app_mode_; |
| 193 // Actions disallowed if there are no windows. | 206 // Actions disallowed if there are no windows. |
| 194 std::set<int> actions_needing_window_; | 207 std::set<int> actions_needing_window_; |
| 195 | 208 |
| 196 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 209 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
| 197 }; | 210 }; |
| 198 | 211 |
| 199 } // namespace ash | 212 } // namespace ash |
| 200 | 213 |
| 201 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 214 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| OLD | NEW |