OLD | NEW |
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_PANEL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/timer.h" |
13 #include "chrome/browser/ui/panels/display_settings_provider.h" | 14 #include "chrome/browser/ui/panels/display_settings_provider.h" |
14 #include "chrome/browser/ui/panels/panel.h" | 15 #include "chrome/browser/ui/panels/panel.h" |
15 #include "chrome/browser/ui/panels/panel_constants.h" | 16 #include "chrome/browser/ui/panels/panel_constants.h" |
16 #include "chrome/browser/ui/panels/panel_strip.h" | 17 #include "chrome/browser/ui/panels/panel_strip.h" |
17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
18 | 19 |
19 class Browser; | 20 class Browser; |
20 class DetachedPanelStrip; | 21 class DetachedPanelStrip; |
21 class DockedPanelStrip; | 22 class DockedPanelStrip; |
22 class OverflowPanelStrip; | 23 class OverflowPanelStrip; |
23 class PanelDragController; | 24 class PanelDragController; |
24 class PanelResizeController; | 25 class PanelResizeController; |
25 class PanelMouseWatcher; | 26 class PanelMouseWatcher; |
26 | 27 |
27 // This class manages a set of panels. | 28 // This class manages a set of panels. |
28 class PanelManager : public DisplaySettingsProvider::DisplayAreaObserver, | 29 class PanelManager : public DisplaySettingsProvider::DisplayAreaObserver { |
29 public DisplaySettingsProvider::FullScreenObserver { | |
30 public: | 30 public: |
31 // Returns a single instance. | 31 // Returns a single instance. |
32 static PanelManager* GetInstance(); | 32 static PanelManager* GetInstance(); |
33 | 33 |
34 // Returns true if panels should be used for the extension. | 34 // Returns true if panels should be used for the extension. |
35 static bool ShouldUsePanels(const std::string& extension_id); | 35 static bool ShouldUsePanels(const std::string& extension_id); |
36 | 36 |
37 // Creates a panel and returns it. The panel might be queued for display | 37 // Creates a panel and returns it. The panel might be queued for display |
38 // later. | 38 // later. |
39 Panel* CreatePanel(Browser* browser); | 39 Panel* CreatePanel(Browser* browser); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 DetachedPanelStrip* detached_strip() const { | 119 DetachedPanelStrip* detached_strip() const { |
120 return detached_strip_.get(); | 120 return detached_strip_.get(); |
121 } | 121 } |
122 | 122 |
123 DockedPanelStrip* docked_strip() const { | 123 DockedPanelStrip* docked_strip() const { |
124 return docked_strip_.get(); | 124 return docked_strip_.get(); |
125 } | 125 } |
126 | 126 |
| 127 bool is_full_screen() const { return is_full_screen_; } |
127 OverflowPanelStrip* overflow_strip() const { | 128 OverflowPanelStrip* overflow_strip() const { |
128 return overflow_strip_.get(); | 129 return overflow_strip_.get(); |
129 } | 130 } |
130 | 131 |
131 // Width of the overflow strip in compact state i.e mouse not hovering over. | 132 // Width of the overflow strip in compact state i.e mouse not hovering over. |
132 int overflow_strip_width() const; | 133 int overflow_strip_width() const; |
133 | 134 |
134 // Reduces time interval in tests to shorten test run time. | 135 // Reduces time interval in tests to shorten test run time. |
135 // Wrapper should be used around all time intervals in panels code. | 136 // Wrapper should be used around all time intervals in panels code. |
136 static inline double AdjustTimeInterval(double interval) { | 137 static inline double AdjustTimeInterval(double interval) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 private: | 173 private: |
173 friend struct base::DefaultLazyInstanceTraits<PanelManager>; | 174 friend struct base::DefaultLazyInstanceTraits<PanelManager>; |
174 | 175 |
175 PanelManager(); | 176 PanelManager(); |
176 virtual ~PanelManager(); | 177 virtual ~PanelManager(); |
177 | 178 |
178 // Overridden from DisplaySettingsProvider::DisplayAreaObserver: | 179 // Overridden from DisplaySettingsProvider::DisplayAreaObserver: |
179 virtual void OnDisplayAreaChanged(const gfx::Rect& display_area) OVERRIDE; | 180 virtual void OnDisplayAreaChanged(const gfx::Rect& display_area) OVERRIDE; |
180 | 181 |
181 // Overridden from DisplaySettingsProvider::FullScreenObserver: | 182 // Tests if the current active app is in full screen mode. |
182 virtual void OnFullScreenModeChanged(bool is_full_screen) OVERRIDE; | 183 void CheckFullScreenMode(); |
183 | 184 |
184 // Tests may want to use a mock panel mouse watcher. | 185 // Tests may want to use a mock panel mouse watcher. |
185 void SetMouseWatcher(PanelMouseWatcher* watcher); | 186 void SetMouseWatcher(PanelMouseWatcher* watcher); |
186 | 187 |
187 // Tests may want to shorten time intervals to reduce running time. | 188 // Tests may want to shorten time intervals to reduce running time. |
188 static bool shorten_time_intervals_; | 189 static bool shorten_time_intervals_; |
189 | 190 |
190 scoped_ptr<DetachedPanelStrip> detached_strip_; | 191 scoped_ptr<DetachedPanelStrip> detached_strip_; |
191 scoped_ptr<DockedPanelStrip> docked_strip_; | 192 scoped_ptr<DockedPanelStrip> docked_strip_; |
192 scoped_ptr<OverflowPanelStrip> overflow_strip_; | 193 scoped_ptr<OverflowPanelStrip> overflow_strip_; |
193 | 194 |
194 scoped_ptr<PanelDragController> drag_controller_; | 195 scoped_ptr<PanelDragController> drag_controller_; |
195 scoped_ptr<PanelResizeController> resize_controller_; | 196 scoped_ptr<PanelResizeController> resize_controller_; |
196 | 197 |
197 // Use a mouse watcher to know when to bring up titlebars to "peek" at | 198 // Use a mouse watcher to know when to bring up titlebars to "peek" at |
198 // minimized panels. Mouse movement is only tracked when there is a minimized | 199 // minimized panels. Mouse movement is only tracked when there is a minimized |
199 // panel. | 200 // panel. |
200 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; | 201 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; |
201 | 202 |
202 scoped_ptr<DisplaySettingsProvider> display_settings_provider_; | 203 scoped_ptr<DisplaySettingsProvider> display_settings_provider_; |
203 | 204 |
204 // Whether or not bounds will be updated when the preferred content size is | 205 // Whether or not bounds will be updated when the preferred content size is |
205 // changed. The testing code could set this flag to false so that other tests | 206 // changed. The testing code could set this flag to false so that other tests |
206 // will not be affected. | 207 // will not be affected. |
207 bool auto_sizing_enabled_; | 208 bool auto_sizing_enabled_; |
208 | 209 |
| 210 // Timer used to track if the current active app is in full screen mode. |
| 211 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; |
| 212 |
| 213 // True if current active app is in full screen mode. |
| 214 bool is_full_screen_; |
| 215 |
209 // True only while moving panels to overflow. Used to prevent moving panels | 216 // True only while moving panels to overflow. Used to prevent moving panels |
210 // out of overflow while in the process of moving panels to overflow. | 217 // out of overflow while in the process of moving panels to overflow. |
211 bool is_processing_overflow_; | 218 bool is_processing_overflow_; |
212 | 219 |
213 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 220 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
214 }; | 221 }; |
215 | 222 |
216 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 223 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
OLD | NEW |