| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_GFX_WIN_SINGLETON_HWND_H_ | 5 #ifndef UI_GFX_WIN_SINGLETON_HWND_H_ |
| 6 #define UI_GFX_WIN_SINGLETON_HWND_H_ | 6 #define UI_GFX_WIN_SINGLETON_HWND_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
| 13 #include "ui/gfx/win/window_impl.h" | 13 #include "ui/gfx/win/window_impl.h" |
| 14 | 14 |
| 15 namespace base { |
| 15 template<typename T> struct DefaultSingletonTraits; | 16 template<typename T> struct DefaultSingletonTraits; |
| 17 } |
| 16 | 18 |
| 17 namespace gfx { | 19 namespace gfx { |
| 18 | 20 |
| 19 class SingletonHwndObserver; | 21 class SingletonHwndObserver; |
| 20 | 22 |
| 21 // Singleton message-only HWND that allows interested clients to receive WM_* | 23 // Singleton message-only HWND that allows interested clients to receive WM_* |
| 22 // notifications. | 24 // notifications. |
| 23 class GFX_EXPORT SingletonHwnd : public WindowImpl { | 25 class GFX_EXPORT SingletonHwnd : public WindowImpl { |
| 24 public: | 26 public: |
| 25 static SingletonHwnd* GetInstance(); | 27 static SingletonHwnd* GetInstance(); |
| 26 | 28 |
| 27 // Windows callback for WM_* notifications. | 29 // Windows callback for WM_* notifications. |
| 28 BOOL ProcessWindowMessage(HWND window, | 30 BOOL ProcessWindowMessage(HWND window, |
| 29 UINT message, | 31 UINT message, |
| 30 WPARAM wparam, | 32 WPARAM wparam, |
| 31 LPARAM lparam, | 33 LPARAM lparam, |
| 32 LRESULT& result, | 34 LRESULT& result, |
| 33 DWORD msg_map_id) override; | 35 DWORD msg_map_id) override; |
| 34 | 36 |
| 35 private: | 37 private: |
| 36 friend class SingletonHwndObserver; | 38 friend class SingletonHwndObserver; |
| 37 friend struct DefaultSingletonTraits<SingletonHwnd>; | 39 friend struct base::DefaultSingletonTraits<SingletonHwnd>; |
| 38 | 40 |
| 39 SingletonHwnd(); | 41 SingletonHwnd(); |
| 40 ~SingletonHwnd() override; | 42 ~SingletonHwnd() override; |
| 41 | 43 |
| 42 // Add/remove SingletonHwndObserver to forward WM_* notifications. | 44 // Add/remove SingletonHwndObserver to forward WM_* notifications. |
| 43 void AddObserver(SingletonHwndObserver* observer); | 45 void AddObserver(SingletonHwndObserver* observer); |
| 44 void RemoveObserver(SingletonHwndObserver* observer); | 46 void RemoveObserver(SingletonHwndObserver* observer); |
| 45 | 47 |
| 46 // List of registered observers. | 48 // List of registered observers. |
| 47 base::ObserverList<SingletonHwndObserver, true> observer_list_; | 49 base::ObserverList<SingletonHwndObserver, true> observer_list_; |
| 48 | 50 |
| 49 DISALLOW_COPY_AND_ASSIGN(SingletonHwnd); | 51 DISALLOW_COPY_AND_ASSIGN(SingletonHwnd); |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 } // namespace gfx | 54 } // namespace gfx |
| 53 | 55 |
| 54 #endif // UI_GFX_WIN_SINGLETON_HWND_H_ | 56 #endif // UI_GFX_WIN_SINGLETON_HWND_H_ |
| OLD | NEW |