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

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>
11 #include <IOKit/hidsystem/ev_keymap.h>
12
13 #include "ApplicationServices/ApplicationServices.h"
8 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
9 #include "chrome/browser/extensions/global_shortcut_listener.h" 15 #include "base/mac/scoped_nsobject.h"
16
17 @class GlobalShortcutListenerTap;
10 18
11 namespace extensions { 19 namespace extensions {
12 20
13 // Mac-specific implementation of the GlobalShortcutListener class that 21 // Mac-specific implementation of the GlobalShortcutListener class that
14 // listens for global shortcuts. Handles basic keyboard intercepting and 22 // listens for global shortcuts. Handles basic keyboard intercepting and
15 // forwards its output to the base class for processing. 23 // forwards its output to the base class for processing.
16 // TODO(finnur/smus): Implement this class. 24 // TODO(finnur/smus): Implement this class.
17 class GlobalShortcutListenerMac : public GlobalShortcutListener { 25 class GlobalShortcutListenerMac : public GlobalShortcutListener {
18 public: 26 public:
19 virtual ~GlobalShortcutListenerMac(); 27 virtual ~GlobalShortcutListenerMac();
20 28
21 virtual void StartListening() OVERRIDE; 29 virtual void StartListening() OVERRIDE;
22 virtual void StopListening() OVERRIDE; 30 virtual void StopListening() OVERRIDE;
23 31
32 // Keyboard event callbacks.
33 bool OnKeyEvent(ui::KeyboardCode keyCode, int modifiers);
34 bool OnMediaKeyEvent(ui::KeyboardCode keyCode);
35
36
24 private: 37 private:
25 friend struct base::DefaultLazyInstanceTraits<GlobalShortcutListenerMac>; 38 friend struct base::DefaultLazyInstanceTraits<GlobalShortcutListenerMac>;
26 39
27 GlobalShortcutListenerMac(); 40 GlobalShortcutListenerMac();
28 41
29 // Register an |accelerator| with the particular |observer|. 42 // Register an |accelerator| with the particular |observer|.
30 virtual void RegisterAccelerator( 43 virtual void RegisterAccelerator(
31 const ui::Accelerator& accelerator, 44 const ui::Accelerator& accelerator,
32 GlobalShortcutListener::Observer* observer) OVERRIDE; 45 GlobalShortcutListener::Observer* observer) OVERRIDE;
33 // Unregister an |accelerator| with the particular |observer|. 46 // Unregister an |accelerator| with the particular |observer|.
34 virtual void UnregisterAccelerator( 47 virtual void UnregisterAccelerator(
35 const ui::Accelerator& accelerator, 48 const ui::Accelerator& accelerator,
36 GlobalShortcutListener::Observer* observer) OVERRIDE; 49 GlobalShortcutListener::Observer* observer) OVERRIDE;
37 50
38 // Whether this object is listening for global shortcuts. 51 // Whether this object is listening for global shortcuts.
39 bool is_listening_; 52 bool is_listening_;
40 53
54 // Set of registered accelerators.
55 typedef std::set<ui::Accelerator> RegisteredHotKeys;
56 RegisteredHotKeys registered_hot_keys_;
57
58 // A pointer to the global shortcut listener tap.
59 base::scoped_nsobject<GlobalShortcutListenerTap> tap_;
60
41 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerMac); 61 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerMac);
42 }; 62 };
43 63
44 } // namespace extensions 64 } // namespace extensions
45 65
46 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_ 66 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698