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 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 gfx::Rect* bounds, | 186 gfx::Rect* bounds, |
187 ui::WindowShowState* show_state) const { | 187 ui::WindowShowState* show_state) const { |
188 DCHECK(bounds); | 188 DCHECK(bounds); |
189 DCHECK(show_state); | 189 DCHECK(show_state); |
190 // Pre-populate the window state with our default. | 190 // Pre-populate the window state with our default. |
191 *show_state = GetWindowDefaultShowState(); | 191 *show_state = GetWindowDefaultShowState(); |
192 *bounds = specified_bounds; | 192 *bounds = specified_bounds; |
193 if (bounds->IsEmpty()) { | 193 if (bounds->IsEmpty()) { |
194 #if defined(USE_ASH) | 194 #if defined(USE_ASH) |
195 // See if ash should decide the window placement. | 195 // See if ash should decide the window placement. |
196 // TODO(beng): insufficient but currently necessary. | 196 if (IsTabbedBrowserInAsh()) { |
197 // http://crbug.com/133312 | 197 GetBoundsOverrideAsh(bounds, show_state); |
198 if (chrome::ShouldOpenAshOnStartup() && | |
199 GetBoundsOverrideAsh(bounds, show_state)) | |
200 return; | 198 return; |
| 199 } |
201 #endif | 200 #endif |
202 // See if there's last active window's placement information. | 201 // See if there's last active window's placement information. |
203 if (GetLastWindowBounds(bounds, show_state)) | 202 if (GetLastWindowBounds(bounds, show_state)) |
204 return; | 203 return; |
205 // See if there's saved placement information. | 204 // See if there's saved placement information. |
206 if (GetSavedWindowBounds(bounds, show_state)) | 205 if (GetSavedWindowBounds(bounds, show_state)) |
207 return; | 206 return; |
208 // No saved placement, figure out some sensible default size based on | 207 // No saved placement, figure out some sensible default size based on |
209 // the user's screen size. | 208 // the user's screen size. |
210 GetDefaultWindowBounds(bounds); | 209 GetDefaultWindowBounds(bounds); |
211 } else { | 210 } else { |
212 #if defined(USE_ASH) | 211 #if defined(USE_ASH) |
213 // In case of a popup with an 'unspecified' location in ash, we are | 212 // In case of a popup with an 'unspecified' location in ash, we are |
214 // looking for a good screen location. We are interpreting (0,0) as an | 213 // looking for a good screen location. We are interpreting (0,0) as an |
215 // unspecified location. | 214 // unspecified location. |
216 if (chrome::ShouldOpenAshOnStartup() && | 215 if (IsPopupBrowserInAsh() && bounds->origin().IsOrigin()) { |
217 browser_ && browser_->is_type_popup() && | |
218 bounds->x() == 0 && bounds->y() == 0) { | |
219 *bounds = ChromeShellDelegate::instance()->window_positioner()-> | 216 *bounds = ChromeShellDelegate::instance()->window_positioner()-> |
220 GetPopupPosition(*bounds); | 217 GetPopupPosition(*bounds); |
221 return; | 218 return; |
222 } | 219 } |
223 #endif | 220 #endif |
224 // In case that there was a bound given we need to make sure that it is | 221 // In case that there was a bound given we need to make sure that it is |
225 // visible and fits on the screen. | 222 // visible and fits on the screen. |
226 // Find the size of the work area of the monitor that intersects the bounds | 223 // Find the size of the work area of the monitor that intersects the bounds |
227 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining | 224 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining |
228 // does not exactly what we want: It makes only sure that "a minimal part" | 225 // does not exactly what we want: It makes only sure that "a minimal part" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 389 |
393 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) | 390 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
394 return ui::SHOW_STATE_MAXIMIZED; | 391 return ui::SHOW_STATE_MAXIMIZED; |
395 | 392 |
396 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 393 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
397 return browser_->initial_show_state(); | 394 return browser_->initial_show_state(); |
398 | 395 |
399 // Otherwise we use the default which can be overridden later on. | 396 // Otherwise we use the default which can be overridden later on. |
400 return ui::SHOW_STATE_DEFAULT; | 397 return ui::SHOW_STATE_DEFAULT; |
401 } | 398 } |
| 399 |
| 400 bool WindowSizer::IsTabbedBrowserInAsh() const { |
| 401 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 |
| 402 return chrome::ShouldOpenAshOnStartup() && |
| 403 browser_ && |
| 404 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && |
| 405 browser_->is_type_tabbed(); |
| 406 } |
| 407 |
| 408 bool WindowSizer::IsPopupBrowserInAsh() const { |
| 409 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 |
| 410 return chrome::ShouldOpenAshOnStartup() && |
| 411 browser_ && |
| 412 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && |
| 413 browser_->is_type_popup(); |
| 414 } |
OLD | NEW |