diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-08 02:19:04 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-08 02:19:04 +0000 |
commit | f8feb29903155d73053e7ea5cca63c523c2bd215 (patch) | |
tree | 529607571ef3e76a04510bb89fc162bf5925fa11 | |
parent | 01d7a4c42b16354d144321c924ab7c0bfe29d318 (diff) | |
download | chromium_src-f8feb29903155d73053e7ea5cca63c523c2bd215.zip chromium_src-f8feb29903155d73053e7ea5cca63c523c2bd215.tar.gz chromium_src-f8feb29903155d73053e7ea5cca63c523c2bd215.tar.bz2 |
Minor window_sizer_ash cleanups
* remove unnecessary code
* move ash specific piece to ash/wm/window_positioner
* add separate if block for session_restore path.
Next step: I'll move window_sizer_ash logic to ash/wm/window_positoner
BUG=272460
R=jamescook@chromium.org, sky@chromium.org, varkha@chromium.org
Review URL: https://codereview.chromium.org/25453009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227432 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/wm/window_positioner.cc | 19 | ||||
-rw-r--r-- | ash/wm/window_positioner.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer/window_sizer.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer/window_sizer.h | 6 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer/window_sizer_ash.cc | 36 | ||||
-rw-r--r-- | chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc | 3 |
6 files changed, 40 insertions, 33 deletions
diff --git a/ash/wm/window_positioner.cc b/ash/wm/window_positioner.cc index 1a7af44..743a3fc 100644 --- a/ash/wm/window_positioner.cc +++ b/ash/wm/window_positioner.cc @@ -4,11 +4,13 @@ #include "ash/wm/window_positioner.h" +#include "ash/ash_switches.h" #include "ash/shell.h" #include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_resizer.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" +#include "base/command_line.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" #include "ui/compositor/layer.h" @@ -16,10 +18,25 @@ namespace ash { -// statics +// 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; const int WindowPositioner::kMinimumWindowOffset = 32; +// static +int WindowPositioner::GetForceMaximizedWidthLimit() { + static int maximum_limit = 0; + if (!maximum_limit) { + maximum_limit = CommandLine::ForCurrentProcess()->HasSwitch( + ash::switches::kAshDisableAutoMaximizing) ? + kForceMaximizeWidthLimitDisabled : kForceMaximizeWidthLimit; + } + return maximum_limit; +} + WindowPositioner::WindowPositioner() : pop_position_offset_increment_x(0), pop_position_offset_increment_y(0), diff --git a/ash/wm/window_positioner.h b/ash/wm/window_positioner.h index 8a95b2e..b3302f1 100644 --- a/ash/wm/window_positioner.h +++ b/ash/wm/window_positioner.h @@ -23,6 +23,10 @@ class WindowPositionerTest; // a usable position on the closest work area (of the active window). class ASH_EXPORT WindowPositioner { public: + // When the screen resolution width is smaller then this size, The algorithm + // will default to maximized. + static int GetForceMaximizedWidthLimit(); + WindowPositioner(); ~WindowPositioner(); 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, |