[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / ui / gfx / win / singleton_hwnd.h
blobea62b3ed4b6d56be225de8f0e8f9ee7085cec54b
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_
8 #include <windows.h>
9 #include <vector>
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;
17 namespace gfx {
19 class SingletonHwndObserver;
21 // Singleton message-only HWND that allows interested clients to receive WM_*
22 // notifications.
23 class GFX_EXPORT SingletonHwnd : public WindowImpl {
24 public:
25 static SingletonHwnd* GetInstance();
27 // Windows callback for WM_* notifications.
28 BOOL ProcessWindowMessage(HWND window,
29 UINT message,
30 WPARAM wparam,
31 LPARAM lparam,
32 LRESULT& result,
33 DWORD msg_map_id) override;
35 private:
36 friend class SingletonHwndObserver;
37 friend struct DefaultSingletonTraits<SingletonHwnd>;
39 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);
52 } // namespace gfx
54 #endif // UI_GFX_WIN_SINGLETON_HWND_H_