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" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 virtual bool GetLastActiveWindowState(gfx::Rect* bounds) const = 0; | 74 virtual bool GetLastActiveWindowState(gfx::Rect* bounds) const = 0; |
75 }; | 75 }; |
76 | 76 |
77 // Determines the position and size for a window as it is created. This | 77 // Determines the position and size for a window as it is created. This |
78 // function uses several strategies to figure out optimal size and placement, | 78 // function uses several strategies to figure out optimal size and placement, |
79 // first looking for an existing active window, then falling back to persisted | 79 // first looking for an existing active window, then falling back to persisted |
80 // data from a previous session, finally utilizing a default | 80 // data from a previous session, finally utilizing a default |
81 // algorithm. If |specified_bounds| are non-empty, this value is returned | 81 // algorithm. If |specified_bounds| are non-empty, this value is returned |
82 // instead. For use only in testing. | 82 // instead. For use only in testing. |
83 void DetermineWindowBounds(const gfx::Rect& specified_bounds, | 83 void DetermineWindowBounds(const gfx::Rect& specified_bounds, |
84 gfx::Rect* bounds) const; | 84 gfx::Rect* bounds, |
| 85 const Browser* browser) const; |
85 | 86 |
86 // Determines the size, position and maximized state for the browser window. | 87 // Determines the size, position and maximized state for the browser window. |
87 // See documentation for DetermineWindowBounds above. Normally, | 88 // See documentation for DetermineWindowBounds above. Normally, |
88 // |window_bounds| is calculated by calling GetLastActiveWindowState(). To | 89 // |window_bounds| is calculated by calling GetLastActiveWindowState(). To |
89 // explicitly specify a particular window to base the bounds on, pass in a | 90 // explicitly specify a particular window to base the bounds on, pass in a |
90 // non-NULL value for |browser|. | 91 // non-NULL value for |browser|. |
91 static void GetBrowserWindowBounds(const std::string& app_name, | 92 static void GetBrowserWindowBounds(const std::string& app_name, |
92 const gfx::Rect& specified_bounds, | 93 const gfx::Rect& specified_bounds, |
93 const Browser* browser, | 94 const Browser* browser, |
94 gfx::Rect* window_bounds); | 95 gfx::Rect* window_bounds); |
(...skipping 13 matching lines...) Expand all Loading... |
108 // opened windows. This value may be different on each platform. | 109 // opened windows. This value may be different on each platform. |
109 static const int kWindowTilePixels; | 110 static const int kWindowTilePixels; |
110 | 111 |
111 private: | 112 private: |
112 // The edge of the screen to check for out-of-bounds. | 113 // The edge of the screen to check for out-of-bounds. |
113 enum Edge { TOP, LEFT, BOTTOM, RIGHT }; | 114 enum Edge { TOP, LEFT, BOTTOM, RIGHT }; |
114 | 115 |
115 // Gets the size and placement of the last window. Returns true if this data | 116 // Gets the size and placement of the last window. Returns true if this data |
116 // is valid, false if there is no last window and the application should | 117 // is valid, false if there is no last window and the application should |
117 // restore saved state from preferences using RestoreWindowPosition. | 118 // restore saved state from preferences using RestoreWindowPosition. |
118 bool GetLastWindowBounds(gfx::Rect* bounds) const; | 119 bool GetLastWindowBounds(gfx::Rect* bounds, const Browser* browser) const; |
119 | 120 |
120 // Gets the size and placement of the last window in the last session, saved | 121 // Gets the size and placement of the last window in the last session, saved |
121 // in local state preferences. Returns true if local state exists containing | 122 // in local state preferences. Returns true if local state exists containing |
122 // this information, false if this information does not exist and a default | 123 // this information, false if this information does not exist and a default |
123 // size should be used. | 124 // size should be used. |
124 bool GetSavedWindowBounds(gfx::Rect* bounds) const; | 125 bool GetSavedWindowBounds(gfx::Rect* bounds, const Browser* browser) const; |
125 | 126 |
126 // Gets the default window position and size if there is no last window and | 127 // Gets the default window position and size if there is no last window and |
127 // no saved window placement in prefs. This function determines the default | 128 // no saved window placement in prefs. This function determines the default |
128 // size based on monitor size, etc. | 129 // size based on monitor size, etc. |
129 void GetDefaultWindowBounds(gfx::Rect* default_bounds) const; | 130 void GetDefaultWindowBounds(gfx::Rect* default_bounds, |
| 131 const Browser* browser) const; |
130 #if defined(USE_ASH) | 132 #if defined(USE_ASH) |
131 void GetDefaultWindowBoundsAsh(gfx::Rect* default_bounds) const; | 133 void GetDefaultWindowBoundsAsh(gfx::Rect* default_bounds) const; |
132 #endif | 134 #endif |
133 | 135 |
134 // Adjusts |bounds| to be visible on-screen, biased toward the work area of | 136 // Adjusts |bounds| to be visible on-screen, biased toward the work area of |
135 // the monitor containing |other_bounds|. Despite the name, this doesn't | 137 // the monitor containing |other_bounds|. Despite the name, this doesn't |
136 // guarantee the bounds are fully contained within this monitor's work rect; | 138 // guarantee the bounds are fully contained within this monitor's work rect; |
137 // it just tried to ensure the edges are visible on _some_ work rect. | 139 // it just tried to ensure the edges are visible on _some_ work rect. |
138 // If |saved_work_area| is non-empty, it is used to determine whether the | 140 // If |saved_work_area| is non-empty, it is used to determine whether the |
139 // monitor configuration has changed. If it has, bounds are repositioned and | 141 // monitor configuration has changed. If it has, bounds are repositioned and |
140 // resized if necessary to make them completely contained in the current work | 142 // resized if necessary to make them completely contained in the current work |
141 // area. | 143 // area. |
142 void AdjustBoundsToBeVisibleOnMonitorContaining( | 144 void AdjustBoundsToBeVisibleOnMonitorContaining( |
143 const gfx::Rect& other_bounds, | 145 const gfx::Rect& other_bounds, |
144 const gfx::Rect& saved_work_area, | 146 const gfx::Rect& saved_work_area, |
145 gfx::Rect* bounds) const; | 147 gfx::Rect* bounds, |
| 148 const Browser* browser) const; |
146 | 149 |
147 // Determines the position and size for a window as it gets created. This | 150 // Determines the position and size for a window as it gets created. This |
148 // will be called before DetermineWindowBounds. It will return true when the | 151 // will be called before DetermineWindowBounds. It will return true when the |
149 // function was setting the bounds structure to the desired size. Otherwise | 152 // function was setting the bounds structure to the desired size. Otherwise |
150 // another algorithm should get used to determine the correct bounds. | 153 // another algorithm should get used to determine the correct bounds. |
151 bool GetBoundsOverride(const gfx::Rect& specified_bounds, | 154 bool GetBoundsOverride(const gfx::Rect& specified_bounds, |
152 gfx::Rect* bounds) const; | 155 gfx::Rect* bounds, |
| 156 const Browser* browser) const; |
153 #if defined(USE_ASH) | 157 #if defined(USE_ASH) |
154 bool GetBoundsOverrideAsh(const gfx::Rect& specified_bounds, | 158 bool GetBoundsOverrideAsh(const gfx::Rect& specified_bounds, |
155 gfx::Rect* bounds_in_screen) const; | 159 gfx::Rect* bounds_in_screen, |
| 160 const Browser* browser) const; |
156 #endif | 161 #endif |
157 | 162 |
158 // Providers for persistent storage and monitor metrics. | 163 // Providers for persistent storage and monitor metrics. |
159 scoped_ptr<StateProvider> state_provider_; | 164 scoped_ptr<StateProvider> state_provider_; |
160 scoped_ptr<MonitorInfoProvider> monitor_info_provider_; | 165 scoped_ptr<MonitorInfoProvider> monitor_info_provider_; |
161 | 166 |
162 // Note that this browser handle might be NULL. | 167 // Note that this browser handle might be NULL. |
163 const Browser* browser_; | 168 const Browser* browser_; |
164 | 169 |
165 DISALLOW_COPY_AND_ASSIGN(WindowSizer); | 170 DISALLOW_COPY_AND_ASSIGN(WindowSizer); |
166 }; | 171 }; |
167 | 172 |
168 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ | 173 #endif // CHROME_BROWSER_UI_WINDOW_SIZER_WINDOW_SIZER_H_ |
OLD | NEW |