| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider { | 154 class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider { |
| 155 public: | 155 public: |
| 156 DefaultTargetDisplayProvider() {} | 156 DefaultTargetDisplayProvider() {} |
| 157 ~DefaultTargetDisplayProvider() override {} | 157 ~DefaultTargetDisplayProvider() override {} |
| 158 | 158 |
| 159 display::Display GetTargetDisplay(const display::Screen* screen, | 159 display::Display GetTargetDisplay(const display::Screen* screen, |
| 160 const gfx::Rect& bounds) const override { | 160 const gfx::Rect& bounds) const override { |
| 161 #if defined(USE_ASH) | 161 #if defined(USE_ASH) |
| 162 // Use the target display on ash. | 162 // Use the target display on ash. |
| 163 if (ash_util::ShouldOpenAshOnStartup()) { | 163 if (ShouldOpenAshOnStartup()) { |
| 164 aura::Window* target = ash::Shell::GetTargetRootWindow(); | 164 aura::Window* target = ash::Shell::GetTargetRootWindow(); |
| 165 return screen->GetDisplayNearestWindow(target); | 165 return screen->GetDisplayNearestWindow(target); |
| 166 } | 166 } |
| 167 #endif | 167 #endif |
| 168 // Find the size of the work area of the monitor that intersects the bounds | 168 // Find the size of the work area of the monitor that intersects the bounds |
| 169 // of the anchor window. | 169 // of the anchor window. |
| 170 return screen->GetDisplayMatching(bounds); | 170 return screen->GetDisplayMatching(bounds); |
| 171 } | 171 } |
| 172 | 172 |
| 173 private: | 173 private: |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 saved_work_area, | 294 saved_work_area, |
| 295 bounds); | 295 bounds); |
| 296 return true; | 296 return true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 void WindowSizer::GetDefaultWindowBounds(const display::Display& display, | 299 void WindowSizer::GetDefaultWindowBounds(const display::Display& display, |
| 300 gfx::Rect* default_bounds) const { | 300 gfx::Rect* default_bounds) const { |
| 301 DCHECK(default_bounds); | 301 DCHECK(default_bounds); |
| 302 #if defined(USE_ASH) | 302 #if defined(USE_ASH) |
| 303 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 | 303 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 |
| 304 if (ash_util::ShouldOpenAshOnStartup()) { | 304 if (ShouldOpenAshOnStartup()) { |
| 305 *default_bounds = ash::WindowPositioner::GetDefaultWindowBounds(display); | 305 *default_bounds = ash::WindowPositioner::GetDefaultWindowBounds(display); |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 #endif | 308 #endif |
| 309 gfx::Rect work_area = display.work_area(); | 309 gfx::Rect work_area = display.work_area(); |
| 310 | 310 |
| 311 // The default size is either some reasonably wide width, or if the work | 311 // The default size is either some reasonably wide width, or if the work |
| 312 // area is narrower, then the work area width less some aesthetic padding. | 312 // area is narrower, then the work area width less some aesthetic padding. |
| 313 int default_width = std::min(work_area.width() - 2 * kWindowTilePixels, 1050); | 313 int default_width = std::min(work_area.width() - 2 * kWindowTilePixels, 1050); |
| 314 int default_height = work_area.height() - 2 * kWindowTilePixels; | 314 int default_height = work_area.height() - 2 * kWindowTilePixels; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 430 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 431 switches::kStartMaximized)) | 431 switches::kStartMaximized)) |
| 432 return ui::SHOW_STATE_MAXIMIZED; | 432 return ui::SHOW_STATE_MAXIMIZED; |
| 433 | 433 |
| 434 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 434 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
| 435 return browser_->initial_show_state(); | 435 return browser_->initial_show_state(); |
| 436 | 436 |
| 437 // Otherwise we use the default which can be overridden later on. | 437 // Otherwise we use the default which can be overridden later on. |
| 438 return ui::SHOW_STATE_DEFAULT; | 438 return ui::SHOW_STATE_DEFAULT; |
| 439 } | 439 } |
| OLD | NEW |