No gfx::SingletonHwnd::Observer any more.
Using gfx::SingletonHwndObserver instead.
This commit is contained in:
parent
b4e836bf2e
commit
48ccb0f2ab
2 changed files with 15 additions and 9 deletions
|
@ -4,11 +4,14 @@
|
|||
|
||||
#include "chrome/browser/extensions/global_shortcut_listener_win.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/bind_helpers.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
#include "ui/events/event_constants.h"
|
||||
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
|
||||
#include "ui/gfx/win/singleton_hwnd.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
|
@ -35,14 +38,17 @@ GlobalShortcutListenerWin::~GlobalShortcutListenerWin() {
|
|||
void GlobalShortcutListenerWin::StartListening() {
|
||||
DCHECK(!is_listening_); // Don't start twice.
|
||||
DCHECK(!hotkey_ids_.empty()); // Also don't start if no hotkey is registered.
|
||||
gfx::SingletonHwnd::GetInstance()->AddObserver(this);
|
||||
singleton_hwnd_observer_.reset(new gfx::SingletonHwndObserver(
|
||||
base::Bind(
|
||||
&GlobalShortcutListenerWin::OnWndProc, base::Unretained(this))));
|
||||
|
||||
is_listening_ = true;
|
||||
}
|
||||
|
||||
void GlobalShortcutListenerWin::StopListening() {
|
||||
DCHECK(is_listening_); // No point if we are not already listening.
|
||||
DCHECK(hotkey_ids_.empty()); // Make sure the map is clean before ending.
|
||||
gfx::SingletonHwnd::GetInstance()->RemoveObserver(this);
|
||||
singleton_hwnd_observer_.reset(nullptr);
|
||||
is_listening_ = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,26 +7,24 @@
|
|||
|
||||
#include <windows.h>
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "chrome/browser/extensions/global_shortcut_listener.h"
|
||||
#include "ui/gfx/win/singleton_hwnd.h"
|
||||
#include "ui/gfx/win/singleton_hwnd_observer.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
// Windows-specific implementation of the GlobalShortcutListener class that
|
||||
// listens for global shortcuts. Handles setting up a keyboard hook and
|
||||
// forwarding its output to the base class for processing.
|
||||
class GlobalShortcutListenerWin : public GlobalShortcutListener,
|
||||
public gfx::SingletonHwnd::Observer {
|
||||
class GlobalShortcutListenerWin : public GlobalShortcutListener {
|
||||
public:
|
||||
GlobalShortcutListenerWin();
|
||||
virtual ~GlobalShortcutListenerWin();
|
||||
|
||||
private:
|
||||
// The implementation of our Window Proc, called by SingletonHwnd.
|
||||
virtual void OnWndProc(HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam) override;
|
||||
// The implementation of our Window Proc, called by SingletonHwndObserver.
|
||||
void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
// GlobalShortcutListener implementation.
|
||||
virtual void StartListening() override;
|
||||
|
@ -43,6 +41,8 @@ class GlobalShortcutListenerWin : public GlobalShortcutListener,
|
|||
typedef std::map<ui::Accelerator, int> HotkeyIdMap;
|
||||
HotkeyIdMap hotkey_ids_;
|
||||
|
||||
scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerWin);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue