Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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 UI_GFX_SINGLETON_HWND_H_ | |
| 6 #define UI_GFX_SINGLETON_HWND_H_ | |
|
tfarina
2012/02/08 20:34:55
nit: UI_BASE_WIN_SINGLETON_HWND_H_
asvitkine_google
2012/02/08 21:04:57
Done.
| |
| 7 #pragma once | |
| 8 | |
| 9 #include <windows.h> | |
| 10 #include <vector> | |
|
tfarina
2012/02/08 20:34:55
nit: I'd put a blank line between windows.h and ve
asvitkine_google
2012/02/08 21:04:57
I've seen a different review go the other way - la
| |
| 11 | |
| 12 #include "base/callback_forward.h" | |
| 13 #include "base/basictypes.h" | |
|
tfarina
2012/02/08 20:34:55
sort.
asvitkine_google
2012/02/08 21:04:57
Done.
| |
| 14 #include "base/memory/singleton.h" | |
| 15 | |
| 16 namespace gfx { | |
|
tfarina
2012/02/08 20:34:55
nit: namespace ui instead?
asvitkine_google
2012/02/08 21:04:57
Done.
| |
| 17 | |
| 18 typedef base::Callback<void(HWND, UINT, WPARAM, LPARAM)> WndProcCallback; | |
| 19 | |
| 20 // Singleton HWND that allows interested clients to receive WM_* notifications. | |
| 21 class SingletonHwnd { | |
| 22 public: | |
| 23 // Singleton getter. | |
| 24 static SingletonHwnd* GetInstance(); | |
| 25 | |
| 26 // Registers a listener callback for WM_* notifications. | |
| 27 void RegisterListener(WndProcCallback& callback); | |
| 28 | |
| 29 // Windows callback for WM_* notifications. | |
| 30 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | |
| 31 | |
| 32 private: | |
| 33 // Listener HWND for WM_* notifications. | |
| 34 HWND listener_window_; | |
| 35 | |
| 36 // List of registers listener callbacks. | |
| 37 std::vector<WndProcCallback> listeners_; | |
| 38 | |
| 39 SingletonHwnd(); | |
| 40 ~SingletonHwnd(); | |
| 41 | |
| 42 friend struct DefaultSingletonTraits<SingletonHwnd>; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(SingletonHwnd); | |
| 45 }; | |
| 46 | |
| 47 } // namespace gfx | |
| 48 | |
| 49 #endif // UI_GFX_SINGLETON_HWND_H_ | |
| OLD | NEW |