| 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 UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ | 5 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ |
| 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ | 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // First, AcceleratorPressed handler of the most recently registered target | 58 // First, AcceleratorPressed handler of the most recently registered target |
| 59 // is called, and if that handler processes the event (i.e. returns true), | 59 // is called, and if that handler processes the event (i.e. returns true), |
| 60 // this method immediately returns. If not, we do the same thing on the next | 60 // this method immediately returns. If not, we do the same thing on the next |
| 61 // target, and so on. | 61 // target, and so on. |
| 62 // Returns true if an accelerator was activated. | 62 // Returns true if an accelerator was activated. |
| 63 bool Process(const Accelerator& accelerator); | 63 bool Process(const Accelerator& accelerator); |
| 64 | 64 |
| 65 // Returns the AcceleratorTarget that should be activated for the specified | 65 // Returns the AcceleratorTarget that should be activated for the specified |
| 66 // keyboard accelerator, or NULL if no view is registered for that keyboard | 66 // keyboard accelerator, or NULL if no view is registered for that keyboard |
| 67 // accelerator. | 67 // accelerator. |
| 68 AcceleratorTarget* GetCurrentTarget(const Accelerator& accelertor) const; | 68 AcceleratorTarget* GetCurrentTarget(const Accelerator& accelerator) const; |
| 69 | 69 |
| 70 // Whether the given |accelerator| has a priority handler associated with it. | 70 // Whether the given |accelerator| has a priority handler associated with it. |
| 71 bool HasPriorityHandler(const Accelerator& accelerator) const; | 71 bool HasPriorityHandler(const Accelerator& accelerator) const; |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 // The accelerators and associated targets. | 74 // The accelerators and associated targets. |
| 75 typedef std::list<AcceleratorTarget*> AcceleratorTargetList; | 75 typedef std::list<AcceleratorTarget*> AcceleratorTargetList; |
| 76 // This construct pairs together a |bool| (denoting whether the list contains | 76 // This construct pairs together a |bool| (denoting whether the list contains |
| 77 // a priority_handler at the front) with the list of AcceleratorTargets. | 77 // a priority_handler at the front) with the list of AcceleratorTargets. |
| 78 typedef std::pair<bool, AcceleratorTargetList> AcceleratorTargets; | 78 typedef std::pair<bool, AcceleratorTargetList> AcceleratorTargets; |
| 79 typedef std::map<Accelerator, AcceleratorTargets> AcceleratorMap; | 79 typedef std::map<Accelerator, AcceleratorTargets> AcceleratorMap; |
| 80 AcceleratorMap accelerators_; | 80 AcceleratorMap accelerators_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(AcceleratorManager); | 82 DISALLOW_COPY_AND_ASSIGN(AcceleratorManager); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace ui | 85 } // namespace ui |
| 86 | 86 |
| 87 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ | 87 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_MANAGER_H_ |
| OLD | NEW |