diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-15 23:26:02 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-15 23:26:02 +0000 |
commit | f8c2c0bd79ea4cbafe326f92cd6d4b60e0e0ae71 (patch) | |
tree | 555b4389d14e8fbe10805de9013fcb1c5763ef5a /chrome | |
parent | a51bf895ffc17144c2094acf550b0ab2bf00bb5e (diff) | |
download | chromium_src-f8c2c0bd79ea4cbafe326f92cd6d4b60e0e0ae71.zip chromium_src-f8c2c0bd79ea4cbafe326f92cd6d4b60e0e0ae71.tar.gz chromium_src-f8c2c0bd79ea4cbafe326f92cd6d4b60e0e0ae71.tar.bz2 |
Adds a factory method for creating DockInfos.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/75015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/dock_info.cc | 8 | ||||
-rw-r--r-- | chrome/browser/dock_info.h | 22 |
2 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/dock_info.cc b/chrome/browser/dock_info.cc index 92ee871..a9c2561 100644 --- a/chrome/browser/dock_info.cc +++ b/chrome/browser/dock_info.cc @@ -331,8 +331,14 @@ class DockToWindowFinder : public BaseWindowFinder { // DockInfo ------------------------------------------------------------------- // static +DockInfo::Factory* DockInfo::factory_ = NULL; + +// static DockInfo DockInfo::GetDockInfoAtPoint(const gfx::Point& screen_point, const std::set<HWND>& ignore) { + if (factory_) + return factory_->GetDockInfoAtPoint(screen_point, ignore); + // Try docking to a window first. DockInfo info = DockToWindowFinder::GetDockInfoAtPoint(screen_point, ignore); if (info.type() != DockInfo::NONE) @@ -368,6 +374,8 @@ int DockInfo::popup_height() { HWND DockInfo::GetLocalProcessWindowAtPoint(const gfx::Point& screen_point, const std::set<HWND>& ignore) { + if (factory_) + return factory_->GetLocalProcessWindowAtPoint(screen_point, ignore); return LocalProcessWindowFinder::GetProcessWindowAtPoint(screen_point, ignore); } diff --git a/chrome/browser/dock_info.h b/chrome/browser/dock_info.h index dd94563..0774e6b 100644 --- a/chrome/browser/dock_info.h +++ b/chrome/browser/dock_info.h @@ -25,6 +25,15 @@ class Profile; // DockInfos are cheap and explicitly allow copy and assignment operators. class DockInfo { public: + class Factory { + public: + virtual DockInfo GetDockInfoAtPoint(const gfx::Point& screen_point, + const std::set<HWND>& ignore) = 0; + + virtual HWND GetLocalProcessWindowAtPoint(const gfx::Point& screen_point, + const std::set<HWND>& ignore) = 0; + }; + // Possible dock positions. enum Type { // Indicates there is no valid dock position for the current location. @@ -48,6 +57,9 @@ class DockInfo { DockInfo() : type_(NONE), hwnd_(NULL), in_enable_area_(false) {} + // Sets the factory. + static void set_factory(Factory* factory) { factory_ = factory; } + // Size of the popup window shown to indicate a valid dock location. static int popup_width(); static int popup_height(); @@ -58,6 +70,9 @@ class DockInfo { // // If there is no docking position for the specified location the returned // DockInfo has a type of NONE. + // + // If a Factory has been set, the method of the same name is invoked on the + // Factory to determine the DockInfo. static DockInfo GetDockInfoAtPoint(const gfx::Point& screen_point, const std::set<HWND>& ignore); @@ -65,6 +80,9 @@ class DockInfo { // See GetDockInfoAtPoint for a description of |ignore|. This returns NULL if // there is no window from the current process at |screen_point|, or another // window obscures the topmost window from our process at |screen_point|. + // + // If a Factory has been set, the method of the same name is invoked on the + // Factory to determine the DockInfo. static HWND GetLocalProcessWindowAtPoint(const gfx::Point& screen_point, const std::set<HWND>& ignore); @@ -139,6 +157,10 @@ class DockInfo { gfx::Point hot_spot_; gfx::Rect monitor_bounds_; bool in_enable_area_; + + // Factory that creates DockInfos. By default this is NULL, which gives the + // default behavior. + static Factory* factory_; }; #endif // CHROME_BROWSER_DOCK_INFO_H_ |