| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HISTORY_H_ | 5 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_HISTORY_H_ |
| 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_HISTORY_H_ | 6 #define UI_BASE_ACCELERATORS_ACCELERATOR_HISTORY_H_ |
| 7 | 7 |
| 8 #include <set> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/singleton.h" | |
| 10 #include "ui/base/accelerators/accelerator.h" | 11 #include "ui/base/accelerators/accelerator.h" |
| 11 #include "ui/base/ui_base_export.h" | 12 #include "ui/base/ui_base_export.h" |
| 12 #include "ui/events/event.h" | |
| 13 #include "ui/events/event_handler.h" | |
| 14 | 13 |
| 15 namespace ui { | 14 namespace ui { |
| 16 | 15 |
| 17 // Keeps track of the system-wide current and the most recent previous | 16 // Keeps track of the system-wide current and the most recent previous |
| 18 // key accelerators. | 17 // key accelerators. |
| 19 class UI_BASE_EXPORT AcceleratorHistory { | 18 class UI_BASE_EXPORT AcceleratorHistory { |
| 20 public: | 19 public: |
| 21 AcceleratorHistory(); | 20 AcceleratorHistory(); |
| 22 ~AcceleratorHistory(); | 21 ~AcceleratorHistory(); |
| 23 | 22 |
| 24 // Returns the most recent recorded accelerator. | 23 // Returns the most recent recorded accelerator. |
| 25 const Accelerator& current_accelerator() const { | 24 const Accelerator& current_accelerator() const { |
| 26 return current_accelerator_; | 25 return current_accelerator_; |
| 27 } | 26 } |
| 28 | 27 |
| 29 // Returns the most recent previously recorded accelerator that is different | 28 // Returns the most recent previously recorded accelerator that is different |
| 30 // than the current. | 29 // than the current. |
| 31 const Accelerator& previous_accelerator() const { | 30 const Accelerator& previous_accelerator() const { |
| 32 return previous_accelerator_; | 31 return previous_accelerator_; |
| 33 } | 32 } |
| 34 | 33 |
| 35 // Stores the given |accelerator| only if it's different than the currently | 34 // Stores the given |accelerator| only if it's different than the currently |
| 36 // stored one. | 35 // stored one. |
| 37 void StoreCurrentAccelerator(const Accelerator& accelerator); | 36 void StoreCurrentAccelerator(const Accelerator& accelerator); |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 Accelerator current_accelerator_; | 39 Accelerator current_accelerator_; |
| 41 Accelerator previous_accelerator_; | 40 Accelerator previous_accelerator_; |
| 42 | 41 |
| 42 std::set<KeyboardCode> currently_pressed_keys_; |
| 43 |
| 43 DISALLOW_COPY_AND_ASSIGN(AcceleratorHistory); | 44 DISALLOW_COPY_AND_ASSIGN(AcceleratorHistory); |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 }; // namespace ui | 47 }; // namespace ui |
| 47 | 48 |
| 48 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_HISTORY_H_ | 49 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_HISTORY_H_ |
| OLD | NEW |