window_sizer_ash.cc revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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. 4 5#include "chrome/browser/ui/window_sizer/window_sizer.h" 6 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" 14 15void WindowSizer::GetTabbedBrowserBoundsAsh( 16 gfx::Rect* bounds_in_screen, 17 ui::WindowShowState* show_state) const { 18 DCHECK(show_state); 19 DCHECK(bounds_in_screen); 20 DCHECK(browser_->is_type_tabbed()); 21 DCHECK(bounds_in_screen->IsEmpty()); 22 23 ui::WindowShowState passed_show_state = *show_state; 24 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); 29 if (!is_saved_bounds) 30 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display); 31 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|. 37 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()); 44 return; 45 } 46 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; 51 52 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( 53 screen_, 54 browser_window, 55 is_saved_bounds, 56 passed_show_state, 57 bounds_in_screen, 58 show_state); 59} 60