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 } else if (browser_ && browser_->host_desktop_type() == | |
200 chrome::HOST_DESKTOP_TYPE_ASH) { | |
oshima
2013/08/31 00:54:56
This may look odd, but WindowSizerAsh::TestShowSta
sky
2013/09/03 15:58:36
Not sure either.
oshima
2013/09/03 18:15:27
I'll keep this to make sure the logic stays the sa
| |
201 GetSavedWindowBounds(bounds, show_state); | |
202 } | |
201 #endif | 203 #endif |
202 // See if there's last active window's placement information. | 204 // See if there's last active window's placement information. |
203 if (GetLastWindowBounds(bounds, show_state)) | 205 if (GetLastWindowBounds(bounds, show_state)) |
204 return; | 206 return; |
205 // See if there's saved placement information. | 207 // See if there's saved placement information. |
206 if (GetSavedWindowBounds(bounds, show_state)) | 208 if (GetSavedWindowBounds(bounds, show_state)) |
207 return; | 209 return; |
208 // No saved placement, figure out some sensible default size based on | 210 // No saved placement, figure out some sensible default size based on |
209 // the user's screen size. | 211 // the user's screen size. |
210 GetDefaultWindowBounds(bounds); | 212 GetDefaultWindowBounds(bounds); |
211 } else { | 213 } else { |
212 #if defined(USE_ASH) | 214 #if defined(USE_ASH) |
213 // In case of a popup with an 'unspecified' location in ash, we are | 215 // 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 | 216 // looking for a good screen location. We are interpreting (0,0) as an |
215 // unspecified location. | 217 // unspecified location. |
216 if (chrome::ShouldOpenAshOnStartup() && | 218 if (IsPopupBrowserInAsh() && bounds->origin().IsOrigin()) { |
217 browser_ && browser_->is_type_popup() && | |
218 bounds->x() == 0 && bounds->y() == 0) { | |
219 *bounds = ChromeShellDelegate::instance()->window_positioner()-> | 219 *bounds = ChromeShellDelegate::instance()->window_positioner()-> |
220 GetPopupPosition(*bounds); | 220 GetPopupPosition(*bounds); |
221 return; | 221 return; |
222 } | 222 } |
223 #endif | 223 #endif |
224 // In case that there was a bound given we need to make sure that it is | 224 // In case that there was a bound given we need to make sure that it is |
225 // visible and fits on the screen. | 225 // visible and fits on the screen. |
226 // Find the size of the work area of the monitor that intersects the bounds | 226 // Find the size of the work area of the monitor that intersects the bounds |
227 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining | 227 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining |
228 // does not exactly what we want: It makes only sure that "a minimal part" | 228 // 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 | 392 |
393 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) | 393 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
394 return ui::SHOW_STATE_MAXIMIZED; | 394 return ui::SHOW_STATE_MAXIMIZED; |
395 | 395 |
396 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 396 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
397 return browser_->initial_show_state(); | 397 return browser_->initial_show_state(); |
398 | 398 |
399 // Otherwise we use the default which can be overridden later on. | 399 // Otherwise we use the default which can be overridden later on. |
400 return ui::SHOW_STATE_DEFAULT; | 400 return ui::SHOW_STATE_DEFAULT; |
401 } | 401 } |
402 | |
403 bool WindowSizer::IsTabbedBrowserInAsh() const { | |
404 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 | |
405 return chrome::ShouldOpenAshOnStartup() && | |
sky
2013/09/03 15:58:36
Why is this and the next checking ShouldOpenAshOnS
oshima
2013/09/03 18:15:27
My understanding is that this is necessary for win
Mr4D (OOO till 08-26)
2013/09/03 18:21:28
I might be mistaken - but you should not get here
oshima
2013/09/03 18:36:56
Sorry, I didn't get it. What do you mean?
sky
2013/09/03 20:47:31
Isn't the host_desktop_type enough?
| |
406 browser_ && | |
407 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && | |
408 browser_->is_type_tabbed(); | |
409 } | |
410 | |
411 bool WindowSizer::IsPopupBrowserInAsh() const { | |
412 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 | |
413 return chrome::ShouldOpenAshOnStartup() && | |
414 browser_ && | |
415 browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH && | |
416 browser_->is_type_popup(); | |
417 } | |
OLD | NEW |