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

Side by Side Diff: chrome/browser/extensions/global_shortcut_listener_mac.h

Issue 60353008: Mac global keybindings (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 1 month 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_
6 #define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_ 6 #define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_
7 7
8 #include "chrome/browser/extensions/global_shortcut_listener.h"
9
10 #include <set>
Robert Sesek 2013/11/18 15:25:03 #include <map> since you use it.
smus 2013/11/18 23:13:41 Done.
11 #include <IOKit/hidsystem/ev_keymap.h>
Robert Sesek 2013/11/18 15:25:03 IOKit/IOKit.h Does this need to be in the .h?
smus 2013/11/18 23:13:41 Moved to .mm, but unfortunately IOKit/IOKit.h does
12 #include <Carbon/Carbon.h>
Robert Sesek 2013/11/18 15:25:03 Same. Does this need to be in the .h?
smus 2013/11/18 23:13:41 Yes, this provides EventHotKeyRef
13
14 #include "ApplicationServices/ApplicationServices.h"
Robert Sesek 2013/11/18 15:25:03 This is a system header, so it should be in <>. Do
smus 2013/11/18 23:13:41 Moved to .mm and changed to <> syntax.
8 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
9 #include "chrome/browser/extensions/global_shortcut_listener.h" 16 #include "base/mac/scoped_nsobject.h"
17
18 @class GlobalShortcutListenerTap;
10 19
11 namespace extensions { 20 namespace extensions {
12 21
13 // Mac-specific implementation of the GlobalShortcutListener class that 22 // Mac-specific implementation of the GlobalShortcutListener class that
14 // listens for global shortcuts. Handles basic keyboard intercepting and 23 // listens for global shortcuts. Handles basic keyboard intercepting and
15 // forwards its output to the base class for processing. 24 // forwards its output to the base class for processing.
16 // TODO(finnur/smus): Implement this class. 25 // TODO(finnur/smus): Implement this class.
Robert Sesek 2013/11/18 15:25:03 This comment should be revised. It should also det
smus 2013/11/18 23:13:41 Done.
17 class GlobalShortcutListenerMac : public GlobalShortcutListener { 26 class GlobalShortcutListenerMac : public GlobalShortcutListener {
18 public: 27 public:
19 virtual ~GlobalShortcutListenerMac(); 28 virtual ~GlobalShortcutListenerMac();
20 29
21 virtual void StartListening() OVERRIDE; 30 virtual void StartListening() OVERRIDE;
22 virtual void StopListening() OVERRIDE; 31 virtual void StopListening() OVERRIDE;
23 32
33 // Keyboard event callbacks.
34 bool OnKeyEvent(EventHotKeyID hotKeyID);
35 bool OnMediaKeyEvent(ui::KeyboardCode keyCode);
36
37
Finnur 2013/11/18 11:55:57 nit: Remove line break.
smus 2013/11/18 23:13:41 Done.
24 private: 38 private:
25 friend struct base::DefaultLazyInstanceTraits<GlobalShortcutListenerMac>; 39 friend struct base::DefaultLazyInstanceTraits<GlobalShortcutListenerMac>;
26 40
27 GlobalShortcutListenerMac(); 41 GlobalShortcutListenerMac();
28 42
29 // Register an |accelerator| with the particular |observer|. 43 // Register an |accelerator| with the particular |observer|.
30 virtual void RegisterAccelerator( 44 virtual void RegisterAccelerator(
31 const ui::Accelerator& accelerator, 45 const ui::Accelerator& accelerator,
32 GlobalShortcutListener::Observer* observer) OVERRIDE; 46 GlobalShortcutListener::Observer* observer) OVERRIDE;
33 // Unregister an |accelerator| with the particular |observer|. 47 // Unregister an |accelerator| with the particular |observer|.
34 virtual void UnregisterAccelerator( 48 virtual void UnregisterAccelerator(
35 const ui::Accelerator& accelerator, 49 const ui::Accelerator& accelerator,
36 GlobalShortcutListener::Observer* observer) OVERRIDE; 50 GlobalShortcutListener::Observer* observer) OVERRIDE;
37 51
52 // Mac-specific function for registering a hotkey.
53 void RegisterHotKey(ui::Accelerator accelerator);
Robert Sesek 2013/11/18 15:25:03 Make these be const& parameters.
smus 2013/11/18 23:13:41 Done.
54 void UnregisterHotKey(ui::Accelerator accelerator);
55
38 // Whether this object is listening for global shortcuts. 56 // Whether this object is listening for global shortcuts.
39 bool is_listening_; 57 bool is_listening_;
58 int hotkey_id = 0;
Finnur 2013/11/18 11:55:57 nit: Add line break and comment. Also, why not tra
smus 2013/11/18 23:13:41 Done.
59
60 // A map of registered accelerators and their registration ids.
61 // TODO: Consider using a bimap structure instead.
Finnur 2013/11/18 11:55:57 style: All TODOs need an actor, e.g.: // TODO(smus
smus 2013/11/18 23:13:41 Done.
62 typedef std::map< ui::Accelerator, int > HotkeyIdMap;
63 HotkeyIdMap hotkey_ids_;
64 typedef std::map< int, ui::Accelerator > IdHotkeyMap;
65 IdHotkeyMap id_hotkeys_;
66
67 // A map of hot key refs so they can be unregistered later.
Finnur 2013/11/18 11:55:57 nit: hot key? or hotkey? :)
smus 2013/11/18 23:13:41 hotkey!!!
68 typedef std::map< int, EventHotKeyRef > IdHotkeyRefMap;
69 IdHotkeyRefMap id_hotkey_refs_;
Finnur 2013/11/18 11:55:57 That's a lot of maps, Mr. Magellan. It would be go
smus 2013/11/18 23:13:41 Ok, documented. I could have used one fewer map bu
70
71
Finnur 2013/11/18 11:55:57 nit: Remove line break.
smus 2013/11/18 23:13:41 Done.
72 // A pointer to the global shortcut listener tap.
Finnur 2013/11/18 11:55:57 This is kind of self-evident from the code. It wou
smus 2013/11/18 23:13:41 Done.
73 base::scoped_nsobject<GlobalShortcutListenerTap> tap_;
40 74
41 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerMac); 75 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerMac);
42 }; 76 };
43 77
44 } // namespace extensions 78 } // namespace extensions
45 79
46 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_ 80 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698