Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: ui/gfx/win/display_manager.h

Issue 1639623003: ScreenWin Testability and Restructuring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef UI_GFX_WIN_DISPLAY_MANAGER_H_
6 #define UI_GFX_WIN_DISPLAY_MANAGER_H_
7
8 #include <windows.h>
9 #include <memory>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/singleton.h"
14 #include "base/observer_list.h"
15 #include "ui/gfx/display.h"
16 #include "ui/gfx/gfx_export.h"
17
18 namespace gfx {
19
20 class Point;
21 class Rect;
22 class SingletonHwndObserver;
23
24 namespace win {
25
26 class DisplayManagerObserver;
27 class DisplayInfo;
28 class ScreenWinDisplay;
29
30 // Holds all of the ScreenWinDisplays available in the system.
31 // Normally, this means there is a 1:1 correspondence between ScreenWinDisplays
32 // and HMONITORS. However, in tests, we can't depend on this so we allow
33 // overrides of system API functions via virtual calls.
34 class GFX_EXPORT DisplayManager {
35 public:
36 static DisplayManager* GetInstance();
37
38 virtual void Initialize();
39
40 void AddObserver(DisplayManagerObserver* observer);
41 void RemoveObserver(DisplayManagerObserver* observer);
42
43 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.
44 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const;
45 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect(
46 const Rect& screen_rect) const;
47 ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint(
48 const Point& screen_point) const;
49 ScreenWinDisplay GetPrimaryScreenWinDisplay() const;
oshima 2016/01/28 18:32:04 document this
robliao 2016/01/29 01:44:41 Done.
50
51 // 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
52 virtual MONITORINFOEX MonitorInfoFromScreenPoint(
53 const gfx::Point& screen_point) const;
54 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect)
55 const;
56 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options)
57 const;
58 virtual HWND GetRootWindow(HWND hwnd) const;
59
60 protected:
61 friend std::default_delete<DisplayManager>;
62
63 static void SetInstanceForTesting(scoped_ptr<DisplayManager> display_manager);
64
65 DisplayManager();
66 virtual ~DisplayManager();
67
68 void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos);
69
70 private:
71 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const;
72 void WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
73
74 scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
75 base::ObserverList<DisplayManagerObserver, true> observer_list_;
76 std::vector<ScreenWinDisplay> screen_win_displays_;
77
78 DISALLOW_COPY_AND_ASSIGN(DisplayManager);
79 };
80
81 } // namespace win
82 } // namespace gfx
83
84 #endif // UI_GFX_WIN_DISPLAY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698