Chromium Code Reviews| Index: chrome/browser/ui/window_sizer/window_sizer.h |
| diff --git a/chrome/browser/ui/window_sizer/window_sizer.h b/chrome/browser/ui/window_sizer/window_sizer.h |
| index bbc69aefe8eca40be1264b98be00a8ca544a7e9a..dc788205d101e0d22c7d857bf5a33231dde0d856 100644 |
| --- a/chrome/browser/ui/window_sizer/window_sizer.h |
| +++ b/chrome/browser/ui/window_sizer/window_sizer.h |
| @@ -32,14 +32,18 @@ class Screen; |
| class WindowSizer { |
| public: |
| class StateProvider; |
| + class TargetDisplayProvider; |
| - // WindowSizer owns |state_provider| and will create a default |
| - // MonitorInfoProvider using the physical screen. |
| - WindowSizer(StateProvider* state_provider, const Browser* browser); |
| + // WindowSizer owns |state_provider| and |target_display_provider|, |
| + // and will use the platforms's gfx::Screen. |
| + WindowSizer(StateProvider* state_provider, |
| + TargetDisplayProvider* target_display_provider, |
|
sky
2013/12/07 00:40:28
scoped_ptr<TargetDisplayProvider>
oshima
2013/12/07 01:01:38
Done.
|
| + const Browser* browser); |
| - // WindowSizer owns |state_provider| and will use the supplied |screen|. |
| - // Used only for testing. |
| + // WindowSizer owns |state_provider| and |target_display_provider|, |
| + // and will use the supplied |screen|. Used only for testing. |
| WindowSizer(StateProvider* state_provider, |
| + TargetDisplayProvider* target_display_provider, |
| gfx::Screen* screen, |
| const Browser* browser); |
| @@ -69,6 +73,15 @@ class WindowSizer { |
| ui::WindowShowState* show_state) const = 0; |
| }; |
| + // An interface implemented by an object that to identify on which display |
|
sky
2013/12/07 00:40:28
nuke 'that'
oshima
2013/12/07 01:01:38
Done.
|
| + // a new window should be located. |
| + class TargetDisplayProvider { |
| + public: |
| + virtual ~TargetDisplayProvider() {} |
| + virtual gfx::Display GetTargetDisplay(const gfx::Screen* screen, |
| + const gfx::Rect& bounds) const = 0; |
| + }; |
| + |
| // Determines the position and size for a window as it is created as well |
| // as the initial state. This function uses several strategies to figure out |
| // optimal size and placement, first looking for an existing active window, |
| @@ -106,12 +119,12 @@ class WindowSizer { |
| // The edge of the screen to check for out-of-bounds. |
| enum Edge { TOP, LEFT, BOTTOM, RIGHT }; |
| - // Gets the size and placement of the last window. Returns true if this data |
| - // is valid, false if there is no last window and the application should |
| + // Gets the size and placement of the last active window. Returns true if this |
| + // data is valid, false if there is no last window and the application should |
| // restore saved state from preferences using RestoreWindowPosition. |
| // |show_state| will only be changed if it was set to SHOW_STATE_DEFAULT. |
| - bool GetLastWindowBounds(gfx::Rect* bounds, |
| - ui::WindowShowState* show_state) const; |
| + bool GetLastActiveWindowBounds(gfx::Rect* bounds, |
| + ui::WindowShowState* show_state) const; |
| // Gets the size and placement of the last window in the last session, saved |
| // in local state preferences. Returns true if local state exists containing |
| @@ -129,18 +142,23 @@ class WindowSizer { |
| gfx::Rect* default_bounds) const; |
| // Adjusts |bounds| to be visible on-screen, biased toward the work area of |
| - // the monitor containing |other_bounds|. Despite the name, this doesn't |
| - // guarantee the bounds are fully contained within this monitor's work rect; |
| + // the |display|. Despite the name, this doesn't |
| + // guarantee the bounds are fully contained within this display's work rect; |
| // it just tried to ensure the edges are visible on _some_ work rect. |
| // If |saved_work_area| is non-empty, it is used to determine whether the |
| // monitor configuration has changed. If it has, bounds are repositioned and |
| // resized if necessary to make them completely contained in the current work |
| // area. |
| - void AdjustBoundsToBeVisibleOnMonitorContaining( |
| - const gfx::Rect& other_bounds, |
| + void AdjustBoundsToBeVisibleOnDisplay( |
| + const gfx::Display& display, |
| const gfx::Rect& saved_work_area, |
| gfx::Rect* bounds) const; |
| + // Determine the target display for a new window based on |
| + // |bounds|. On ash environment, this returns the display containing |
| + // ash's the target root window. |
| + gfx::Display GetTargetDisplay(const gfx::Rect& bounds) const; |
| + |
| #if defined(USE_ASH) |
| // Determines the position and size for a tabbed browser window in |
| // ash as it gets created. This will be called before other standard |
| @@ -161,6 +179,7 @@ class WindowSizer { |
| // Providers for persistent storage and monitor metrics. |
| scoped_ptr<StateProvider> state_provider_; |
| + scoped_ptr<TargetDisplayProvider> target_display_provider_; |
| gfx::Screen* screen_; // not owned. |
| // Note that this browser handle might be NULL. |