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"
16 template<typename T
> struct DefaultSingletonTraits
;
21 class SingletonHwndObserver
;
23 // Singleton message-only HWND that allows interested clients to receive WM_*
25 class GFX_EXPORT SingletonHwnd
: public WindowImpl
{
27 static SingletonHwnd
* GetInstance();
29 // Windows callback for WM_* notifications.
30 BOOL
ProcessWindowMessage(HWND window
,
35 DWORD msg_map_id
) override
;
38 friend class SingletonHwndObserver
;
39 friend struct base::DefaultSingletonTraits
<SingletonHwnd
>;
42 ~SingletonHwnd() override
;
44 // Add/remove SingletonHwndObserver to forward WM_* notifications.
45 void AddObserver(SingletonHwndObserver
* observer
);
46 void RemoveObserver(SingletonHwndObserver
* observer
);
48 // List of registered observers.
49 base::ObserverList
<SingletonHwndObserver
, true> observer_list_
;
51 DISALLOW_COPY_AND_ASSIGN(SingletonHwnd
);
56 #endif // UI_GFX_WIN_SINGLETON_HWND_H_