Chromium Code Reviews| Index: ui/base/win/singleton_hwnd.h |
| =================================================================== |
| --- ui/base/win/singleton_hwnd.h (revision 0) |
| +++ ui/base/win/singleton_hwnd.h (revision 0) |
| @@ -0,0 +1,49 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_BASE_SINGLETON_HWND_H_ |
|
tfarina
2012/02/08 23:35:50
still wrong :)
UI_BASE_SINGLETON_HWND_H_ -> UI_BAS
Alexei Svitkine (slow)
2012/02/09 15:11:43
Oops, you're right. Fixed.
|
| +#define UI_BASE_SINGLETON_HWND_H_ |
| +#pragma once |
| + |
| +#include <windows.h> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback_forward.h" |
| +#include "base/memory/singleton.h" |
| + |
| +namespace ui { |
| + |
| +typedef base::Callback<void(HWND, UINT, WPARAM, LPARAM)> WndProcCallback; |
| + |
| +// Singleton HWND that allows interested clients to receive WM_* notifications. |
| +class SingletonHwnd { |
| + public: |
| + // Singleton getter. |
| + static SingletonHwnd* GetInstance(); |
| + |
| + // Registers a listener callback for WM_* notifications. |
| + void RegisterListener(WndProcCallback& callback); |
| + |
| + // Windows callback for WM_* notifications. |
| + void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); |
| + |
| + private: |
| + // Listener HWND for WM_* notifications. |
| + HWND listener_window_; |
| + |
| + // List of registered listener callbacks. |
| + std::vector<WndProcCallback> listeners_; |
| + |
| + SingletonHwnd(); |
|
sky
2012/02/08 23:34:04
this should be first.
Alexei Svitkine (slow)
2012/02/09 15:11:43
Done.
|
| + ~SingletonHwnd(); |
| + |
| + friend struct DefaultSingletonTraits<SingletonHwnd>; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SingletonHwnd); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_BASE_SINGLETON_HWND_H_ |