Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / accelerators_cocoa.h
blobe29eefb9de9a6b6a72f2aeebca37f0872d5deabb
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_
8 #import <Cocoa/Cocoa.h>
10 #include <map>
11 #include <vector>
13 #include "base/gtest_prod_util.h"
14 #include "ui/base/accelerators/accelerator.h"
16 template <typename T> struct DefaultSingletonTraits;
18 // This class maintains a map of command_ids to Accelerator objects (see
19 // chrome/app/chrome_command_ids.h). Currently, this only lists the commands
20 // that are used in the Wrench menu.
22 // It is recommended that this class be used as a singleton so that the key map
23 // isn't created multiple places.
25 // #import "base/memory/singleton.h"
26 // ...
27 // AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
28 // return keymap->GetAcceleratorForCommand(IDC_COPY);
30 class AcceleratorsCocoa {
31 public:
32 typedef std::map<int, ui::Accelerator> AcceleratorMap;
33 typedef std::vector<ui::Accelerator> AcceleratorVector;
34 typedef AcceleratorMap::const_iterator const_iterator;
36 const_iterator const begin() { return accelerators_.begin(); }
37 const_iterator const end() { return accelerators_.end(); }
39 // Returns NULL if there is no accelerator for the command.
40 const ui::Accelerator* GetAcceleratorForCommand(int command_id);
41 // Searches the list of accelerators without a command_id for an accelerator
42 // that matches the given |key_equivalent| and |modifiers|.
43 const ui::Accelerator* GetAcceleratorForHotKey(NSString* key_equivalent,
44 NSUInteger modifiers) const;
46 // Returns the singleton instance.
47 static AcceleratorsCocoa* GetInstance();
49 private:
50 friend struct DefaultSingletonTraits<AcceleratorsCocoa>;
51 FRIEND_TEST_ALL_PREFIXES(AcceleratorsCocoaBrowserTest,
52 MappingAcceleratorsInMainMenu);
54 AcceleratorsCocoa();
55 ~AcceleratorsCocoa();
57 // A map from command_id to Accelerator. The accelerator is fully filled out,
58 // and its platform_accelerator is also fully filled out.
59 // Contains accelerators from both the wrench menu and the main menu.
60 AcceleratorMap accelerators_;
61 // A list of accelerators used in the main menu that have no associated
62 // command_id. The accelerator is fully filled out, and its
63 // platform_accelerator is also fully filled out.
64 AcceleratorVector accelerator_vector_;
66 DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa);
69 #endif // CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_