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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/ash/ash_init.h" | 12 #include "chrome/browser/ui/ash/ash_init.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/browser_window_state.h" | 16 #include "chrome/browser/ui/browser_window_state.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
20 | 20 |
21 // Minimum height of the visible part of a window. | 21 // Minimum height of the visible part of a window. |
22 const int kMinVisibleHeight = 30; | 22 const int kMinVisibleHeight = 30; |
23 // Minimum width of the visible part of a window. | 23 // Minimum width of the visible part of a window. |
24 const int kMinVisibleWidth = 30; | 24 const int kMinVisibleWidth = 30; |
25 | 25 |
26 class DefaultMonitorInfoProvider : public MonitorInfoProvider { | 26 class DefaultMonitorInfoProvider : public MonitorInfoProvider { |
27 public: | 27 public: |
28 DefaultMonitorInfoProvider(gfx::Screen* screen) : screen_(screen) {} | |
oshima
2012/10/10 20:08:39
const gfx::Screen*
scottmg
2012/10/10 20:52:01
Done.
| |
28 // Overridden from MonitorInfoProvider: | 29 // Overridden from MonitorInfoProvider: |
29 virtual gfx::Rect GetPrimaryDisplayWorkArea() const OVERRIDE { | 30 virtual gfx::Rect GetPrimaryDisplayWorkArea() const OVERRIDE { |
30 return gfx::Screen::GetPrimaryDisplay().work_area(); | 31 return screen_->GetPrimaryDisplay().work_area(); |
31 } | 32 } |
32 virtual gfx::Rect GetPrimaryDisplayBounds() const OVERRIDE { | 33 virtual gfx::Rect GetPrimaryDisplayBounds() const OVERRIDE { |
33 return gfx::Screen::GetPrimaryDisplay().bounds(); | 34 return screen_->GetPrimaryDisplay().bounds(); |
34 } | 35 } |
35 virtual gfx::Rect GetMonitorWorkAreaMatching( | 36 virtual gfx::Rect GetMonitorWorkAreaMatching( |
36 const gfx::Rect& match_rect) const OVERRIDE { | 37 const gfx::Rect& match_rect) const OVERRIDE { |
37 return gfx::Screen::GetDisplayMatching(match_rect).work_area(); | 38 return screen_->GetDisplayMatching(match_rect).work_area(); |
38 } | 39 } |
40 private: | |
41 gfx::Screen* screen_; | |
oshima
2012/10/10 20:08:39
const
DISALLOW_COPY_AND_ASSIGN
scottmg
2012/10/10 20:52:01
Done.
| |
39 }; | 42 }; |
40 | 43 |
41 /////////////////////////////////////////////////////////////////////////////// | 44 /////////////////////////////////////////////////////////////////////////////// |
42 // An implementation of WindowSizer::StateProvider that gets the last active | 45 // An implementation of WindowSizer::StateProvider that gets the last active |
43 // and persistent state from the browser window and the user's profile. | 46 // and persistent state from the browser window and the user's profile. |
44 class DefaultStateProvider : public WindowSizer::StateProvider { | 47 class DefaultStateProvider : public WindowSizer::StateProvider { |
45 public: | 48 public: |
46 DefaultStateProvider(const std::string& app_name, const Browser* browser) | 49 DefaultStateProvider(const std::string& app_name, const Browser* browser) |
47 : app_name_(app_name), browser_(browser) { | 50 : app_name_(app_name), browser_(browser) { |
48 } | 51 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // gets positioned to its default location. | 146 // gets positioned to its default location. |
144 // static | 147 // static |
145 const int WindowSizer::kDesktopBorderSize = 16; | 148 const int WindowSizer::kDesktopBorderSize = 16; |
146 | 149 |
147 // Maximum width of a window even if there is more room on the desktop. | 150 // Maximum width of a window even if there is more room on the desktop. |
148 // static | 151 // static |
149 const int WindowSizer::kMaximumWindowWidth = 1100; | 152 const int WindowSizer::kMaximumWindowWidth = 1100; |
150 | 153 |
151 WindowSizer::WindowSizer(StateProvider* state_provider, const Browser* browser) | 154 WindowSizer::WindowSizer(StateProvider* state_provider, const Browser* browser) |
152 : state_provider_(state_provider), | 155 : state_provider_(state_provider), |
153 monitor_info_provider_(new DefaultMonitorInfoProvider), | 156 monitor_info_provider_(new DefaultMonitorInfoProvider( |
157 gfx::Screen::GetScreenFor(browser->window()->GetNativeWindow()))), | |
154 browser_(browser) { | 158 browser_(browser) { |
155 } | 159 } |
156 | 160 |
157 WindowSizer::WindowSizer(StateProvider* state_provider, | 161 WindowSizer::WindowSizer(StateProvider* state_provider, |
158 MonitorInfoProvider* monitor_info_provider, | 162 MonitorInfoProvider* monitor_info_provider, |
159 const Browser* browser) | 163 const Browser* browser) |
160 : state_provider_(state_provider), | 164 : state_provider_(state_provider), |
161 monitor_info_provider_(monitor_info_provider), | 165 monitor_info_provider_(monitor_info_provider), |
162 browser_(browser) { | 166 browser_(browser) { |
163 } | 167 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 | 393 |
390 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) | 394 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
391 return ui::SHOW_STATE_MAXIMIZED; | 395 return ui::SHOW_STATE_MAXIMIZED; |
392 | 396 |
393 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 397 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
394 return browser_->initial_show_state(); | 398 return browser_->initial_show_state(); |
395 | 399 |
396 // Otherwise we use the default which can be overridden later on. | 400 // Otherwise we use the default which can be overridden later on. |
397 return ui::SHOW_STATE_DEFAULT; | 401 return ui::SHOW_STATE_DEFAULT; |
398 } | 402 } |
OLD | NEW |