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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_
10 #include "ui/base/accelerators/accelerator.h"
12 template <typename T
> struct DefaultSingletonTraits
;
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
16 // that are used in the Wrench menu.
18 // It is recommended that this class be used as a singleton so that the key map
19 // isn't created multiple places.
21 // #import "base/memory/singleton.h"
23 // AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
24 // return keymap->GetAcceleratorForCommand(IDC_COPY);
26 class AcceleratorsCocoa
{
28 typedef std::map
<int, ui::Accelerator
> AcceleratorMap
;
29 typedef AcceleratorMap::const_iterator const_iterator
;
31 const_iterator
const begin() { return accelerators_
.begin(); }
32 const_iterator
const end() { return accelerators_
.end(); }
34 // Returns NULL if there is no accelerator for the command.
35 const ui::Accelerator
* GetAcceleratorForCommand(int command_id
);
37 // Returns the singleton instance.
38 static AcceleratorsCocoa
* GetInstance();
41 friend struct DefaultSingletonTraits
<AcceleratorsCocoa
>;
46 AcceleratorMap accelerators_
;
48 DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa
);
51 #endif // CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_