| 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_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 5 #ifndef ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| 6 #define ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 6 #define ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 void Register(const std::vector<ui::Accelerator>& accelerators, | 67 void Register(const std::vector<ui::Accelerator>& accelerators, |
| 68 ui::AcceleratorTarget* target); | 68 ui::AcceleratorTarget* target); |
| 69 | 69 |
| 70 // Unregisters the specified keyboard accelerator for the specified target. | 70 // Unregisters the specified keyboard accelerator for the specified target. |
| 71 void Unregister(const ui::Accelerator& accelerator, | 71 void Unregister(const ui::Accelerator& accelerator, |
| 72 ui::AcceleratorTarget* target); | 72 ui::AcceleratorTarget* target); |
| 73 | 73 |
| 74 // Unregisters all keyboard accelerators for the specified target. | 74 // Unregisters all keyboard accelerators for the specified target. |
| 75 void UnregisterAll(ui::AcceleratorTarget* target); | 75 void UnregisterAll(ui::AcceleratorTarget* target); |
| 76 | 76 |
| 77 // Returns true if there is an action for |accelerator| and it is enabled. |
| 78 bool IsActionForAcceleratorEnabled(const ui::Accelerator& accelerator) const; |
| 79 |
| 77 // Activates the target associated with the specified accelerator. | 80 // Activates the target associated with the specified accelerator. |
| 78 // First, AcceleratorPressed handler of the most recently registered target | 81 // First, AcceleratorPressed handler of the most recently registered target |
| 79 // is called, and if that handler processes the event (i.e. returns true), | 82 // is called, and if that handler processes the event (i.e. returns true), |
| 80 // this method immediately returns. If not, we do the same thing on the next | 83 // this method immediately returns. If not, we do the same thing on the next |
| 81 // target, and so on. | 84 // target, and so on. |
| 82 // Returns true if an accelerator was activated. | 85 // Returns true if an accelerator was activated. |
| 83 bool Process(const ui::Accelerator& accelerator); | 86 bool Process(const ui::Accelerator& accelerator); |
| 84 | 87 |
| 85 // Returns true if the |accelerator| is registered. | 88 // Returns true if the |accelerator| is registered. |
| 86 bool IsRegistered(const ui::Accelerator& accelerator) const; | 89 bool IsRegistered(const ui::Accelerator& accelerator) const; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Registers the specified accelerators. | 147 // Registers the specified accelerators. |
| 145 void RegisterAccelerators(const AcceleratorData accelerators[], | 148 void RegisterAccelerators(const AcceleratorData accelerators[], |
| 146 size_t accelerators_length); | 149 size_t accelerators_length); |
| 147 | 150 |
| 148 // Registers the deprecated accelerators and their replacing new ones. | 151 // Registers the deprecated accelerators and their replacing new ones. |
| 149 void RegisterDeprecatedAccelerators(); | 152 void RegisterDeprecatedAccelerators(); |
| 150 | 153 |
| 151 // Returns whether |action| can be performed. The |accelerator| may provide | 154 // Returns whether |action| can be performed. The |accelerator| may provide |
| 152 // additional data the action needs. | 155 // additional data the action needs. |
| 153 bool CanPerformAction(AcceleratorAction action, | 156 bool CanPerformAction(AcceleratorAction action, |
| 154 const ui::Accelerator& accelerator); | 157 const ui::Accelerator& accelerator) const; |
| 155 | 158 |
| 156 // Performs the specified action. The |accelerator| may provide additional | 159 // Performs the specified action. The |accelerator| may provide additional |
| 157 // data the action needs. | 160 // data the action needs. |
| 158 void PerformAction(AcceleratorAction action, | 161 void PerformAction(AcceleratorAction action, |
| 159 const ui::Accelerator& accelerator); | 162 const ui::Accelerator& accelerator); |
| 160 | 163 |
| 161 // Returns whether performing |action| should consume the key event. | 164 // Returns whether performing |action| should consume the key event. |
| 162 bool ShouldActionConsumeKeyEvent(AcceleratorAction action); | 165 bool ShouldActionConsumeKeyEvent(AcceleratorAction action); |
| 163 | 166 |
| 164 // Get the accelerator restriction for the given action. Supply an |action| | 167 // Get the accelerator restriction for the given action. Supply an |action| |
| 165 // of -1 to get restrictions that apply for the current context. | 168 // of -1 to get restrictions that apply for the current context. |
| 166 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( | 169 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( |
| 167 int action); | 170 int action) const; |
| 168 | 171 |
| 169 // If |accelerator| is a deprecated accelerator, it performs the appropriate | 172 // If |accelerator| is a deprecated accelerator, it performs the appropriate |
| 170 // deprecated accelerator pre-handling. | 173 // deprecated accelerator pre-handling. |
| 171 // Returns PROCEED if the accelerator's action should be performed (i.e. if | 174 // Returns PROCEED if the accelerator's action should be performed (i.e. if |
| 172 // |accelerator| is not a deprecated accelerator, or it's an enabled | 175 // |accelerator| is not a deprecated accelerator, or it's an enabled |
| 173 // deprecated accelerator), and STOP otherwise (if the accelerator is a | 176 // deprecated accelerator), and STOP otherwise (if the accelerator is a |
| 174 // disabled deprecated accelerator). | 177 // disabled deprecated accelerator). |
| 175 enum class AcceleratorProcessingStatus { PROCEED, STOP }; | 178 enum class AcceleratorProcessingStatus { PROCEED, STOP }; |
| 176 AcceleratorProcessingStatus MaybeDeprecatedAcceleratorPressed( | 179 AcceleratorProcessingStatus MaybeDeprecatedAcceleratorPressed( |
| 177 AcceleratorAction action, | 180 AcceleratorAction action, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 std::set<int> actions_needing_window_; | 228 std::set<int> actions_needing_window_; |
| 226 // Actions that can be performed without closing the menu (if one is present). | 229 // Actions that can be performed without closing the menu (if one is present). |
| 227 std::set<int> actions_keeping_menu_open_; | 230 std::set<int> actions_keeping_menu_open_; |
| 228 | 231 |
| 229 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 232 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
| 230 }; | 233 }; |
| 231 | 234 |
| 232 } // namespace ash | 235 } // namespace ash |
| 233 | 236 |
| 234 #endif // ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 237 #endif // ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| OLD | NEW |