Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer.cc

Issue 10911274: Adding new window management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cahnged the SetBounds to SetBoundsInScreen Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 sizer.DetermineWindowBounds(specified_bounds, window_bounds); 161 sizer.DetermineWindowBounds(specified_bounds, window_bounds);
162 } 162 }
163 163
164 /////////////////////////////////////////////////////////////////////////////// 164 ///////////////////////////////////////////////////////////////////////////////
165 // WindowSizer, private: 165 // WindowSizer, private:
166 166
167 void WindowSizer::DetermineWindowBounds(const gfx::Rect& specified_bounds, 167 void WindowSizer::DetermineWindowBounds(const gfx::Rect& specified_bounds,
168 gfx::Rect* bounds) const { 168 gfx::Rect* bounds) const {
169 *bounds = specified_bounds; 169 *bounds = specified_bounds;
170 if (bounds->IsEmpty()) { 170 if (bounds->IsEmpty()) {
171 if (GetBoundsIgnoringPreviousState(specified_bounds, bounds)) 171 if (GetBoundsOverride(specified_bounds, bounds))
172 return; 172 return;
173 // See if there's saved placement information. 173 // See if there's saved placement information.
174 if (!GetLastWindowBounds(bounds)) { 174 if (!GetLastWindowBounds(bounds)) {
175 if (!GetSavedWindowBounds(bounds)) { 175 if (!GetSavedWindowBounds(bounds)) {
176 // No saved placement, figure out some sensible default size based on 176 // No saved placement, figure out some sensible default size based on
177 // the user's screen size. 177 // the user's screen size.
178 GetDefaultWindowBounds(bounds); 178 GetDefaultWindowBounds(bounds);
179 } 179 }
180 } 180 }
181 } else { 181 } else {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // ensure that at least kMinVisibleWidth * kMinVisibleHeight is visible. 323 // ensure that at least kMinVisibleWidth * kMinVisibleHeight is visible.
324 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height(); 324 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height();
325 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width(); 325 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width();
326 const int max_y = work_area.bottom() - kMinVisibleHeight; 326 const int max_y = work_area.bottom() - kMinVisibleHeight;
327 const int max_x = work_area.right() - kMinVisibleWidth; 327 const int max_x = work_area.right() - kMinVisibleWidth;
328 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y()))); 328 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y())));
329 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x()))); 329 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x())));
330 #endif // defined(OS_MACOSX) 330 #endif // defined(OS_MACOSX)
331 } 331 }
332 332
333 bool WindowSizer::GetBoundsIgnoringPreviousState( 333 bool WindowSizer::GetBoundsOverride(
334 const gfx::Rect& specified_bounds, 334 const gfx::Rect& specified_bounds,
335 gfx::Rect* bounds) const { 335 gfx::Rect* bounds) const {
336 #if defined(USE_ASH) 336 #if defined(USE_ASH)
337 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 337 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312
338 if (chrome::ShouldOpenAshOnStartup()) 338 if (chrome::ShouldOpenAshOnStartup())
339 return GetBoundsIgnoringPreviousStateAsh(specified_bounds, bounds); 339 return GetBoundsOverrideAsh(specified_bounds, bounds);
340 #endif 340 #endif
341 return false; 341 return false;
342 } 342 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer.h ('k') | chrome/browser/ui/window_sizer/window_sizer_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698