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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/window_sizer/window_sizer.h"
7 #include "ash/wm/window_positioner.h"
8 #include "ash/wm/window_state.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_window.h"
11 #include "ui/aura/root_window.h"
12 #include "ui/aura/window.h"
13 #include "ui/gfx/screen.h"
15 void WindowSizer::GetTabbedBrowserBoundsAsh(
16 gfx::Rect* bounds_in_screen,
17 ui::WindowShowState* show_state) const {
19 DCHECK(bounds_in_screen);
20 DCHECK(browser_->is_type_tabbed());
21 DCHECK(bounds_in_screen->IsEmpty());
23 ui::WindowShowState passed_show_state = *show_state;
25 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 // |display| will be the primary display.
28 const gfx::Display& display = screen_->GetDisplayMatching(*bounds_in_screen);
30 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display);
32 if (browser_->is_session_restore()) {
33 // 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
35 // above. The regular path is handled in
36 // |WindowSizer::DetermineWindowBoundsAndShowState|.
38 // Note: How restore bounds/show state data are passed.
39 // The restore bounds is passed via |Browser::override_bounds()| in
40 // |chrome::GetBrowserWindowBoundsAndShowState()|.
41 // The restore state is passed via |Browser::initial_state()| in
42 // |WindowSizer::GetWindowDefaultShowState|.
43 bounds_in_screen->AdjustToFit(display.work_area());
47 // The |browser_window| is non NULL when this is called after
48 // browser's aura window is created.
49 aura::Window* browser_window =
50 browser_->window() ? browser_->window()->GetNativeWindow() : NULL;
52 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(