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

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

Issue 10540123: Rename gfx::Screen::GetMonitorXXXX to gfx::Screen::GetDisplayXXX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « chrome/browser/ui/window_sizer.h ('k') | chrome/browser/ui/window_sizer_ash.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
16 16
17 // Minimum height of the visible part of a window. 17 // Minimum height of the visible part of a window.
18 const int kMinVisibleHeight = 30; 18 const int kMinVisibleHeight = 30;
19 // Minimum width of the visible part of a window. 19 // Minimum width of the visible part of a window.
20 const int kMinVisibleWidth = 30; 20 const int kMinVisibleWidth = 30;
21 21
22 class DefaultMonitorInfoProvider : public MonitorInfoProvider { 22 class DefaultMonitorInfoProvider : public MonitorInfoProvider {
23 public: 23 public:
24 // Overridden from MonitorInfoProvider: 24 // Overridden from MonitorInfoProvider:
25 virtual gfx::Rect GetPrimaryMonitorWorkArea() const OVERRIDE { 25 virtual gfx::Rect GetPrimaryDisplayWorkArea() const OVERRIDE {
26 return gfx::Screen::GetPrimaryMonitor().work_area(); 26 return gfx::Screen::GetPrimaryDisplay().work_area();
27 } 27 }
28 virtual gfx::Rect GetPrimaryMonitorBounds() const OVERRIDE { 28 virtual gfx::Rect GetPrimaryDisplayBounds() const OVERRIDE {
29 return gfx::Screen::GetPrimaryMonitor().bounds(); 29 return gfx::Screen::GetPrimaryDisplay().bounds();
30 } 30 }
31 virtual gfx::Rect GetMonitorWorkAreaMatching( 31 virtual gfx::Rect GetMonitorWorkAreaMatching(
32 const gfx::Rect& match_rect) const OVERRIDE { 32 const gfx::Rect& match_rect) const OVERRIDE {
33 return gfx::Screen::GetMonitorMatching(match_rect).work_area(); 33 return gfx::Screen::GetDisplayMatching(match_rect).work_area();
34 } 34 }
35 }; 35 };
36 36
37 /////////////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////////////
38 // An implementation of WindowSizer::StateProvider that gets the last active 38 // An implementation of WindowSizer::StateProvider that gets the last active
39 // and persistent state from the browser window and the user's profile. 39 // and persistent state from the browser window and the user's profile.
40 class DefaultStateProvider : public WindowSizer::StateProvider { 40 class DefaultStateProvider : public WindowSizer::StateProvider {
41 public: 41 public:
42 DefaultStateProvider(const std::string& app_name, const Browser* browser) 42 DefaultStateProvider(const std::string& app_name, const Browser* browser)
43 : app_name_(app_name), browser_(browser) { 43 : app_name_(app_name), browser_(browser) {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return false; 206 return false;
207 AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, saved_work_area, bounds); 207 AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, saved_work_area, bounds);
208 return true; 208 return true;
209 } 209 }
210 210
211 #if !defined(USE_ASH) 211 #if !defined(USE_ASH)
212 void WindowSizer::GetDefaultWindowBounds(gfx::Rect* default_bounds) const { 212 void WindowSizer::GetDefaultWindowBounds(gfx::Rect* default_bounds) const {
213 DCHECK(default_bounds); 213 DCHECK(default_bounds);
214 DCHECK(monitor_info_provider_.get()); 214 DCHECK(monitor_info_provider_.get());
215 215
216 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea(); 216 gfx::Rect work_area = monitor_info_provider_->GetPrimaryDisplayWorkArea();
217 217
218 // The default size is either some reasonably wide width, or if the work 218 // The default size is either some reasonably wide width, or if the work
219 // area is narrower, then the work area width less some aesthetic padding. 219 // area is narrower, then the work area width less some aesthetic padding.
220 int default_width = std::min(work_area.width() - 2 * kWindowTilePixels, 1050); 220 int default_width = std::min(work_area.width() - 2 * kWindowTilePixels, 1050);
221 int default_height = work_area.height() - 2 * kWindowTilePixels; 221 int default_height = work_area.height() - 2 * kWindowTilePixels;
222 222
223 // For wider aspect ratio displays at higher resolutions, we might size the 223 // For wider aspect ratio displays at higher resolutions, we might size the
224 // window narrower to allow two windows to easily be placed side-by-side. 224 // window narrower to allow two windows to easily be placed side-by-side.
225 gfx::Rect screen_size = monitor_info_provider_->GetPrimaryMonitorBounds(); 225 gfx::Rect screen_size = monitor_info_provider_->GetPrimaryDisplayBounds();
226 double width_to_height = 226 double width_to_height =
227 static_cast<double>(screen_size.width()) / screen_size.height(); 227 static_cast<double>(screen_size.width()) / screen_size.height();
228 228
229 // The least wide a screen can be to qualify for the halving described above. 229 // The least wide a screen can be to qualify for the halving described above.
230 static const int kMinScreenWidthForWindowHalving = 1600; 230 static const int kMinScreenWidthForWindowHalving = 1600;
231 // We assume 16:9/10 is a fairly standard indicator of a wide aspect ratio 231 // We assume 16:9/10 is a fairly standard indicator of a wide aspect ratio
232 // computer display. 232 // computer display.
233 if (((width_to_height * 10) >= 16) && 233 if (((width_to_height * 10) >= 16) &&
234 work_area.width() > kMinScreenWidthForWindowHalving) { 234 work_area.width() > kMinScreenWidthForWindowHalving) {
235 // Halve the work area, subtracting aesthetic padding on either side. 235 // Halve the work area, subtracting aesthetic padding on either side.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 #endif // defined(OS_MACOSX) 318 #endif // defined(OS_MACOSX)
319 } 319 }
320 320
321 #if !defined(USE_ASH) 321 #if !defined(USE_ASH)
322 bool WindowSizer::GetBoundsIgnoringPreviousState( 322 bool WindowSizer::GetBoundsIgnoringPreviousState(
323 const gfx::Rect& specified_bounds, 323 const gfx::Rect& specified_bounds,
324 gfx::Rect* bounds) const { 324 gfx::Rect* bounds) const {
325 return false; 325 return false;
326 } 326 }
327 #endif 327 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer.h ('k') | chrome/browser/ui/window_sizer_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698