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

Side by Side Diff: ui/gfx/screen_win.h

Issue 1092183005: Fix Up SingletonHwnd Observer Lifetime Issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed WndProc null guard Created 5 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_SCREEN_WIN_H_ 5 #ifndef UI_GFX_SCREEN_WIN_H_
6 #define UI_GFX_SCREEN_WIN_H_ 6 #define UI_GFX_SCREEN_WIN_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "ui/gfx/display_change_notifier.h" 10 #include "ui/gfx/display_change_notifier.h"
10 #include "ui/gfx/gfx_export.h" 11 #include "ui/gfx/gfx_export.h"
11 #include "ui/gfx/screen.h" 12 #include "ui/gfx/screen.h"
12 #include "ui/gfx/win/singleton_hwnd.h" 13 #include "ui/gfx/win/singleton_hwnd_observer.h"
13 14
14 namespace gfx { 15 namespace gfx {
15 16
16 class GFX_EXPORT ScreenWin : public Screen, 17 class GFX_EXPORT ScreenWin : public Screen {
17 public SingletonHwnd::Observer {
18 public: 18 public:
19 ScreenWin(); 19 ScreenWin();
20 ~ScreenWin() override; 20 ~ScreenWin() override;
21 21
22 protected: 22 protected:
23 // Overridden from gfx::Screen: 23 // Overridden from gfx::Screen:
24 gfx::Point GetCursorScreenPoint() override; 24 gfx::Point GetCursorScreenPoint() override;
25 gfx::NativeWindow GetWindowUnderCursor() override; 25 gfx::NativeWindow GetWindowUnderCursor() override;
26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; 26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
27 int GetNumDisplays() const override; 27 int GetNumDisplays() const override;
28 std::vector<gfx::Display> GetAllDisplays() const override; 28 std::vector<gfx::Display> GetAllDisplays() const override;
29 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override; 29 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override;
30 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; 30 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override;
31 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; 31 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override;
32 gfx::Display GetPrimaryDisplay() const override; 32 gfx::Display GetPrimaryDisplay() const override;
33 void AddObserver(DisplayObserver* observer) override; 33 void AddObserver(DisplayObserver* observer) override;
34 void RemoveObserver(DisplayObserver* observer) override; 34 void RemoveObserver(DisplayObserver* observer) override;
35 35
36 // Overriden from gfx::SingletonHwnd::Observer.
37 void OnWndProc(HWND hwnd,
38 UINT message,
39 WPARAM wparam,
40 LPARAM lparam) override;
41
42 // Returns the HWND associated with the NativeView. 36 // Returns the HWND associated with the NativeView.
43 virtual HWND GetHWNDFromNativeView(NativeView window) const; 37 virtual HWND GetHWNDFromNativeView(NativeView window) const;
44 38
45 // Returns the NativeView associated with the HWND. 39 // Returns the NativeView associated with the HWND.
46 virtual NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; 40 virtual NativeWindow GetNativeWindowFromHWND(HWND hwnd) const;
47 41
48 private: 42 private:
43 void OnDisplayChange(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
44
49 // Helper implementing the DisplayObserver handling. 45 // Helper implementing the DisplayObserver handling.
50 gfx::DisplayChangeNotifier change_notifier_; 46 gfx::DisplayChangeNotifier change_notifier_;
51 47
48 scoped_ptr<SingletonHwndObserver> singleton_hwnd_observer_;
49
52 // Current list of displays. 50 // Current list of displays.
53 std::vector<gfx::Display> displays_; 51 std::vector<gfx::Display> displays_;
54 52
55 DISALLOW_COPY_AND_ASSIGN(ScreenWin); 53 DISALLOW_COPY_AND_ASSIGN(ScreenWin);
56 }; 54 };
57 55
58 } // namespace gfx 56 } // namespace gfx
59 57
60 #endif // UI_GFX_SCREEN_WIN_H_ 58 #endif // UI_GFX_SCREEN_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698