summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/window_sizer
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui/window_sizer')
-rw-r--r--chrome/browser/ui/window_sizer/window_sizer.cc5
-rw-r--r--chrome/browser/ui/window_sizer/window_sizer.h6
-rw-r--r--chrome/browser/ui/window_sizer/window_sizer_ash.cc36
-rw-r--r--chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc3
4 files changed, 18 insertions, 32 deletions
diff --git a/chrome/browser/ui/window_sizer/window_sizer.cc b/chrome/browser/ui/window_sizer/window_sizer.cc
index e5a1c9f..9e7c820 100644
--- a/chrome/browser/ui/window_sizer/window_sizer.cc
+++ b/chrome/browser/ui/window_sizer/window_sizer.cc
@@ -200,9 +200,8 @@ void WindowSizer::DetermineWindowBoundsAndShowState(
} else if (chrome::ShouldOpenAshOnStartup() &&
browser_ && browser_->host_desktop_type() ==
chrome::HOST_DESKTOP_TYPE_ASH) {
- // Saved bounds's show state takes precedence over one in last
- // bounds in ash. If you have a question or an issue, please
- // contact oshima@chromium.org.
+ // In ash, saved show state takes precidence. If you have a
+ // question or an issue, please contact oshima@chromium.org.
GetSavedWindowBounds(bounds, show_state);
}
#endif
diff --git a/chrome/browser/ui/window_sizer/window_sizer.h b/chrome/browser/ui/window_sizer/window_sizer.h
index 5905426..c5c4c01 100644
--- a/chrome/browser/ui/window_sizer/window_sizer.h
+++ b/chrome/browser/ui/window_sizer/window_sizer.h
@@ -108,12 +108,6 @@ class WindowSizer {
// opened windows. This value may be different on each platform.
static const int kWindowTilePixels;
-#if defined(USE_ASH)
- // When the screen resolution width is smaller then this size, The algorithm
- // will default to maximized.
- static int GetForceMaximizedWidthLimit();
-#endif
-
private:
// The edge of the screen to check for out-of-bounds.
enum Edge { TOP, LEFT, BOTTOM, RIGHT };
diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash.cc b/chrome/browser/ui/window_sizer/window_sizer_ash.cc
index 6f41a86..64b6e60 100644
--- a/chrome/browser/ui/window_sizer/window_sizer_ash.cc
+++ b/chrome/browser/ui/window_sizer/window_sizer_ash.cc
@@ -4,13 +4,12 @@
#include "chrome/browser/ui/window_sizer/window_sizer.h"
-#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h"
+#include "ash/wm/window_positioner.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/auto_window_management.h"
-#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -22,12 +21,6 @@
namespace {
-// When a window gets opened in default mode and the screen is less than or
-// equal to this width, the window will get opened in maximized mode. This value
-// can be reduced to a "tame" number if the feature is disabled.
-const int kForceMaximizeWidthLimit = 1366;
-const int kForceMaximizeWidthLimitDisabled = 640;
-
// Check if the given browser is 'valid': It is a tabbed, non minimized
// window, which intersects with the |bounds_in_screen| area of a given screen.
bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) {
@@ -76,23 +69,12 @@ bool MoveRect(const gfx::Rect& work_area,
} // namespace
-// static
-int WindowSizer::GetForceMaximizedWidthLimit() {
- static int maximum_limit = 0;
- if (!maximum_limit) {
- maximum_limit = CommandLine::ForCurrentProcess()->HasSwitch(
- ash::switches::kAshDisableAutoMaximizing) ?
- kForceMaximizeWidthLimitDisabled : kForceMaximizeWidthLimit;
- }
- return maximum_limit;
-}
-
void WindowSizer::GetTabbedBrowserBoundsAsh(
gfx::Rect* bounds_in_screen,
ui::WindowShowState* show_state) const {
DCHECK(show_state);
DCHECK(bounds_in_screen);
- DCHECK(!browser_ || browser_->is_type_tabbed());
+ DCHECK(browser_->is_type_tabbed());
bounds_in_screen->SetRect(0, 0, 0, 0);
@@ -107,6 +89,16 @@ void WindowSizer::GetTabbedBrowserBoundsAsh(
GetDefaultWindowBoundsAsh(bounds_in_screen);
}
+ if (browser_->is_session_restore()) {
+ // Use saved bounds to find the destination work area when
+ // restoring the session. If the dispay has been removed,
+ // this will fallback to the primary display's work area.
+ gfx::Rect work_area =
+ screen_->GetDisplayMatching(*bounds_in_screen).work_area();
+ bounds_in_screen->AdjustToFit(work_area);
+ return;
+ }
+
aura::RootWindow* target = ash::Shell::GetTargetRootWindow();
// Always open new window in the active display.
gfx::Rect work_area =
@@ -130,8 +122,8 @@ void WindowSizer::GetTabbedBrowserBoundsAsh(
// When using "small screens" we want to always open in full screen mode.
if (passed_show_state == ui::SHOW_STATE_DEFAULT &&
- !browser_->is_session_restore() &&
- work_area.width() <= GetForceMaximizedWidthLimit() &&
+ work_area.width() <=
+ ash::WindowPositioner::GetForceMaximizedWidthLimit() &&
(!browser_->window() || !browser_->window()->IsFullscreen()))
*show_state = ui::SHOW_STATE_MAXIMIZED;
return;
diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
index 9874fba..bcb7a12 100644
--- a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
+++ b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
@@ -6,6 +6,7 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/test_shell_delegate.h"
+#include "ash/wm/window_positioner.h"
#include "ash/wm/window_resizer.h"
#include "ash/wm/window_state.h"
#include "base/compiler_specific.h"
@@ -756,7 +757,7 @@ TEST_F(WindowSizerAshTest, TestShowState) {
// In smaller screen resolutions we default to maximized if there is no other
// window visible.
- int min_size = WindowSizer::GetForceMaximizedWidthLimit() / 2;
+ int min_size = ash::WindowPositioner::GetForceMaximizedWidthLimit() / 2;
if (min_size > 0) {
const gfx::Rect tiny_screen(0, 0, min_size, min_size);
EXPECT_EQ(ui::SHOW_STATE_DEFAULT,