NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / window_sizer / window_sizer_ash.cc
blob3ad703f2f392b29b444a50ffb9146616232469c1
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/shell.h"
8 #include "ash/wm/window_positioner.h"
9 #include "ash/wm/window_state.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "ui/aura/root_window.h"
13 #include "ui/aura/window.h"
14 #include "ui/gfx/screen.h"
16 void WindowSizer::GetTabbedBrowserBoundsAsh(
17 gfx::Rect* bounds_in_screen,
18 ui::WindowShowState* show_state) const {
19 DCHECK(show_state);
20 DCHECK(bounds_in_screen);
21 DCHECK(browser_->is_type_tabbed());
22 DCHECK(bounds_in_screen->IsEmpty());
24 ui::WindowShowState passed_show_state = *show_state;
26 bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state);
27 gfx::Display display;
28 if (is_saved_bounds) {
29 display = screen_->GetDisplayMatching(*bounds_in_screen);
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);
35 *bounds_in_screen = ash::WindowPositioner::GetDefaultWindowBounds(display);
38 if (browser_->is_session_restore()) {
39 // This is a fall-through case when there is no bounds recorded
40 // for restored window, and should not be used except for the case
41 // above. The regular path is handled in
42 // |WindowSizer::DetermineWindowBoundsAndShowState|.
44 // Note: How restore bounds/show state data are passed.
45 // The restore bounds is passed via |Browser::override_bounds()| in
46 // |chrome::GetBrowserWindowBoundsAndShowState()|.
47 // The restore state is passed via |Browser::initial_state()| in
48 // |WindowSizer::GetWindowDefaultShowState|.
49 bounds_in_screen->AdjustToFit(display.work_area());
50 return;
53 // The |browser_window| is non NULL when this is called after
54 // browser's aura window is created.
55 aura::Window* browser_window =
56 browser_->window() ? browser_->window()->GetNativeWindow() : NULL;
58 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
59 screen_,
60 browser_window,
61 is_saved_bounds,
62 passed_show_state,
63 bounds_in_screen,
64 show_state);