| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "base/timer/timer.h" | |
| 11 #include "ui/gfx/geometry/rect.h" | |
| 12 | |
| 13 // Encapsulates the logic to provide display settings support, including the | |
| 14 // information for: | |
| 15 // 1) Work area | |
| 16 // 2) Auto-hiding desktop bars, like Windows taskbar and MacOSX dock. | |
| 17 class DisplaySettingsProvider { | |
| 18 public: | |
| 19 // Indicates which screen edge the desktop bar is aligned to. | |
| 20 // We do not care about the desktop aligned to the top screen edge. | |
| 21 enum DesktopBarAlignment { | |
| 22 DESKTOP_BAR_ALIGNED_BOTTOM = 0, | |
| 23 DESKTOP_BAR_ALIGNED_LEFT = 1, | |
| 24 DESKTOP_BAR_ALIGNED_RIGHT = 2 | |
| 25 }; | |
| 26 | |
| 27 // Indicates current visibility state of the desktop bar. | |
| 28 enum DesktopBarVisibility { | |
| 29 DESKTOP_BAR_VISIBLE, | |
| 30 DESKTOP_BAR_ANIMATING, | |
| 31 DESKTOP_BAR_HIDDEN | |
| 32 }; | |
| 33 | |
| 34 class DisplayObserver { | |
| 35 public: | |
| 36 virtual void OnDisplayChanged() = 0; | |
| 37 }; | |
| 38 | |
| 39 class DesktopBarObserver { | |
| 40 public: | |
| 41 virtual void OnAutoHidingDesktopBarVisibilityChanged( | |
| 42 DesktopBarAlignment alignment, DesktopBarVisibility visibility) = 0; | |
| 43 virtual void OnAutoHidingDesktopBarThicknessChanged( | |
| 44 DesktopBarAlignment alignment, int thickness) = 0; | |
| 45 }; | |
| 46 | |
| 47 class FullScreenObserver { | |
| 48 public: | |
| 49 virtual void OnFullScreenModeChanged(bool is_full_screen) = 0; | |
| 50 }; | |
| 51 | |
| 52 static DisplaySettingsProvider* Create(); | |
| 53 | |
| 54 virtual ~DisplaySettingsProvider(); | |
| 55 | |
| 56 // Subscribes/unsubscribes from the display settings change notification. | |
| 57 void AddDisplayObserver(DisplayObserver* observer); | |
| 58 void RemoveDisplayObserver(DisplayObserver* observer); | |
| 59 | |
| 60 void AddDesktopBarObserver(DesktopBarObserver* observer); | |
| 61 void RemoveDesktopBarObserver(DesktopBarObserver* observer); | |
| 62 | |
| 63 void AddFullScreenObserver(FullScreenObserver* observer); | |
| 64 void RemoveFullScreenObserver(FullScreenObserver* observer); | |
| 65 | |
| 66 // | |
| 67 // Display Area: | |
| 68 // This is the area of a display (monitor). There could be multiple display | |
| 69 // areas. | |
| 70 // Work Area: | |
| 71 // This is the standard work area returned by the system. It is usually | |
| 72 // computed by the system as the part of display area that excludes | |
| 73 // top-most system menu or bars aligned to the screen edges. | |
| 74 // | |
| 75 | |
| 76 // Returns the bounds of primary display. | |
| 77 virtual gfx::Rect GetPrimaryDisplayArea() const; | |
| 78 | |
| 79 // Returns the bounds of the work area of primary display. | |
| 80 virtual gfx::Rect GetPrimaryWorkArea() const; | |
| 81 | |
| 82 // Returns the bounds of the display area that most closely intersects the | |
| 83 // provided bounds. | |
| 84 virtual gfx::Rect GetDisplayAreaMatching(const gfx::Rect& bounds) const; | |
| 85 | |
| 86 // Returns the bounds of the work area that most closely intersects the | |
| 87 // provided bounds. | |
| 88 virtual gfx::Rect GetWorkAreaMatching(const gfx::Rect& bounds) const; | |
| 89 | |
| 90 // Invoked when the display settings has changed, due to any of the following: | |
| 91 // 1) screen resolution changes | |
| 92 // 2) the thickness of desktop bar changes | |
| 93 // 3) desktop bar switches between auto-hiding and non-auto-hiding | |
| 94 virtual void OnDisplaySettingsChanged(); | |
| 95 | |
| 96 // Returns true if there is a desktop bar that is aligned to the specified | |
| 97 // screen edge and set to auto-hide. | |
| 98 virtual bool IsAutoHidingDesktopBarEnabled(DesktopBarAlignment alignment); | |
| 99 | |
| 100 // Returns the thickness of the desktop bar that is aligned to the specified | |
| 101 // screen edge, when it is visible. When the desktop bar is aligned to bottom | |
| 102 // edge, this is the height of the bar. If the desktop bar is aligned to | |
| 103 // left or right edge, this is the width of the bar. | |
| 104 virtual int GetDesktopBarThickness(DesktopBarAlignment alignment) const; | |
| 105 | |
| 106 // Returns the visibility state of the desktop bar that is aligned to the | |
| 107 // specified screen edge. | |
| 108 virtual DesktopBarVisibility GetDesktopBarVisibility( | |
| 109 DesktopBarAlignment alignment) const; | |
| 110 | |
| 111 base::ObserverList<DisplayObserver>& display_observers() { | |
| 112 return display_observers_; | |
| 113 } | |
| 114 | |
| 115 base::ObserverList<DesktopBarObserver>& desktop_bar_observers() { | |
| 116 return desktop_bar_observers_; | |
| 117 } | |
| 118 | |
| 119 base::ObserverList<FullScreenObserver>& full_screen_observers() { | |
| 120 return full_screen_observers_; | |
| 121 } | |
| 122 | |
| 123 bool is_full_screen() const { return is_full_screen_; } | |
| 124 | |
| 125 protected: | |
| 126 enum FullScreenCheckMode { | |
| 127 ASSUME_FULLSCREEN_ON, | |
| 128 ASSUME_FULLSCREEN_OFF, | |
| 129 PERFORM_FULLSCREEN_CHECK | |
| 130 }; | |
| 131 | |
| 132 DisplaySettingsProvider(); | |
| 133 | |
| 134 // Returns true if we need to perform fullscreen check periodically. | |
| 135 virtual bool NeedsPeriodicFullScreenCheck() const; | |
| 136 | |
| 137 // Returns true if full screen or presentation mode in main screen is entered. | |
| 138 virtual bool IsFullScreen(); | |
| 139 | |
| 140 // Callback to perform periodic check for full screen mode changes. | |
| 141 void CheckFullScreenMode(FullScreenCheckMode check_mode); | |
| 142 | |
| 143 private: | |
| 144 // Observers that listen to various display settings changes. | |
| 145 base::ObserverList<DisplayObserver> display_observers_; | |
| 146 base::ObserverList<DesktopBarObserver> desktop_bar_observers_; | |
| 147 base::ObserverList<FullScreenObserver> full_screen_observers_; | |
| 148 | |
| 149 // True if full screen mode or presentation mode is entered. | |
| 150 bool is_full_screen_; | |
| 151 | |
| 152 // Timer used to detect full-screen mode change. | |
| 153 base::RepeatingTimer full_screen_mode_timer_; | |
| 154 | |
| 155 DISALLOW_COPY_AND_ASSIGN(DisplaySettingsProvider); | |
| 156 }; | |
| 157 | |
| 158 #endif // CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_PROVIDER_H_ | |
| OLD | NEW |