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

Side by Side Diff: chrome/browser/ui/panels/display_settings_provider.h

Issue 10066041: Revert 132144 - Broke ASAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
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 CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_
6 #define CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_ 6 #define CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/observer_list.h"
10 #include "base/timer.h"
11 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
12 10
13 // Encapsulates the logic to provide display settings support, including the 11 // Encapsulates the logic to provide display settings support, including the
14 // information for: 12 // information for:
15 // 1) Work area 13 // 1) Work area
16 // 2) Auto-hiding desktop bars, like Windows taskbar and MacOSX dock. 14 // 2) Auto-hiding desktop bars, like Windows taskbar and MacOSX dock.
17 class DisplaySettingsProvider { 15 class DisplaySettingsProvider {
18 public: 16 public:
19 // Indicates which screen edge the desktop bar is aligned to. 17 // Indicates which screen edge the desktop bar is aligned to.
20 // We do not care about the desktop aligned to the top screen edge. 18 // We do not care about the desktop aligned to the top screen edge.
21 enum DesktopBarAlignment { 19 enum DesktopBarAlignment {
22 DESKTOP_BAR_ALIGNED_BOTTOM = 0, 20 DESKTOP_BAR_ALIGNED_BOTTOM = 0,
23 DESKTOP_BAR_ALIGNED_LEFT = 1, 21 DESKTOP_BAR_ALIGNED_LEFT = 1,
24 DESKTOP_BAR_ALIGNED_RIGHT = 2 22 DESKTOP_BAR_ALIGNED_RIGHT = 2
25 }; 23 };
26 24
27 // Indicates current visibility state of the desktop bar. 25 // Indicates current visibility state of the desktop bar.
28 enum DesktopBarVisibility { 26 enum DesktopBarVisibility {
29 DESKTOP_BAR_VISIBLE, 27 DESKTOP_BAR_VISIBLE,
30 DESKTOP_BAR_ANIMATING, 28 DESKTOP_BAR_ANIMATING,
31 DESKTOP_BAR_HIDDEN 29 DESKTOP_BAR_HIDDEN
32 }; 30 };
33 31
32 // Observer can listen to the event regarding the display area change.
34 class DisplayAreaObserver { 33 class DisplayAreaObserver {
35 public: 34 public:
36 virtual void OnDisplayAreaChanged(const gfx::Rect& display_area) = 0; 35 virtual void OnDisplayAreaChanged(const gfx::Rect& display_area) = 0;
37 }; 36 };
38 37
38 // Observer can listen to the event regarding the desktop bar change.
39 class DesktopBarObserver { 39 class DesktopBarObserver {
40 public: 40 public:
41 virtual void OnAutoHidingDesktopBarVisibilityChanged( 41 virtual void OnAutoHidingDesktopBarVisibilityChanged(
42 DesktopBarAlignment alignment, DesktopBarVisibility visibility) = 0; 42 DesktopBarAlignment alignment, DesktopBarVisibility visibility) = 0;
43 }; 43 };
44 44
45 class FullScreenObserver {
46 public:
47 virtual void OnFullScreenModeChanged(bool is_full_screen) = 0;
48 };
49
50 static DisplaySettingsProvider* Create(); 45 static DisplaySettingsProvider* Create();
51 46
52 virtual ~DisplaySettingsProvider(); 47 virtual ~DisplaySettingsProvider();
53 48
54 // Subscribes/unsubscribes from the display settings change notification.
55 void AddDisplayAreaObserver(DisplayAreaObserver* observer);
56 void RemoveDisplayAreaObserver(DisplayAreaObserver* observer);
57
58 void AddDesktopBarObserver(DesktopBarObserver* observer);
59 void RemoveDesktopBarObserver(DesktopBarObserver* observer);
60
61 void AddFullScreenObserver(FullScreenObserver* observer);
62 void RemoveFullScreenObserver(FullScreenObserver* observer);
63
64 // Returns the bounds of the display area. 49 // Returns the bounds of the display area.
65 gfx::Rect GetDisplayArea(); 50 gfx::Rect GetDisplayArea();
66 51
67 // Invoked when the display settings has changed, due to any of the following: 52 // Invoked when the display settings has changed, due to any of the following:
68 // 1) screen resolution changes 53 // 1) screen resolution changes
69 // 2) the thickness of desktop bar changes 54 // 2) the thickness of desktop bar changes
70 // 3) desktop bar switches between auto-hiding and non-auto-hiding 55 // 3) desktop bar switches between auto-hiding and non-auto-hiding
71 virtual void OnDisplaySettingsChanged(); 56 virtual void OnDisplaySettingsChanged();
72 57
73 // Returns true if there is a desktop bar that is aligned to the specified 58 // Returns true if there is a desktop bar that is aligned to the specified
74 // screen edge and set to auto-hide. 59 // screen edge and set to auto-hide.
75 virtual bool IsAutoHidingDesktopBarEnabled(DesktopBarAlignment alignment); 60 virtual bool IsAutoHidingDesktopBarEnabled(DesktopBarAlignment alignment);
76 61
77 // Returns the thickness of the desktop bar that is aligned to the specified 62 // Returns the thickness of the desktop bar that is aligned to the specified
78 // screen edge, when it is visible. When the desktop bar is aligned to bottom 63 // screen edge, when it is visible. When the desktop bar is aligned to bottom
79 // edge, this is the height of the bar. If the desktop bar is aligned to 64 // edge, this is the height of the bar. If the desktop bar is aligned to
80 // left or right edge, this is the width of the bar. 65 // left or right edge, this is the width of the bar.
81 virtual int GetDesktopBarThickness(DesktopBarAlignment alignment) const; 66 virtual int GetDesktopBarThickness(DesktopBarAlignment alignment) const;
82 67
83 // Returns the visibility state of the desktop bar that is aligned to the 68 // Returns the visibility state of the desktop bar that is aligned to the
84 // specified screen edge. 69 // specified screen edge.
85 virtual DesktopBarVisibility GetDesktopBarVisibility( 70 virtual DesktopBarVisibility GetDesktopBarVisibility(
86 DesktopBarAlignment alignment) const; 71 DesktopBarAlignment alignment) const;
87 72
88 ObserverList<DisplayAreaObserver>& display_area_observers() { 73 DisplayAreaObserver* display_area_observer() const {
89 return display_area_observers_; 74 return display_area_observer_;
75 }
76 void set_display_area_observer(DisplayAreaObserver* display_area_observer) {
77 display_area_observer_ = display_area_observer;
90 } 78 }
91 79
92 ObserverList<DesktopBarObserver>& desktop_bar_observers() { 80 DesktopBarObserver* desktop_bar_observer() const {
93 return desktop_bar_observers_; 81 return desktop_bar_observer_;
94 } 82 }
95 83 void set_desktop_bar_observer(DesktopBarObserver* desktop_bar_observer) {
96 ObserverList<FullScreenObserver>& full_screen_observers() { 84 desktop_bar_observer_ = desktop_bar_observer;
97 return full_screen_observers_;
98 } 85 }
99 86
100 gfx::Rect work_area() const { return work_area_; } 87 gfx::Rect work_area() const { return work_area_; }
101 bool is_full_screen() const { return is_full_screen_; }
102 88
103 protected: 89 protected:
104 DisplaySettingsProvider(); 90 DisplaySettingsProvider();
105 91
106 // Returns the bounds of the work area that has not been adjusted to take 92 // Returns the bounds of the work area that has not been adjusted to take
107 // auto-hiding desktop bars into account. This can be overridden by the 93 // auto-hiding desktop bars into account. This can be overridden by the
108 // testing code. 94 // testing code.
109 virtual gfx::Rect GetWorkArea() const; 95 virtual gfx::Rect GetWorkArea() const;
110 96
111 // Callback to perform periodic check for full screen mode changes.
112 virtual void CheckFullScreenMode();
113
114 void OnAutoHidingDesktopBarChanged(); 97 void OnAutoHidingDesktopBarChanged();
115 98
116 private: 99 private:
117 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. 100 // Adjusts the work area to exclude the influence of auto-hiding desktop bars.
118 void AdjustWorkAreaForAutoHidingDesktopBars(); 101 void AdjustWorkAreaForAutoHidingDesktopBars();
119 102
120 // Observers that listen to various display settings changes. 103 DisplayAreaObserver* display_area_observer_;
121 ObserverList<DisplayAreaObserver> display_area_observers_; 104 DesktopBarObserver* desktop_bar_observer_;
122 ObserverList<DesktopBarObserver> desktop_bar_observers_;
123 ObserverList<FullScreenObserver> full_screen_observers_;
124 105
125 // The maximum work area avaialble. This area does not include the area taken 106 // The maximum work area avaialble. This area does not include the area taken
126 // by the always-visible (non-auto-hiding) desktop bars. 107 // by the always-visible (non-auto-hiding) desktop bars.
127 gfx::Rect work_area_; 108 gfx::Rect work_area_;
128 109
129 // The useable work area for computing the panel bounds. This area excludes 110 // The useable work area for computing the panel bounds. This area excludes
130 // the potential area that could be taken by the auto-hiding desktop 111 // the potential area that could be taken by the auto-hiding desktop
131 // bars (we only consider those bars that are aligned to bottom, left, and 112 // bars (we only consider those bars that are aligned to bottom, left, and
132 // right of the screen edges) when they become fully visible. 113 // right of the screen edges) when they become fully visible.
133 gfx::Rect adjusted_work_area_; 114 gfx::Rect adjusted_work_area_;
134
135 // True if full screen mode or presentation mode is entered.
136 bool is_full_screen_;
137
138 // Timer used to detect full-screen mode change.
139 base::RepeatingTimer<DisplaySettingsProvider> full_screen_mode_timer_;
140
141 DISALLOW_COPY_AND_ASSIGN(DisplaySettingsProvider);
142 }; 115 };
143 116
144 #endif // CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_ 117 #endif // CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/base_panel_browser_test.cc ('k') | chrome/browser/ui/panels/display_settings_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698