Index: ui/gfx/win/display_manager.h |
diff --git a/ui/gfx/win/display_manager.h b/ui/gfx/win/display_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a049ebc338d86f917e63a82aae1876366ab6c93e |
--- /dev/null |
+++ b/ui/gfx/win/display_manager.h |
@@ -0,0 +1,84 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_GFX_WIN_DISPLAY_MANAGER_H_ |
+#define UI_GFX_WIN_DISPLAY_MANAGER_H_ |
+ |
+#include <windows.h> |
+#include <memory> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/memory/singleton.h" |
+#include "base/observer_list.h" |
+#include "ui/gfx/display.h" |
+#include "ui/gfx/gfx_export.h" |
+ |
+namespace gfx { |
+ |
+class Point; |
+class Rect; |
+class SingletonHwndObserver; |
+ |
+namespace win { |
+ |
+class DisplayManagerObserver; |
+class DisplayInfo; |
+class ScreenWinDisplay; |
+ |
+// Holds all of the ScreenWinDisplays available in the system. |
+// Normally, this means there is a 1:1 correspondence between ScreenWinDisplays |
+// and HMONITORS. However, in tests, we can't depend on this so we allow |
+// overrides of system API functions via virtual calls. |
+class GFX_EXPORT DisplayManager { |
+ public: |
+ static DisplayManager* GetInstance(); |
+ |
+ virtual void Initialize(); |
+ |
+ void AddObserver(DisplayManagerObserver* observer); |
+ void RemoveObserver(DisplayManagerObserver* observer); |
+ |
+ const std::vector<ScreenWinDisplay>& GetScreenWinDisplays(); |
oshima
2016/01/28 18:32:05
maybe you should have new line here and
robliao
2016/01/29 01:44:41
Done.
|
+ ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const; |
+ ScreenWinDisplay GetScreenWinDisplayNearestScreenRect( |
+ const Rect& screen_rect) const; |
+ ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint( |
+ const Point& screen_point) const; |
+ ScreenWinDisplay GetPrimaryScreenWinDisplay() const; |
oshima
2016/01/28 18:32:04
document this
robliao
2016/01/29 01:44:41
Done.
|
+ |
+ // For Unit Tests. |
oshima
2016/01/28 18:32:05
methods for test should either be named XxxForTest
robliao
2016/01/29 01:44:41
These are called by production code, but they are
|
+ virtual MONITORINFOEX MonitorInfoFromScreenPoint( |
+ const gfx::Point& screen_point) const; |
+ virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) |
+ const; |
+ virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) |
+ const; |
+ virtual HWND GetRootWindow(HWND hwnd) const; |
+ |
+ protected: |
+ friend std::default_delete<DisplayManager>; |
+ |
+ static void SetInstanceForTesting(scoped_ptr<DisplayManager> display_manager); |
+ |
+ DisplayManager(); |
+ virtual ~DisplayManager(); |
+ |
+ void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos); |
+ |
+ private: |
+ ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const; |
+ void WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); |
+ |
+ scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; |
+ base::ObserverList<DisplayManagerObserver, true> observer_list_; |
+ std::vector<ScreenWinDisplay> screen_win_displays_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
+}; |
+ |
+} // namespace win |
+} // namespace gfx |
+ |
+#endif // UI_GFX_WIN_DISPLAY_MANAGER_H_ |