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 virtual ~GlobalShortcutListenerWin(); |
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 virtual 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 virtual void StartListening() override; |
33 virtual void StopListening() OVERRIDE; | 33 virtual void StopListening() override; |
34 virtual bool RegisterAcceleratorImpl( | 34 virtual bool RegisterAcceleratorImpl( |
35 const ui::Accelerator& accelerator) OVERRIDE; | 35 const ui::Accelerator& accelerator) override; |
36 virtual void UnregisterAcceleratorImpl( | 36 virtual void UnregisterAcceleratorImpl( |
37 const ui::Accelerator& accelerator) OVERRIDE; | 37 const ui::Accelerator& accelerator) override; |
38 | 38 |
39 // Whether this object is listening for global shortcuts. | 39 // Whether this object is listening for global shortcuts. |
40 bool is_listening_; | 40 bool is_listening_; |
41 | 41 |
42 // A map of registered accelerators and their registration ids. | 42 // A map of registered accelerators and their registration ids. |
43 typedef std::map<ui::Accelerator, int> HotkeyIdMap; | 43 typedef std::map<ui::Accelerator, int> HotkeyIdMap; |
44 HotkeyIdMap hotkey_ids_; | 44 HotkeyIdMap hotkey_ids_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerWin); | 46 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerWin); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace extensions | 49 } // namespace extensions |
50 | 50 |
51 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ | 51 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_WIN_H_ |
OLD | NEW |