Commit 46bca10d authored by oshima@chromium.org's avatar oshima@chromium.org

More cleanup in window_sizer/window_sizer_ash

* The bounds obtained from GetBoundsOverrideAsh is ignored
  (overridden) by the following logic if it returns false,
  so skip early for the condition that returns false.
* Removed the code for non tabbed case in GetBoundsOverrideAsh as it won't be used.

* removed fullscreen controller check because it seems to be
  redundant with window->IsFullscreen() check. (IsFullscerenForBrowser() is always false if window->IsFullscreen() is false)

BUG=272460
R=skuhne@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/23567007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221461 0039d316-1c4b-4281-b951-d872f2087c98
parent 7f46b8f4
...@@ -98,10 +98,11 @@ class DefaultStateProvider : public WindowSizer::StateProvider { ...@@ -98,10 +98,11 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
if (browser_ && browser_->window()) { if (browser_ && browser_->window()) {
window = browser_->window(); window = browser_->window();
} else { } else {
// This code is only ran on the native desktop (on the ash desktop, // This code is only ran on the native desktop (on the ash
// GetBoundsOverrideAsh should take over below before this is reached). // desktop, GetTabbedBrowserBoundsAsh should take over below
// TODO(gab): This code should go in a native desktop specific window // before this is reached). TODO(gab): This code should go in a
// sizer as part of fixing crbug.com/175812. // native desktop specific window sizer as part of fixing
// crbug.com/175812.
const BrowserList* native_browser_list = const BrowserList* native_browser_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
for (BrowserList::const_reverse_iterator it = for (BrowserList::const_reverse_iterator it =
...@@ -193,11 +194,17 @@ void WindowSizer::DetermineWindowBoundsAndShowState( ...@@ -193,11 +194,17 @@ void WindowSizer::DetermineWindowBoundsAndShowState(
if (bounds->IsEmpty()) { if (bounds->IsEmpty()) {
#if defined(USE_ASH) #if defined(USE_ASH)
// See if ash should decide the window placement. // See if ash should decide the window placement.
// TODO(beng): insufficient but currently necessary. if (IsTabbedBrowserInAsh()) {
// http://crbug.com/133312 GetTabbedBrowserBoundsAsh(bounds, show_state);
if (chrome::ShouldOpenAshOnStartup() &&
GetBoundsOverrideAsh(bounds, show_state))
return; return;
} 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.
GetSavedWindowBounds(bounds, show_state);
}
#endif #endif
// See if there's last active window's placement information. // See if there's last active window's placement information.
if (GetLastWindowBounds(bounds, show_state)) if (GetLastWindowBounds(bounds, show_state))
...@@ -213,9 +220,7 @@ void WindowSizer::DetermineWindowBoundsAndShowState( ...@@ -213,9 +220,7 @@ void WindowSizer::DetermineWindowBoundsAndShowState(
// In case of a popup with an 'unspecified' location in ash, we are // In case of a popup with an 'unspecified' location in ash, we are
// looking for a good screen location. We are interpreting (0,0) as an // looking for a good screen location. We are interpreting (0,0) as an
// unspecified location. // unspecified location.
if (chrome::ShouldOpenAshOnStartup() && if (IsPopupBrowserInAsh() && bounds->origin().IsOrigin()) {
browser_ && browser_->is_type_popup() &&
bounds->x() == 0 && bounds->y() == 0) {
*bounds = ChromeShellDelegate::instance()->window_positioner()-> *bounds = ChromeShellDelegate::instance()->window_positioner()->
GetPopupPosition(*bounds); GetPopupPosition(*bounds);
return; return;
...@@ -399,3 +404,21 @@ ui::WindowShowState WindowSizer::GetWindowDefaultShowState() const { ...@@ -399,3 +404,21 @@ ui::WindowShowState WindowSizer::GetWindowDefaultShowState() const {
// Otherwise we use the default which can be overridden later on. // Otherwise we use the default which can be overridden later on.
return ui::SHOW_STATE_DEFAULT; return ui::SHOW_STATE_DEFAULT;
} }
#if defined(USE_ASH)
bool WindowSizer::IsTabbedBrowserInAsh() const {
// TODO(beng): insufficient but currently necessary. http://crbug.com/133312
return chrome::ShouldOpenAshOnStartup() &&
browser_ &&
browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
browser_->is_type_tabbed();
}
bool WindowSizer::IsPopupBrowserInAsh() const {
// TODO(beng): insufficient but currently necessary. http://crbug.com/133312
return chrome::ShouldOpenAshOnStartup() &&
browser_ &&
browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
browser_->is_type_popup();
}
#endif
...@@ -155,13 +155,11 @@ class WindowSizer { ...@@ -155,13 +155,11 @@ class WindowSizer {
gfx::Rect* bounds) const; gfx::Rect* bounds) const;
#if defined(USE_ASH) #if defined(USE_ASH)
// Determines the position and size for an ash window as it gets created. This // Determines the position and size for a tabbed browser window in
// will be called before other standard placement logic. It will return true // ash as it gets created. This will be called before other standard
// when the function was setting the bounds structure to the desired size. // placement logic. |show_state| will only be changed
// Otherwise another algorithm should get used to determine the correct // if it was set to SHOW_STATE_DEFAULT.
// bounds. |show_state| will only be changed if it was set to void GetTabbedBrowserBoundsAsh(gfx::Rect* bounds_in_screen,
// SHOW_STATE_DEFAULT.
bool GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen,
ui::WindowShowState* show_state) const; ui::WindowShowState* show_state) const;
#endif #endif
...@@ -169,6 +167,11 @@ class WindowSizer { ...@@ -169,6 +167,11 @@ class WindowSizer {
// windows or at persistent information. // windows or at persistent information.
ui::WindowShowState GetWindowDefaultShowState() const; ui::WindowShowState GetWindowDefaultShowState() const;
#if defined(USE_ASH)
bool IsTabbedBrowserInAsh() const;
bool IsPopupBrowserInAsh() const;
#endif
// Providers for persistent storage and monitor metrics. // Providers for persistent storage and monitor metrics.
scoped_ptr<StateProvider> state_provider_; scoped_ptr<StateProvider> state_provider_;
gfx::Screen* screen_; // not owned. gfx::Screen* screen_; // not owned.
......
...@@ -11,12 +11,9 @@ ...@@ -11,12 +11,9 @@
#include "ash/wm/workspace/auto_window_management.h" #include "ash/wm/workspace/auto_window_management.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
#include "chrome/browser/ui/host_desktop.h"
#include "ui/aura/root_window.h" #include "ui/aura/root_window.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_delegate.h" #include "ui/aura/window_delegate.h"
...@@ -89,36 +86,26 @@ int WindowSizer::GetForceMaximizedWidthLimit() { ...@@ -89,36 +86,26 @@ int WindowSizer::GetForceMaximizedWidthLimit() {
return maximum_limit; return maximum_limit;
} }
bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, void WindowSizer::GetTabbedBrowserBoundsAsh(
gfx::Rect* bounds_in_screen,
ui::WindowShowState* show_state) const { ui::WindowShowState* show_state) const {
DCHECK(show_state); DCHECK(show_state);
DCHECK(bounds_in_screen); DCHECK(bounds_in_screen);
DCHECK(!browser_ || browser_->is_type_tabbed());
if (browser_ &&
browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) {
return false;
}
bounds_in_screen->SetRect(0, 0, 0, 0); bounds_in_screen->SetRect(0, 0, 0, 0);
// Experiment: Force the maximize mode for all windows. // Experiment: Force the maximize mode for all tabbed windows
if (ash::Shell::IsForcedMaximizeMode()) { if (ash::Shell::IsForcedMaximizeMode())
// Exceptions: Do not maximize popups and do not maximize windowed V1 apps
// which explicitly specify a |show_state| (they might be tuned for a
// particular resolution / type).
bool is_tabbed = browser_ && browser_->is_type_tabbed();
bool is_popup = browser_ && browser_->is_type_popup();
if (!is_popup && (is_tabbed || *show_state == ui::SHOW_STATE_DEFAULT))
*show_state = ui::SHOW_STATE_MAXIMIZED; *show_state = ui::SHOW_STATE_MAXIMIZED;
}
ui::WindowShowState passed_show_state = *show_state; ui::WindowShowState passed_show_state = *show_state;
bool has_saved_bounds = true; bool has_saved_bounds = true;
if (!GetSavedWindowBounds(bounds_in_screen, show_state)) { if (!GetSavedWindowBounds(bounds_in_screen, show_state)) {
has_saved_bounds = false; has_saved_bounds = false;
GetDefaultWindowBounds(bounds_in_screen); GetDefaultWindowBoundsAsh(bounds_in_screen);
} }
if (browser_ && browser_->is_type_tabbed()) {
aura::RootWindow* active = ash::Shell::GetActiveRootWindow(); aura::RootWindow* active = ash::Shell::GetActiveRootWindow();
// Always open new window in the active display. // Always open new window in the active display.
gfx::Rect work_area = gfx::Rect work_area =
...@@ -137,17 +124,16 @@ bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, ...@@ -137,17 +124,16 @@ bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen,
if (has_saved_bounds) { if (has_saved_bounds) {
// Restore to previous state - if there is one. // Restore to previous state - if there is one.
bounds_in_screen->AdjustToFit(work_area); bounds_in_screen->AdjustToFit(work_area);
return true; return;
} }
// When using "small screens" we want to always open in full screen mode. // When using "small screens" we want to always open in full screen mode.
if (passed_show_state == ui::SHOW_STATE_DEFAULT && if (passed_show_state == ui::SHOW_STATE_DEFAULT &&
!browser_->is_session_restore() && !browser_->is_session_restore() &&
work_area.width() <= GetForceMaximizedWidthLimit() && work_area.width() <= GetForceMaximizedWidthLimit() &&
(!browser_->window() || !browser_->window()->IsFullscreen()) && (!browser_->window() || !browser_->window()->IsFullscreen()))
(!browser_->fullscreen_controller() ||
!browser_->fullscreen_controller()->IsFullscreenForBrowser()))
*show_state = ui::SHOW_STATE_MAXIMIZED; *show_state = ui::SHOW_STATE_MAXIMIZED;
return true; return;
} }
bool maximized = ash::wm::IsWindowMaximized(top_window); bool maximized = ash::wm::IsWindowMaximized(top_window);
// We ignore the saved show state, but look instead for the top level // We ignore the saved show state, but look instead for the top level
...@@ -157,17 +143,9 @@ bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, ...@@ -157,17 +143,9 @@ bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen,
ui::SHOW_STATE_DEFAULT; ui::SHOW_STATE_DEFAULT;
} }
if (maximized)
return true;
// Use the size of the other window. The window's bound will be rearranged // Use the size of the other window. The window's bound will be rearranged
// in ash::WorkspaceLayoutManager using this location. // in ash::WorkspaceLayoutManager using this location.
*bounds_in_screen = top_window->GetBoundsInScreen(); *bounds_in_screen = top_window->GetBoundsInScreen();
return true;
}
return false;
} }
void WindowSizer::GetDefaultWindowBoundsAsh(gfx::Rect* default_bounds) const { void WindowSizer::GetDefaultWindowBoundsAsh(gfx::Rect* default_bounds) const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment