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 "ash/shell.h" |
7 #include "ash/wm/window_positioner.h" | 8 #include "ash/wm/window_positioner.h" |
8 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
11 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
14 | 15 |
15 void WindowSizer::GetTabbedBrowserBoundsAsh( | 16 void WindowSizer::GetTabbedBrowserBoundsAsh( |
16 gfx::Rect* bounds_in_screen, | 17 gfx::Rect* bounds_in_screen, |
17 ui::WindowShowState* show_state) const { | 18 ui::WindowShowState* show_state) const { |
18 DCHECK(show_state); | 19 DCHECK(show_state); |
19 DCHECK(bounds_in_screen); | 20 DCHECK(bounds_in_screen); |
20 DCHECK(browser_->is_type_tabbed()); | 21 DCHECK(browser_->is_type_tabbed()); |
21 DCHECK(bounds_in_screen->IsEmpty()); | 22 DCHECK(bounds_in_screen->IsEmpty()); |
22 | 23 |
23 ui::WindowShowState passed_show_state = *show_state; | 24 ui::WindowShowState passed_show_state = *show_state; |
24 | 25 |
25 bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state); | 26 bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state); |
26 // If there is no saved bounds (hence bounds_in_screen is empty), the | 27 gfx::Display display; |
27 // |display| will be the primary display. | 28 if (is_saved_bounds) { |
28 const gfx::Display& display = screen_->GetDisplayMatching(*bounds_in_screen); | 29 display = screen_->GetDisplayMatching(*bounds_in_screen); |
29 if (!is_saved_bounds) | 30 } else { |
| 31 // If there is no saved bounds (hence bounds_in_screen is empty), use the |
| 32 // target display. |
| 33 display = target_display_provider_->GetTargetDisplay(screen_, |
| 34 *bounds_in_screen); |
30 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display); | 35 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display); |
| 36 } |
31 | 37 |
32 if (browser_->is_session_restore()) { | 38 if (browser_->is_session_restore()) { |
33 // This is a fall-through case when there is no bounds recorded | 39 // This is a fall-through case when there is no bounds recorded |
34 // for restored window, and should not be used except for the case | 40 // for restored window, and should not be used except for the case |
35 // above. The regular path is handled in | 41 // above. The regular path is handled in |
36 // |WindowSizer::DetermineWindowBoundsAndShowState|. | 42 // |WindowSizer::DetermineWindowBoundsAndShowState|. |
37 | 43 |
38 // Note: How restore bounds/show state data are passed. | 44 // Note: How restore bounds/show state data are passed. |
39 // The restore bounds is passed via |Browser::override_bounds()| in | 45 // The restore bounds is passed via |Browser::override_bounds()| in |
40 // |chrome::GetBrowserWindowBoundsAndShowState()|. | 46 // |chrome::GetBrowserWindowBoundsAndShowState()|. |
41 // The restore state is passed via |Browser::initial_state()| in | 47 // The restore state is passed via |Browser::initial_state()| in |
42 // |WindowSizer::GetWindowDefaultShowState|. | 48 // |WindowSizer::GetWindowDefaultShowState|. |
43 bounds_in_screen->AdjustToFit(display.work_area()); | 49 bounds_in_screen->AdjustToFit(display.work_area()); |
44 return; | 50 return; |
45 } | 51 } |
46 | 52 |
47 // The |browser_window| is non NULL when this is called after | 53 // The |browser_window| is non NULL when this is called after |
48 // browser's aura window is created. | 54 // browser's aura window is created. |
49 aura::Window* browser_window = | 55 aura::Window* browser_window = |
50 browser_->window() ? browser_->window()->GetNativeWindow() : NULL; | 56 browser_->window() ? browser_->window()->GetNativeWindow() : NULL; |
51 | 57 |
52 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( | 58 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( |
53 screen_, | 59 screen_, |
54 browser_window, | 60 browser_window, |
55 is_saved_bounds, | 61 is_saved_bounds, |
56 passed_show_state, | 62 passed_show_state, |
57 bounds_in_screen, | 63 bounds_in_screen, |
58 show_state); | 64 show_state); |
59 } | 65 } |
OLD | NEW |