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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 scoped_ptr<StateProvider> state_provider( | 217 scoped_ptr<StateProvider> state_provider( |
218 new DefaultStateProvider(app_name, browser)); | 218 new DefaultStateProvider(app_name, browser)); |
219 scoped_ptr<TargetDisplayProvider> target_display_provider( | 219 scoped_ptr<TargetDisplayProvider> target_display_provider( |
220 new DefaultTargetDisplayProvider); | 220 new DefaultTargetDisplayProvider); |
221 const WindowSizer sizer(state_provider.Pass(), | 221 const WindowSizer sizer(state_provider.Pass(), |
222 target_display_provider.Pass(), | 222 target_display_provider.Pass(), |
223 browser); | 223 browser); |
224 sizer.DetermineWindowBoundsAndShowState(specified_bounds, | 224 sizer.DetermineWindowBoundsAndShowState(specified_bounds, |
225 window_bounds, | 225 window_bounds, |
226 show_state); | 226 show_state); |
| 227 if (*show_state == ui::SHOW_STATE_DEFAULT) { |
| 228 gfx::Display display = sizer.GetTargetDisplay(*window_bounds); |
| 229 if (*window_bounds == display.work_area()) { |
| 230 // A window that occupies the whole work area gets maximized. |
| 231 // |window_bounds| returned here become the restore bounds once the window |
| 232 // gets maximized after this method returns. Return a sensible default |
| 233 // in order to make restored state visibly different from maximized. |
| 234 *show_state = ui::SHOW_STATE_MAXIMIZED; |
| 235 sizer.GetDefaultWindowBounds(display, window_bounds); |
| 236 } |
| 237 } |
227 } | 238 } |
228 | 239 |
229 /////////////////////////////////////////////////////////////////////////////// | 240 /////////////////////////////////////////////////////////////////////////////// |
230 // WindowSizer, private: | 241 // WindowSizer, private: |
231 | 242 |
232 void WindowSizer::DetermineWindowBoundsAndShowState( | 243 void WindowSizer::DetermineWindowBoundsAndShowState( |
233 const gfx::Rect& specified_bounds, | 244 const gfx::Rect& specified_bounds, |
234 gfx::Rect* bounds, | 245 gfx::Rect* bounds, |
235 ui::WindowShowState* show_state) const { | 246 ui::WindowShowState* show_state) const { |
236 DCHECK(bounds); | 247 DCHECK(bounds); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 446 |
436 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) | 447 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
437 return ui::SHOW_STATE_MAXIMIZED; | 448 return ui::SHOW_STATE_MAXIMIZED; |
438 | 449 |
439 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 450 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
440 return browser_->initial_show_state(); | 451 return browser_->initial_show_state(); |
441 | 452 |
442 // Otherwise we use the default which can be overridden later on. | 453 // Otherwise we use the default which can be overridden later on. |
443 return ui::SHOW_STATE_DEFAULT; | 454 return ui::SHOW_STATE_DEFAULT; |
444 } | 455 } |
OLD | NEW |