| 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/window_cycle_controller.h" | 8 #include "ash/wm/window_cycle_controller.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 16 #include "chrome/browser/ui/host_desktop.h" | 16 #include "chrome/browser/ui/host_desktop.h" |
| 17 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
| 20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // When a window gets opened in default mode and the screen is less then this | 24 // When a window gets opened in default mode and the screen is less then this |
| 25 // width, the window will get opened in maximized mode. | 25 // width, the window will get opened in maximized mode. |
| 26 const int kForceMaximizeWidthLimit = 640; | 26 const int kForceMaximizeWidthLimit = 1366; |
| 27 | 27 |
| 28 // Check if the given browser is 'valid': It is a tabbed, non minimized | 28 // Check if the given browser is 'valid': It is a tabbed, non minimized |
| 29 // window, which intersects with the |bounds_in_screen| area of a given screen. | 29 // window, which intersects with the |bounds_in_screen| area of a given screen. |
| 30 bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { | 30 bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { |
| 31 return (browser && browser->window() && | 31 return (browser && browser->window() && |
| 32 !browser->is_type_popup() && | 32 !browser->is_type_popup() && |
| 33 !browser->window()->IsMinimized() && | 33 !browser->window()->IsMinimized() && |
| 34 browser->window()->GetNativeWindow() && | 34 browser->window()->GetNativeWindow() && |
| 35 bounds_in_screen.Intersects( | 35 bounds_in_screen.Intersects( |
| 36 browser->window()->GetNativeWindow()->GetBoundsInScreen())); | 36 browser->window()->GetNativeWindow()->GetBoundsInScreen())); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 int count = GetNumberOfValidTopLevelBrowserWindows(work_area); | 164 int count = GetNumberOfValidTopLevelBrowserWindows(work_area); |
| 165 aura::Window* top_window = GetTopWindow(work_area); | 165 aura::Window* top_window = GetTopWindow(work_area); |
| 166 // Our window should not have any impact if we are already on top. | 166 // Our window should not have any impact if we are already on top. |
| 167 if (browser_->window() && | 167 if (browser_->window() && |
| 168 top_window == browser_->window()->GetNativeWindow()) | 168 top_window == browser_->window()->GetNativeWindow()) |
| 169 top_window = NULL; | 169 top_window = NULL; |
| 170 // If there is no valid other window we take the coordinates as is. | 170 // If there is no valid other window we take the coordinates as is. |
| 171 if (!count || !top_window) { | 171 if (!count || !top_window) { |
| 172 // When using "small screens" we want to always open in full screen mode. | 172 // When using "small screens" we want to always open in full screen mode. |
| 173 if (passed_show_state == ui::SHOW_STATE_DEFAULT && | 173 if (passed_show_state == ui::SHOW_STATE_DEFAULT && |
| 174 !browser_->is_session_restore() && |
| 174 work_area.width() < kForceMaximizeWidthLimit && | 175 work_area.width() < kForceMaximizeWidthLimit && |
| 175 (!browser_->window() || !browser_->window()->IsFullscreen()) && | 176 (!browser_->window() || !browser_->window()->IsFullscreen()) && |
| 176 (!browser_->fullscreen_controller() || | 177 (!browser_->fullscreen_controller() || |
| 177 !browser_->fullscreen_controller()->IsFullscreenForBrowser())) | 178 !browser_->fullscreen_controller()->IsFullscreenForBrowser())) |
| 178 *show_state = ui::SHOW_STATE_MAXIMIZED; | 179 *show_state = ui::SHOW_STATE_MAXIMIZED; |
| 179 return true; | 180 return true; |
| 180 } | 181 } |
| 181 bool maximized = ash::wm::IsWindowMaximized(top_window); | 182 bool maximized = ash::wm::IsWindowMaximized(top_window); |
| 182 // We ignore the saved show state, but look instead for the top level | 183 // We ignore the saved show state, but look instead for the top level |
| 183 // window's show state. | 184 // window's show state. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 if (default_width > kMaximumWindowWidth) { | 228 if (default_width > kMaximumWindowWidth) { |
| 228 // The window should get centered on the screen and not follow the grid. | 229 // The window should get centered on the screen and not follow the grid. |
| 229 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; | 230 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; |
| 230 default_width = kMaximumWindowWidth; | 231 default_width = kMaximumWindowWidth; |
| 231 } | 232 } |
| 232 default_bounds->SetRect(work_area.x() + offset_x, | 233 default_bounds->SetRect(work_area.x() + offset_x, |
| 233 work_area.y() + kDesktopBorderSize, | 234 work_area.y() + kDesktopBorderSize, |
| 234 default_width, | 235 default_width, |
| 235 default_height); | 236 default_height); |
| 236 } | 237 } |
| OLD | NEW |