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/ash_switches.h" | |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/wm/window_cycle_controller.h" | 9 #include "ash/wm/window_cycle_controller.h" |
9 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
11 #include "base/command_line.h" | |
10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
11 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 17 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
16 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
17 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
18 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
19 #include "ui/aura/window_delegate.h" | 21 #include "ui/aura/window_delegate.h" |
20 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 // When a window gets opened in default mode and the screen is less then this | 26 // 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. | 27 // width, the window will get opened in maximized mode. This value can be |
28 // reduced to a "tame" number if the feature is disabled. | |
26 const int kForceMaximizeWidthLimit = 1366; | 29 const int kForceMaximizeWidthLimit = 1366; |
30 const int kForceMaximizeWidthLimitDisabled = 640; | |
27 | 31 |
28 // Check if the given browser is 'valid': It is a tabbed, non minimized | 32 // 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. | 33 // window, which intersects with the |bounds_in_screen| area of a given screen. |
30 bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { | 34 bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { |
31 return (browser && browser->window() && | 35 return (browser && browser->window() && |
32 !browser->is_type_popup() && | 36 !browser->is_type_popup() && |
33 !browser->window()->IsMinimized() && | 37 !browser->window()->IsMinimized() && |
34 browser->window()->GetNativeWindow() && | 38 browser->window()->GetNativeWindow() && |
35 bounds_in_screen.Intersects( | 39 bounds_in_screen.Intersects( |
36 browser->window()->GetNativeWindow()->GetBoundsInScreen())); | 40 browser->window()->GetNativeWindow()->GetBoundsInScreen())); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 return true; | 132 return true; |
129 } | 133 } |
130 } | 134 } |
131 return false; | 135 return false; |
132 } | 136 } |
133 | 137 |
134 } // namespace | 138 } // namespace |
135 | 139 |
136 // static | 140 // static |
137 int WindowSizer::GetForceMaximizedWidthLimit() { | 141 int WindowSizer::GetForceMaximizedWidthLimit() { |
138 return kForceMaximizeWidthLimit; | 142 static int maximum_limit = 0; |
143 if (!maximum_limit) { | |
144 maximum_limit = CommandLine::ForCurrentProcess()->HasSwitch( | |
145 ash::switches::kAshDisableAutoMaximizing) ? | |
146 kForceMaximizeWidthLimitDisabled : kForceMaximizeWidthLimit; | |
James Cook
2013/04/13 00:15:03
Is there a way to actually disable the code that e
skuhne
2013/04/13 00:21:29
1) LOL - yeah right. I have thought about doing it
| |
147 } | |
148 return maximum_limit; | |
139 } | 149 } |
140 | 150 |
141 bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, | 151 bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, |
142 ui::WindowShowState* show_state) const { | 152 ui::WindowShowState* show_state) const { |
143 DCHECK(show_state); | 153 DCHECK(show_state); |
144 DCHECK(bounds_in_screen); | 154 DCHECK(bounds_in_screen); |
145 | 155 |
146 if (browser_ && | 156 if (browser_ && |
147 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { | 157 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { |
148 return false; | 158 return false; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 if (default_width > kMaximumWindowWidth) { | 238 if (default_width > kMaximumWindowWidth) { |
229 // The window should get centered on the screen and not follow the grid. | 239 // The window should get centered on the screen and not follow the grid. |
230 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; | 240 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; |
231 default_width = kMaximumWindowWidth; | 241 default_width = kMaximumWindowWidth; |
232 } | 242 } |
233 default_bounds->SetRect(work_area.x() + offset_x, | 243 default_bounds->SetRect(work_area.x() + offset_x, |
234 work_area.y() + kDesktopBorderSize, | 244 work_area.y() + kDesktopBorderSize, |
235 default_width, | 245 default_width, |
236 default_height); | 246 default_height); |
237 } | 247 } |
OLD | NEW |