OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ui/base/accelerators/accelerator.h" | 10 #include "ui/base/accelerators/accelerator.h" |
11 | 11 |
12 template <typename T> struct DefaultSingletonTraits; | 12 template <typename T> struct DefaultSingletonTraits; |
13 | 13 |
14 // This class maintains a map of command_ids to Accelerator objects (see | 14 // This class maintains a map of command_ids to Accelerator objects (see |
15 // chrome/app/chrome_command_ids.h). Currently, this only lists the commands | 15 // chrome/app/chrome_command_ids.h). Currently, this only lists the commands |
16 // that are used in the Wrench menu. | 16 // that are used in the Wrench menu. |
17 // | 17 // |
18 // It is recommended that this class be used as a singleton so that the key map | 18 // It is recommended that this class be used as a singleton so that the key map |
19 // isn't created multiple places. | 19 // isn't created multiple places. |
20 // | 20 // |
21 // #import "base/memory/singleton.h" | 21 // #import "base/memory/singleton.h" |
22 // ... | 22 // ... |
23 // AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance(); | 23 // AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance(); |
24 // return keymap->GetAcceleratorForCommand(IDC_COPY); | 24 // return keymap->GetAcceleratorForCommand(IDC_COPY); |
25 // | 25 // |
26 class AcceleratorsCocoa { | 26 class AcceleratorsCocoa { |
27 public: | 27 public: |
28 typedef std::map<int, ui::Accelerator> AcceleratorMap; | 28 typedef std::map<int, ui::Accelerator> AcceleratorMap; |
| 29 typedef AcceleratorMap::const_iterator const_iterator; |
| 30 |
| 31 const_iterator const begin() { return accelerators_.begin(); } |
| 32 const_iterator const end() { return accelerators_.end(); } |
29 | 33 |
30 // Returns NULL if there is no accelerator for the command. | 34 // Returns NULL if there is no accelerator for the command. |
31 const ui::Accelerator* GetAcceleratorForCommand(int command_id); | 35 const ui::Accelerator* GetAcceleratorForCommand(int command_id); |
32 | 36 |
33 // Returns the singleton instance. | 37 // Returns the singleton instance. |
34 static AcceleratorsCocoa* GetInstance(); | 38 static AcceleratorsCocoa* GetInstance(); |
35 | 39 |
36 private: | 40 private: |
37 friend struct DefaultSingletonTraits<AcceleratorsCocoa>; | 41 friend struct DefaultSingletonTraits<AcceleratorsCocoa>; |
38 | 42 |
39 AcceleratorsCocoa(); | 43 AcceleratorsCocoa(); |
40 ~AcceleratorsCocoa(); | 44 ~AcceleratorsCocoa(); |
41 | 45 |
42 AcceleratorMap accelerators_; | 46 AcceleratorMap accelerators_; |
43 | 47 |
44 DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa); | 48 DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa); |
45 }; | 49 }; |
46 | 50 |
47 #endif // CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ | 51 #endif // CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ |
OLD | NEW |