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.
5 #ifndef UI_GFX_WIN_SINGLETON_HWND_H_
6 #define UI_GFX_WIN_SINGLETON_HWND_H_
11 #include "base/observer_list.h"
12 #include "ui/gfx/gfx_export.h"
13 #include "ui/gfx/win/window_impl.h"
15 template<typename T
> struct DefaultSingletonTraits
;
19 class SingletonHwndObserver
;
21 // Singleton message-only HWND that allows interested clients to receive WM_*
23 class GFX_EXPORT SingletonHwnd
: public WindowImpl
{
25 static SingletonHwnd
* GetInstance();
27 // Windows callback for WM_* notifications.
28 BOOL
ProcessWindowMessage(HWND window
,
33 DWORD msg_map_id
) override
;
36 friend class SingletonHwndObserver
;
37 friend struct DefaultSingletonTraits
<SingletonHwnd
>;
40 ~SingletonHwnd() override
;
42 // Add/remove SingletonHwndObserver to forward WM_* notifications.
43 void AddObserver(SingletonHwndObserver
* observer
);
44 void RemoveObserver(SingletonHwndObserver
* observer
);
46 // List of registered observers.
47 base::ObserverList
<SingletonHwndObserver
, true> observer_list_
;
49 DISALLOW_COPY_AND_ASSIGN(SingletonHwnd
);
54 #endif // UI_GFX_WIN_SINGLETON_HWND_H_