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