OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 | 14 |
15 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
16 // An implementation of WindowSizer::StateProvider that gets the last active | 16 // An implementation of WindowSizer::StateProvider that gets the last active |
17 // and persistent state from the browser window and the user's profile. | 17 // and persistent state from the browser window and the user's profile. |
18 class DefaultStateProvider : public WindowSizer::StateProvider { | 18 class DefaultStateProvider : public WindowSizer::StateProvider { |
19 public: | 19 public: |
20 explicit DefaultStateProvider(const std::string& app_name, | 20 DefaultStateProvider(const std::string& app_name, const Browser* browser) |
21 const Browser* browser) : app_name_(app_name), | 21 : app_name_(app_name), browser_(browser) { |
22 browser_(browser) { | |
23 } | 22 } |
24 | 23 |
25 // Overridden from WindowSizer::StateProvider: | 24 // Overridden from WindowSizer::StateProvider: |
26 virtual bool GetPersistentState(gfx::Rect* bounds, | 25 virtual bool GetPersistentState(gfx::Rect* bounds, |
27 bool* maximized, | 26 bool* maximized, |
28 gfx::Rect* work_area) const { | 27 gfx::Rect* work_area) const { |
29 DCHECK(bounds && maximized); | 28 DCHECK(bounds && maximized); |
30 | 29 |
31 std::string key(prefs::kBrowserWindowPlacement); | 30 std::string key(prefs::kBrowserWindowPlacement); |
32 if (!app_name_.empty()) { | 31 if (!app_name_.empty()) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // On non-Mac platforms, we are less aggressive about repositioning. Simply | 311 // On non-Mac platforms, we are less aggressive about repositioning. Simply |
313 // ensure that at least kMinVisibleWidth * kMinVisibleHeight is visible. | 312 // ensure that at least kMinVisibleWidth * kMinVisibleHeight is visible. |
314 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height(); | 313 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height(); |
315 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width(); | 314 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width(); |
316 const int max_y = work_area.bottom() - kMinVisibleHeight; | 315 const int max_y = work_area.bottom() - kMinVisibleHeight; |
317 const int max_x = work_area.right() - kMinVisibleWidth; | 316 const int max_x = work_area.right() - kMinVisibleWidth; |
318 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y()))); | 317 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y()))); |
319 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x()))); | 318 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x()))); |
320 #endif // defined(OS_MACOSX) | 319 #endif // defined(OS_MACOSX) |
321 } | 320 } |
OLD | NEW |