| 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_WINDOW_SIZER_WINDOW_SIZER_H_ | 5 #ifndef CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ |
| 6 #define CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ | 6 #define CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/host_desktop.h" | 10 #include "chrome/browser/ui/host_desktop.h" |
| 11 #include "ui/base/ui_base_types.h" | 11 #include "ui/base/ui_base_types.h" |
| 12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
| 13 | 13 |
| 14 class Browser; | 14 class Browser; |
| 15 | 15 |
| 16 // An interface implemented by an object that can retrieve information about | 16 namespace gfx { |
| 17 // the monitors on the system. | 17 class Screen; |
| 18 class MonitorInfoProvider { | 18 } |
| 19 public: | |
| 20 virtual ~MonitorInfoProvider() {} | |
| 21 | |
| 22 // Returns the bounds of the work area of the primary monitor. | |
| 23 virtual gfx::Rect GetPrimaryDisplayWorkArea() const = 0; | |
| 24 | |
| 25 // Returns the bounds of the primary monitor. | |
| 26 virtual gfx::Rect GetPrimaryDisplayBounds() const = 0; | |
| 27 | |
| 28 // Returns the bounds of the work area of the monitor that most closely | |
| 29 // intersects the provided bounds. | |
| 30 virtual gfx::Rect GetMonitorWorkAreaMatching( | |
| 31 const gfx::Rect& match_rect) const = 0; | |
| 32 }; | |
| 33 | 19 |
| 34 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
| 35 // WindowSizer | 21 // WindowSizer |
| 36 // | 22 // |
| 37 // A class that determines the best new size and position for a window to be | 23 // A class that determines the best new size and position for a window to be |
| 38 // shown at based several factors, including the position and size of the last | 24 // shown at based several factors, including the position and size of the last |
| 39 // window of the same type, the last saved bounds of the window from the | 25 // window of the same type, the last saved bounds of the window from the |
| 40 // previous session, and default system metrics if neither of the above two | 26 // previous session, and default system metrics if neither of the above two |
| 41 // conditions exist. The system has built-in providers for monitor metrics | 27 // conditions exist. The system has built-in providers for monitor metrics |
| 42 // and persistent storage (using preferences) but can be overrided with mocks | 28 // and persistent storage (using preferences) but can be overrided with mocks |
| 43 // for testing. | 29 // for testing. |
| 44 // | 30 // |
| 45 class WindowSizer { | 31 class WindowSizer { |
| 46 public: | 32 public: |
| 47 class StateProvider; | 33 class StateProvider; |
| 48 | 34 |
| 49 // WindowSizer owns |state_provider| and will create a default | 35 // WindowSizer owns |state_provider| and will create a default |
| 50 // MonitorInfoProvider using the physical screen. | 36 // MonitorInfoProvider using the physical screen. |
| 51 WindowSizer(StateProvider* state_provider, const Browser* browser); | 37 WindowSizer(StateProvider* state_provider, const Browser* browser); |
| 52 | 38 |
| 53 // WindowSizer owns |state_provider| and |monitor_info_provider|. | 39 // WindowSizer owns |state_provider| and will use the supplied |screen|. |
| 54 // It will use the supplied monitor info provider. Used only for testing. | 40 // Used only for testing. |
| 55 WindowSizer(StateProvider* state_provider, | 41 WindowSizer(StateProvider* state_provider, |
| 56 MonitorInfoProvider* monitor_info_provider, | 42 gfx::Screen* screen, |
| 57 const Browser* browser); | 43 const Browser* browser); |
| 58 | 44 |
| 59 virtual ~WindowSizer(); | 45 virtual ~WindowSizer(); |
| 60 | 46 |
| 61 // An interface implemented by an object that can retrieve state from either a | 47 // An interface implemented by an object that can retrieve state from either a |
| 62 // persistent store or an existing window. | 48 // persistent store or an existing window. |
| 63 class StateProvider { | 49 class StateProvider { |
| 64 public: | 50 public: |
| 65 virtual ~StateProvider() {} | 51 virtual ~StateProvider() {} |
| 66 | 52 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 bool GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, | 164 bool GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, |
| 179 ui::WindowShowState* show_state) const; | 165 ui::WindowShowState* show_state) const; |
| 180 #endif | 166 #endif |
| 181 | 167 |
| 182 // Determine the default show state for the window - not looking at other | 168 // Determine the default show state for the window - not looking at other |
| 183 // windows or at persistent information. | 169 // windows or at persistent information. |
| 184 ui::WindowShowState GetWindowDefaultShowState() const; | 170 ui::WindowShowState GetWindowDefaultShowState() const; |
| 185 | 171 |
| 186 // Providers for persistent storage and monitor metrics. | 172 // Providers for persistent storage and monitor metrics. |
| 187 scoped_ptr<StateProvider> state_provider_; | 173 scoped_ptr<StateProvider> state_provider_; |
| 188 scoped_ptr<MonitorInfoProvider> monitor_info_provider_; | 174 gfx::Screen* screen_; // not owned. |
| 189 | 175 |
| 190 // Note that this browser handle might be NULL. | 176 // Note that this browser handle might be NULL. |
| 191 const Browser* browser_; | 177 const Browser* browser_; |
| 192 | 178 |
| 193 DISALLOW_COPY_AND_ASSIGN(WindowSizer); | 179 DISALLOW_COPY_AND_ASSIGN(WindowSizer); |
| 194 }; | 180 }; |
| 195 | 181 |
| 196 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ | 182 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ |
| OLD | NEW |