OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_WINDOW_SIZER_H__ | 5 #ifndef CHROME_BROWSER_WINDOW_SIZER_H__ |
6 #define CHROME_BROWSER_WINDOW_SIZER_H__ | 6 #define CHROME_BROWSER_WINDOW_SIZER_H__ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gfx/rect.h" | 11 #include "base/gfx/rect.h" |
12 | 12 |
| 13 class Browser; |
| 14 |
13 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
14 // WindowSizer | 16 // WindowSizer |
15 // | 17 // |
16 // A class that determines the best new size and position for a window to be | 18 // A class that determines the best new size and position for a window to be |
17 // shown at based several factors, including the position and size of the last | 19 // shown at based several factors, including the position and size of the last |
18 // window of the same type, the last saved bounds of the window from the | 20 // window of the same type, the last saved bounds of the window from the |
19 // previous session, and default system metrics if neither of the above two | 21 // previous session, and default system metrics if neither of the above two |
20 // conditions exist. The system has built-in providers for monitor metrics | 22 // conditions exist. The system has built-in providers for monitor metrics |
21 // and persistent storage (using preferences) but can be overrided with mocks | 23 // and persistent storage (using preferences) but can be overrided with mocks |
22 // for testing. | 24 // for testing. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual bool GetPersistentState(gfx::Rect* bounds, | 86 virtual bool GetPersistentState(gfx::Rect* bounds, |
85 bool* maximized) const = 0; | 87 bool* maximized) const = 0; |
86 | 88 |
87 // Retrieve the bounds of the most recent window of the matching type. | 89 // Retrieve the bounds of the most recent window of the matching type. |
88 // Returns true if there was a last active window to retrieve state | 90 // Returns true if there was a last active window to retrieve state |
89 // information from, false otherwise. | 91 // information from, false otherwise. |
90 virtual bool GetLastActiveWindowState(gfx::Rect* bounds) const = 0; | 92 virtual bool GetLastActiveWindowState(gfx::Rect* bounds) const = 0; |
91 }; | 93 }; |
92 | 94 |
93 // Determines the size, position and maximized state for the browser window. | 95 // Determines the size, position and maximized state for the browser window. |
94 // See documentation for DetermineWindowBounds below. | 96 // See documentation for DetermineWindowBounds below. Normally, |
| 97 // |window_bounds| is calculated by calling GetLastActiveWindowState(). To |
| 98 // explicitly specify a particular window to base the bounds on, pass in a |
| 99 // non-NULL value for |browser|. |
95 static void GetBrowserWindowBounds(const std::wstring& app_name, | 100 static void GetBrowserWindowBounds(const std::wstring& app_name, |
96 const gfx::Rect& specified_bounds, | 101 const gfx::Rect& specified_bounds, |
| 102 Browser* browser, |
97 gfx::Rect* window_bounds, | 103 gfx::Rect* window_bounds, |
98 bool* maximized); | 104 bool* maximized); |
99 | 105 |
100 // Returns the default origin for popups of the given size. | 106 // Returns the default origin for popups of the given size. |
101 static gfx::Point GetDefaultPopupOrigin(const gfx::Size& size); | 107 static gfx::Point GetDefaultPopupOrigin(const gfx::Size& size); |
102 | 108 |
103 // Determines the position, size and maximized state for a window as it is | 109 // Determines the position, size and maximized state for a window as it is |
104 // created. This function uses several strategies to figure out optimal size | 110 // created. This function uses several strategies to figure out optimal size |
105 // and placement, first looking for an existing active window, then falling | 111 // and placement, first looking for an existing active window, then falling |
106 // back to persisted data from a previous session, finally utilizing a default | 112 // back to persisted data from a previous session, finally utilizing a default |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 160 |
155 // Providers for persistent storage and monitor metrics. | 161 // Providers for persistent storage and monitor metrics. |
156 StateProvider* state_provider_; | 162 StateProvider* state_provider_; |
157 MonitorInfoProvider* monitor_info_provider_; | 163 MonitorInfoProvider* monitor_info_provider_; |
158 | 164 |
159 DISALLOW_EVIL_CONSTRUCTORS(WindowSizer); | 165 DISALLOW_EVIL_CONSTRUCTORS(WindowSizer); |
160 }; | 166 }; |
161 | 167 |
162 | 168 |
163 #endif // #ifndef CHROME_BROWSER_WINDOW_SIZER_H__ | 169 #endif // #ifndef CHROME_BROWSER_WINDOW_SIZER_H__ |
OLD | NEW |