Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4016)

Unified Diff: chrome/browser/ui/window_sizer.h

Issue 8549008: Extract MonitorInfoProvider from WindowSizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add docs Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/constrained_window_views.cc ('k') | chrome/browser/ui/window_sizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/window_sizer.h
diff --git a/chrome/browser/ui/window_sizer.h b/chrome/browser/ui/window_sizer.h
index 20fe2d163e6017adeb1d20a849d3703d279254df..43e5179fb38d8cdd844865d441c85588ed0eec4c 100644
--- a/chrome/browser/ui/window_sizer.h
+++ b/chrome/browser/ui/window_sizer.h
@@ -6,14 +6,30 @@
#define CHROME_BROWSER_UI_WINDOW_SIZER_H_
#pragma once
-#include <vector>
-
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/rect.h"
class Browser;
+// An interface implemented by an object that can retrieve information about
+// the monitors on the system.
+class MonitorInfoProvider {
+ public:
+ virtual ~MonitorInfoProvider() {}
+
+ // Returns the bounds of the work area of the primary monitor.
+ virtual gfx::Rect GetPrimaryMonitorWorkArea() const = 0;
+
+ // Returns the bounds of the primary monitor.
+ virtual gfx::Rect GetPrimaryMonitorBounds() const = 0;
+
+ // Returns the bounds of the work area of the monitor that most closely
+ // intersects the provided bounds.
+ virtual gfx::Rect GetMonitorWorkAreaMatching(
+ const gfx::Rect& match_rect) const = 0;
+};
+
///////////////////////////////////////////////////////////////////////////////
// WindowSizer
//
@@ -27,55 +43,18 @@ class Browser;
//
class WindowSizer {
public:
- class MonitorInfoProvider;
class StateProvider;
- // The WindowSizer assumes ownership of these objects.
+ // WindowSizer owns |state_provider| and will create a default
+ // MonitorInfoProvider using the physical screen.
+ explicit WindowSizer(StateProvider* state_provider);
+
+ // WindowSizer owns |state_provider| and |monitor_info_provider|.
+ // It will use the supplied monitor info provider. Used only for testing.
WindowSizer(StateProvider* state_provider,
MonitorInfoProvider* monitor_info_provider);
- virtual ~WindowSizer();
- // Static factory methods to create default MonitorInfoProvider
- // instances. The returned object is owned by the caller.
- static MonitorInfoProvider* CreateDefaultMonitorInfoProvider();
-
- // An interface implemented by an object that can retrieve information about
- // the monitors on the system.
- class MonitorInfoProvider {
- public:
- MonitorInfoProvider() {}
- virtual ~MonitorInfoProvider() {}
-
- // Returns the bounds of the work area of the primary monitor.
- virtual gfx::Rect GetPrimaryMonitorWorkArea() const = 0;
-
- // Returns the bounds of the primary monitor.
- virtual gfx::Rect GetPrimaryMonitorBounds() const = 0;
-
- // Returns the bounds of the work area of the monitor that most closely
- // intersects the provided bounds.
- virtual gfx::Rect GetMonitorWorkAreaMatching(
- const gfx::Rect& match_rect) const = 0;
-
- // Ensures number and coordinates of work areas are up-to-date. You must
- // call this before calling either of the below functions, as work areas can
- // change while the program is running.
- virtual void UpdateWorkAreas() = 0;
-
- // Returns the number of monitors on the system.
- size_t GetMonitorCount() const {
- return work_areas_.size();
- }
-
- // Returns the bounds of the work area of the monitor at the specified
- // index.
- gfx::Rect GetWorkAreaAt(size_t index) const {
- return work_areas_[index];
- }
-
- protected:
- std::vector<gfx::Rect> work_areas_;
- };
+ virtual ~WindowSizer();
// An interface implemented by an object that can retrieve state from either a
// persistent store or an existing window.
@@ -140,10 +119,6 @@ class WindowSizer {
// size based on monitor size, etc.
void GetDefaultWindowBounds(gfx::Rect* default_bounds) const;
- // Returns true if the specified position is "offscreen" for the given edge,
- // meaning that it's outside all work areas in the direction of that edge.
- bool PositionIsOffscreen(int position, Edge edge) const;
-
// Adjusts |bounds| to be visible onscreen, 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;
« no previous file with comments | « chrome/browser/ui/views/constrained_window_views.cc ('k') | chrome/browser/ui/window_sizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698