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 <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "ui/base/ui_base_types.h" | 11 #include "ui/base/ui_base_types.h" |
11 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
12 | 13 |
13 class Browser; | 14 class Browser; |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 class Display; | 17 class Display; |
17 class Screen; | 18 class Screen; |
18 } | 19 } |
19 | 20 |
20 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
21 // WindowSizer | 22 // WindowSizer |
22 // | 23 // |
23 // A class that determines the best new size and position for a window to be | 24 // A class that determines the best new size and position for a window to be |
24 // shown at based several factors, including the position and size of the last | 25 // shown at based several factors, including the position and size of the last |
25 // window of the same type, the last saved bounds of the window from the | 26 // window of the same type, the last saved bounds of the window from the |
26 // previous session, and default system metrics if neither of the above two | 27 // previous session, and default system metrics if neither of the above two |
27 // conditions exist. The system has built-in providers for monitor metrics | 28 // conditions exist. The system has built-in providers for monitor metrics |
28 // and persistent storage (using preferences) but can be overrided with mocks | 29 // and persistent storage (using preferences) but can be overrided with mocks |
29 // for testing. | 30 // for testing. |
30 // | 31 // |
31 class WindowSizer { | 32 class WindowSizer { |
32 public: | 33 public: |
33 class StateProvider; | 34 class StateProvider; |
34 class TargetDisplayProvider; | 35 class TargetDisplayProvider; |
35 | 36 |
36 // WindowSizer owns |state_provider| and |target_display_provider|, | 37 // WindowSizer owns |state_provider| and |target_display_provider|, |
37 // and will use the platforms's gfx::Screen. | 38 // and will use the platforms's gfx::Screen. |
38 WindowSizer(scoped_ptr<StateProvider> state_provider, | 39 WindowSizer(std::unique_ptr<StateProvider> state_provider, |
39 scoped_ptr<TargetDisplayProvider> target_display_provider, | 40 std::unique_ptr<TargetDisplayProvider> target_display_provider, |
40 const Browser* browser); | 41 const Browser* browser); |
41 | 42 |
42 // WindowSizer owns |state_provider| and |target_display_provider|, | 43 // WindowSizer owns |state_provider| and |target_display_provider|, |
43 // and will use the supplied |screen|. Used only for testing. | 44 // and will use the supplied |screen|. Used only for testing. |
44 WindowSizer(scoped_ptr<StateProvider> state_provider, | 45 WindowSizer(std::unique_ptr<StateProvider> state_provider, |
45 scoped_ptr<TargetDisplayProvider> target_display_provider, | 46 std::unique_ptr<TargetDisplayProvider> target_display_provider, |
46 gfx::Screen* screen, | 47 gfx::Screen* screen, |
47 const Browser* browser); | 48 const Browser* browser); |
48 | 49 |
49 virtual ~WindowSizer(); | 50 virtual ~WindowSizer(); |
50 | 51 |
51 // An interface implemented by an object that can retrieve state from either a | 52 // An interface implemented by an object that can retrieve state from either a |
52 // persistent store or an existing window. | 53 // persistent store or an existing window. |
53 class StateProvider { | 54 class StateProvider { |
54 public: | 55 public: |
55 virtual ~StateProvider() {} | 56 virtual ~StateProvider() {} |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // if it was set to SHOW_STATE_DEFAULT. | 174 // if it was set to SHOW_STATE_DEFAULT. |
174 void GetTabbedBrowserBoundsAsh(gfx::Rect* bounds, | 175 void GetTabbedBrowserBoundsAsh(gfx::Rect* bounds, |
175 ui::WindowShowState* show_state) const; | 176 ui::WindowShowState* show_state) const; |
176 #endif | 177 #endif |
177 | 178 |
178 // Determine the default show state for the window - not looking at other | 179 // Determine the default show state for the window - not looking at other |
179 // windows or at persistent information. | 180 // windows or at persistent information. |
180 ui::WindowShowState GetWindowDefaultShowState() const; | 181 ui::WindowShowState GetWindowDefaultShowState() const; |
181 | 182 |
182 // Providers for persistent storage and monitor metrics. | 183 // Providers for persistent storage and monitor metrics. |
183 scoped_ptr<StateProvider> state_provider_; | 184 std::unique_ptr<StateProvider> state_provider_; |
184 scoped_ptr<TargetDisplayProvider> target_display_provider_; | 185 std::unique_ptr<TargetDisplayProvider> target_display_provider_; |
185 gfx::Screen* screen_; // not owned. | 186 gfx::Screen* screen_; // not owned. |
186 | 187 |
187 // Note that this browser handle might be NULL. | 188 // Note that this browser handle might be NULL. |
188 const Browser* browser_; | 189 const Browser* browser_; |
189 | 190 |
190 DISALLOW_COPY_AND_ASSIGN(WindowSizer); | 191 DISALLOW_COPY_AND_ASSIGN(WindowSizer); |
191 }; | 192 }; |
192 | 193 |
193 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ | 194 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ |
OLD | NEW |