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/shell.h" |
8 #include "ash/wm/aura/wm_window_aura.h" | 8 #include "ash/wm/aura/wm_window_aura.h" |
9 #include "ash/wm/common/window_positioner.h" | 9 #include "ash/wm/common/window_positioner.h" |
10 #include "ash/wm/common/window_state.h" | 10 #include "ash/wm/common/window_state.h" |
11 #include "chrome/browser/ui/ash/ash_util.h" | 11 #include "chrome/browser/ui/ash/ash_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
16 #include "ui/gfx/screen.h" | 16 #include "ui/display/screen.h" |
17 | 17 |
18 bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, | 18 bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, |
19 ui::WindowShowState* show_state) const { | 19 ui::WindowShowState* show_state) const { |
20 if (!chrome::ShouldOpenAshOnStartup() || !browser_) | 20 if (!chrome::ShouldOpenAshOnStartup() || !browser_) |
21 return false; | 21 return false; |
22 | 22 |
23 bool determined = false; | 23 bool determined = false; |
24 if (bounds->IsEmpty()) { | 24 if (bounds->IsEmpty()) { |
25 if (browser_->is_type_tabbed()) { | 25 if (browser_->is_type_tabbed()) { |
26 GetTabbedBrowserBoundsAsh(bounds, show_state); | 26 GetTabbedBrowserBoundsAsh(bounds, show_state); |
(...skipping 17 matching lines...) Expand all Loading... |
44 } else if (browser_->is_type_popup() && bounds->origin().IsOrigin()) { | 44 } else if (browser_->is_type_popup() && bounds->origin().IsOrigin()) { |
45 // In case of a popup with an 'unspecified' location in ash, we are | 45 // In case of a popup with an 'unspecified' location in ash, we are |
46 // looking for a good screen location. We are interpreting (0,0) as an | 46 // looking for a good screen location. We are interpreting (0,0) as an |
47 // unspecified location. | 47 // unspecified location. |
48 *bounds = ash::Shell::GetInstance()->window_positioner()-> | 48 *bounds = ash::Shell::GetInstance()->window_positioner()-> |
49 GetPopupPosition(*bounds); | 49 GetPopupPosition(*bounds); |
50 determined = true; | 50 determined = true; |
51 } | 51 } |
52 | 52 |
53 if (browser_->is_type_tabbed() && *show_state == ui::SHOW_STATE_DEFAULT) { | 53 if (browser_->is_type_tabbed() && *show_state == ui::SHOW_STATE_DEFAULT) { |
54 gfx::Display display = screen_->GetDisplayMatching(*bounds); | 54 display::Display display = screen_->GetDisplayMatching(*bounds); |
55 gfx::Rect work_area = display.work_area(); | 55 gfx::Rect work_area = display.work_area(); |
56 bounds->AdjustToFit(work_area); | 56 bounds->AdjustToFit(work_area); |
57 if (*bounds == work_area) { | 57 if (*bounds == work_area) { |
58 // A |browser_| that occupies the whole work area gets maximized. | 58 // A |browser_| that occupies the whole work area gets maximized. |
59 // |bounds| returned here become the restore bounds once the window | 59 // |bounds| returned here become the restore bounds once the window |
60 // gets maximized after this method returns. Return a sensible default | 60 // gets maximized after this method returns. Return a sensible default |
61 // in order to make restored state visibly different from maximized. | 61 // in order to make restored state visibly different from maximized. |
62 *show_state = ui::SHOW_STATE_MAXIMIZED; | 62 *show_state = ui::SHOW_STATE_MAXIMIZED; |
63 *bounds = ash::WindowPositioner::GetDefaultWindowBounds(display); | 63 *bounds = ash::WindowPositioner::GetDefaultWindowBounds(display); |
64 determined = true; | 64 determined = true; |
65 } | 65 } |
66 } | 66 } |
67 return determined; | 67 return determined; |
68 } | 68 } |
69 | 69 |
70 void WindowSizer::GetTabbedBrowserBoundsAsh( | 70 void WindowSizer::GetTabbedBrowserBoundsAsh( |
71 gfx::Rect* bounds_in_screen, | 71 gfx::Rect* bounds_in_screen, |
72 ui::WindowShowState* show_state) const { | 72 ui::WindowShowState* show_state) const { |
73 DCHECK(show_state); | 73 DCHECK(show_state); |
74 DCHECK(bounds_in_screen); | 74 DCHECK(bounds_in_screen); |
75 DCHECK(browser_->is_type_tabbed()); | 75 DCHECK(browser_->is_type_tabbed()); |
76 DCHECK(bounds_in_screen->IsEmpty()); | 76 DCHECK(bounds_in_screen->IsEmpty()); |
77 | 77 |
78 ui::WindowShowState passed_show_state = *show_state; | 78 ui::WindowShowState passed_show_state = *show_state; |
79 | 79 |
80 bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state); | 80 bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state); |
81 gfx::Display display; | 81 display::Display display; |
82 if (is_saved_bounds) { | 82 if (is_saved_bounds) { |
83 display = screen_->GetDisplayMatching(*bounds_in_screen); | 83 display = screen_->GetDisplayMatching(*bounds_in_screen); |
84 } else { | 84 } else { |
85 // If there is no saved bounds (hence bounds_in_screen is empty), use the | 85 // If there is no saved bounds (hence bounds_in_screen is empty), use the |
86 // target display. | 86 // target display. |
87 display = target_display_provider_->GetTargetDisplay(screen_, | 87 display = target_display_provider_->GetTargetDisplay(screen_, |
88 *bounds_in_screen); | 88 *bounds_in_screen); |
89 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display); | 89 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display); |
90 } | 90 } |
91 | 91 |
(...skipping 14 matching lines...) Expand all Loading... |
106 | 106 |
107 // The |browser_window| is non NULL when this is called after | 107 // The |browser_window| is non NULL when this is called after |
108 // browser's aura window is created. | 108 // browser's aura window is created. |
109 aura::Window* browser_window = | 109 aura::Window* browser_window = |
110 browser_->window() ? browser_->window()->GetNativeWindow() : NULL; | 110 browser_->window() ? browser_->window()->GetNativeWindow() : NULL; |
111 | 111 |
112 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( | 112 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( |
113 ash::wm::WmWindowAura::Get(browser_window), is_saved_bounds, | 113 ash::wm::WmWindowAura::Get(browser_window), is_saved_bounds, |
114 passed_show_state, bounds_in_screen, show_state); | 114 passed_show_state, bounds_in_screen, show_state); |
115 } | 115 } |
OLD | NEW |