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> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
16 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 188 |
187 } // namespace | 189 } // namespace |
188 | 190 |
189 /////////////////////////////////////////////////////////////////////////////// | 191 /////////////////////////////////////////////////////////////////////////////// |
190 // WindowSizer, public: | 192 // WindowSizer, public: |
191 | 193 |
192 WindowSizer::WindowSizer( | 194 WindowSizer::WindowSizer( |
193 scoped_ptr<StateProvider> state_provider, | 195 scoped_ptr<StateProvider> state_provider, |
194 scoped_ptr<TargetDisplayProvider> target_display_provider, | 196 scoped_ptr<TargetDisplayProvider> target_display_provider, |
195 const Browser* browser) | 197 const Browser* browser) |
196 : state_provider_(state_provider.Pass()), | 198 : state_provider_(std::move(state_provider)), |
197 target_display_provider_(target_display_provider.Pass()), | 199 target_display_provider_(std::move(target_display_provider)), |
198 // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 | 200 // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 |
199 screen_(gfx::Screen::GetNativeScreen()), | 201 screen_(gfx::Screen::GetNativeScreen()), |
200 browser_(browser) { | 202 browser_(browser) {} |
201 } | |
202 | 203 |
203 WindowSizer::WindowSizer( | 204 WindowSizer::WindowSizer( |
204 scoped_ptr<StateProvider> state_provider, | 205 scoped_ptr<StateProvider> state_provider, |
205 scoped_ptr<TargetDisplayProvider> target_display_provider, | 206 scoped_ptr<TargetDisplayProvider> target_display_provider, |
206 gfx::Screen* screen, | 207 gfx::Screen* screen, |
207 const Browser* browser) | 208 const Browser* browser) |
208 : state_provider_(state_provider.Pass()), | 209 : state_provider_(std::move(state_provider)), |
209 target_display_provider_(target_display_provider.Pass()), | 210 target_display_provider_(std::move(target_display_provider)), |
210 screen_(screen), | 211 screen_(screen), |
211 browser_(browser) { | 212 browser_(browser) { |
212 DCHECK(screen_); | 213 DCHECK(screen_); |
213 } | 214 } |
214 | 215 |
215 WindowSizer::~WindowSizer() { | 216 WindowSizer::~WindowSizer() { |
216 } | 217 } |
217 | 218 |
218 // static | 219 // static |
219 void WindowSizer::GetBrowserWindowBoundsAndShowState( | 220 void WindowSizer::GetBrowserWindowBoundsAndShowState( |
220 const std::string& app_name, | 221 const std::string& app_name, |
221 const gfx::Rect& specified_bounds, | 222 const gfx::Rect& specified_bounds, |
222 const Browser* browser, | 223 const Browser* browser, |
223 gfx::Rect* window_bounds, | 224 gfx::Rect* window_bounds, |
224 ui::WindowShowState* show_state) { | 225 ui::WindowShowState* show_state) { |
225 scoped_ptr<StateProvider> state_provider( | 226 scoped_ptr<StateProvider> state_provider( |
226 new DefaultStateProvider(app_name, browser)); | 227 new DefaultStateProvider(app_name, browser)); |
227 scoped_ptr<TargetDisplayProvider> target_display_provider( | 228 scoped_ptr<TargetDisplayProvider> target_display_provider( |
228 new DefaultTargetDisplayProvider); | 229 new DefaultTargetDisplayProvider); |
229 const WindowSizer sizer(state_provider.Pass(), | 230 const WindowSizer sizer(std::move(state_provider), |
230 target_display_provider.Pass(), | 231 std::move(target_display_provider), browser); |
231 browser); | |
232 sizer.DetermineWindowBoundsAndShowState(specified_bounds, | 232 sizer.DetermineWindowBoundsAndShowState(specified_bounds, |
233 window_bounds, | 233 window_bounds, |
234 show_state); | 234 show_state); |
235 } | 235 } |
236 | 236 |
237 /////////////////////////////////////////////////////////////////////////////// | 237 /////////////////////////////////////////////////////////////////////////////// |
238 // WindowSizer, private: | 238 // WindowSizer, private: |
239 | 239 |
240 void WindowSizer::DetermineWindowBoundsAndShowState( | 240 void WindowSizer::DetermineWindowBoundsAndShowState( |
241 const gfx::Rect& specified_bounds, | 241 const gfx::Rect& specified_bounds, |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 444 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
445 switches::kStartMaximized)) | 445 switches::kStartMaximized)) |
446 return ui::SHOW_STATE_MAXIMIZED; | 446 return ui::SHOW_STATE_MAXIMIZED; |
447 | 447 |
448 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 448 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
449 return browser_->initial_show_state(); | 449 return browser_->initial_show_state(); |
450 | 450 |
451 // Otherwise we use the default which can be overridden later on. | 451 // Otherwise we use the default which can be overridden later on. |
452 return ui::SHOW_STATE_DEFAULT; | 452 return ui::SHOW_STATE_DEFAULT; |
453 } | 453 } |
OLD | NEW |