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.h" | 5 #include "chrome/browser/ui/window_sizer.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (GetBoundsIgnoringPreviousState(specified_bounds, bounds)) | 164 if (GetBoundsIgnoringPreviousState(specified_bounds, bounds)) |
165 return; | 165 return; |
166 // See if there's saved placement information. | 166 // See if there's saved placement information. |
167 if (!GetLastWindowBounds(bounds)) { | 167 if (!GetLastWindowBounds(bounds)) { |
168 if (!GetSavedWindowBounds(bounds)) { | 168 if (!GetSavedWindowBounds(bounds)) { |
169 // No saved placement, figure out some sensible default size based on | 169 // No saved placement, figure out some sensible default size based on |
170 // the user's screen size. | 170 // the user's screen size. |
171 GetDefaultWindowBounds(bounds); | 171 GetDefaultWindowBounds(bounds); |
172 } | 172 } |
173 } | 173 } |
| 174 } else { |
| 175 // In case that there was a bound given we need to make sure that it is |
| 176 // visible and fits on the screen. |
| 177 // Find the size of the work area of the monitor that intersects the bounds |
| 178 // of the anchor window. Note: AdjustBoundsToBeVisibleOnMonitorContaining |
| 179 // does not exactly what we want: It makes only sure that "a minimal part" |
| 180 // is visible on the screen. |
| 181 gfx::Rect work_area = |
| 182 monitor_info_provider_->GetMonitorWorkAreaMatching(*bounds); |
| 183 // Resize so that it fits. |
| 184 *bounds = bounds->AdjustToFit(work_area); |
174 } | 185 } |
175 } | 186 } |
176 | 187 |
177 bool WindowSizer::GetLastWindowBounds(gfx::Rect* bounds) const { | 188 bool WindowSizer::GetLastWindowBounds(gfx::Rect* bounds) const { |
178 DCHECK(bounds); | 189 DCHECK(bounds); |
179 if (!state_provider_.get() || | 190 if (!state_provider_.get() || |
180 !state_provider_->GetLastActiveWindowState(bounds)) | 191 !state_provider_->GetLastActiveWindowState(bounds)) |
181 return false; | 192 return false; |
182 gfx::Rect last_window_bounds = *bounds; | 193 gfx::Rect last_window_bounds = *bounds; |
183 bounds->Offset(kWindowTilePixels, kWindowTilePixels); | 194 bounds->Offset(kWindowTilePixels, kWindowTilePixels); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 #endif // defined(OS_MACOSX) | 318 #endif // defined(OS_MACOSX) |
308 } | 319 } |
309 | 320 |
310 #if !defined(USE_ASH) | 321 #if !defined(USE_ASH) |
311 bool WindowSizer::GetBoundsIgnoringPreviousState( | 322 bool WindowSizer::GetBoundsIgnoringPreviousState( |
312 const gfx::Rect& specified_bounds, | 323 const gfx::Rect& specified_bounds, |
313 gfx::Rect* bounds) const { | 324 gfx::Rect* bounds) const { |
314 return false; | 325 return false; |
315 } | 326 } |
316 #endif | 327 #endif |
OLD | NEW |