OLD | NEW |
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_WIN_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "chrome/browser/extensions/global_shortcut_listener.h" | 10 #include "chrome/browser/extensions/global_shortcut_listener.h" |
11 #include "ui/gfx/win/singleton_hwnd.h" | 11 #include "ui/gfx/win/singleton_hwnd.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 // Windows-specific implementation of the GlobalShortcutListener class that | 15 // Windows-specific implementation of the GlobalShortcutListener class that |
16 // listens for global shortcuts. Handles setting up a keyboard hook and | 16 // listens for global shortcuts. Handles setting up a keyboard hook and |
17 // forwarding its output to the base class for processing. | 17 // forwarding its output to the base class for processing. |
18 class GlobalShortcutListenerWin : public GlobalShortcutListener, | 18 class GlobalShortcutListenerWin : public GlobalShortcutListener, |
19 public gfx::SingletonHwnd::Observer { | 19 public gfx::SingletonHwnd::Observer { |
20 public: | 20 public: |
21 GlobalShortcutListenerWin(); | 21 GlobalShortcutListenerWin(); |
22 virtual ~GlobalShortcutListenerWin(); | 22 ~GlobalShortcutListenerWin() override; |
23 | 23 |
24 private: | 24 private: |
25 // The implementation of our Window Proc, called by SingletonHwnd. | 25 // The implementation of our Window Proc, called by SingletonHwnd. |
26 virtual void OnWndProc(HWND hwnd, | 26 void OnWndProc(HWND hwnd, |
27 UINT message, | 27 UINT message, |
28 WPARAM wparam, | 28 WPARAM wparam, |
29 LPARAM lparam) override; | 29 LPARAM lparam) override; |
30 | 30 |
31 // GlobalShortcutListener implementation. | 31 // GlobalShortcutListener implementation. |
32 virtual void StartListening() override; | 32 void StartListening() override; |
33 virtual void StopListening() override; | 33 void StopListening() override; |
34 virtual bool RegisterAcceleratorImpl( | 34 bool RegisterAcceleratorImpl(const ui::Accelerator& accelerator) override; |
35 const ui::Accelerator& accelerator) override; | 35 void UnregisterAcceleratorImpl(const ui::Accelerator& accelerator) override; |
36 virtual void UnregisterAcceleratorImpl( | |
37 const ui::Accelerator& accelerator) override; | |
38 | 36 |
39 // Whether this object is listening for global shortcuts. | 37 // Whether this object is listening for global shortcuts. |
40 bool is_listening_; | 38 bool is_listening_; |
41 | 39 |
42 // A map of registered accelerators and their registration ids. | 40 // A map of registered accelerators and their registration ids. |
43 typedef std::map<ui::Accelerator, int> HotkeyIdMap; | 41 typedef std::map<ui::Accelerator, int> HotkeyIdMap; |
44 HotkeyIdMap hotkey_ids_; | 42 HotkeyIdMap hotkey_ids_; |
45 | 43 |
46 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerWin); | 44 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerWin); |
47 }; | 45 }; |
48 | 46 |
49 } // namespace extensions | 47 } // namespace extensions |
50 | 48 |
51 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ | 49 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ |
OLD | NEW |