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

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

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