Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/ui/cocoa/accelerators_cocoa.h

Issue 152643007: mac: Create a static mapping of accelerators in the main menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@acc_list
Patch Set: Yet more capitalization of cocoa. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import <Cocoa/Cocoa.h>
9
8 #include <map> 10 #include <map>
11 #include <vector>
9 12
13 #include "base/gtest_prod_util.h"
10 #include "ui/base/accelerators/accelerator.h" 14 #include "ui/base/accelerators/accelerator.h"
11 15
12 template <typename T> struct DefaultSingletonTraits; 16 template <typename T> struct DefaultSingletonTraits;
13 17
14 // This class maintains a map of command_ids to Accelerator objects (see 18 // 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 19 // chrome/app/chrome_command_ids.h). Currently, this only lists the commands
16 // that are used in the Wrench menu. 20 // that are used in the Wrench menu.
17 // 21 //
18 // It is recommended that this class be used as a singleton so that the key map 22 // It is recommended that this class be used as a singleton so that the key map
19 // isn't created multiple places. 23 // isn't created multiple places.
20 // 24 //
21 // #import "base/memory/singleton.h" 25 // #import "base/memory/singleton.h"
22 // ... 26 // ...
23 // AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance(); 27 // AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
24 // return keymap->GetAcceleratorForCommand(IDC_COPY); 28 // return keymap->GetAcceleratorForCommand(IDC_COPY);
25 // 29 //
26 class AcceleratorsCocoa { 30 class AcceleratorsCocoa {
27 public: 31 public:
28 typedef std::map<int, ui::Accelerator> AcceleratorMap; 32 typedef std::map<int, ui::Accelerator> AcceleratorMap;
33 typedef std::vector<ui::Accelerator> AcceleratorVector;
29 typedef AcceleratorMap::const_iterator const_iterator; 34 typedef AcceleratorMap::const_iterator const_iterator;
30 35
31 const_iterator const begin() { return accelerators_.begin(); } 36 const_iterator const begin() { return accelerators_.begin(); }
32 const_iterator const end() { return accelerators_.end(); } 37 const_iterator const end() { return accelerators_.end(); }
33 38
34 // Returns NULL if there is no accelerator for the command. 39 // Returns NULL if there is no accelerator for the command.
35 const ui::Accelerator* GetAcceleratorForCommand(int command_id); 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(
44 NSString* key_equivalent, NSUInteger modifiers) const;
Robert Sesek 2014/02/11 23:21:25 nit: indent 2 more spaces
erikchen 2014/02/11 23:34:08 went with the output of clang-format. On 2014/02/
36 45
37 // Returns the singleton instance. 46 // Returns the singleton instance.
38 static AcceleratorsCocoa* GetInstance(); 47 static AcceleratorsCocoa* GetInstance();
39 48
40 private: 49 private:
41 friend struct DefaultSingletonTraits<AcceleratorsCocoa>; 50 friend struct DefaultSingletonTraits<AcceleratorsCocoa>;
51 FRIEND_TEST_ALL_PREFIXES(AcceleratorsCocoaBrowserTest,
52 MappingAcceleratorsInMainMenu);
42 53
43 AcceleratorsCocoa(); 54 AcceleratorsCocoa();
44 ~AcceleratorsCocoa(); 55 ~AcceleratorsCocoa();
45 56
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.
46 AcceleratorMap accelerators_; 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_;
47 65
48 DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa); 66 DISALLOW_COPY_AND_ASSIGN(AcceleratorsCocoa);
49 }; 67 };
50 68
51 #endif // CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_ 69 #endif // CHROME_BROWSER_UI_COCOA_ACCELERATORS_COCOA_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/accelerators_cocoa.mm » ('j') | chrome/browser/ui/cocoa/accelerators_cocoa.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698