diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 03:42:39 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 03:42:39 +0000 |
commit | b9281ac4b0bbe0068d47ff83e153603734c2b264 (patch) | |
tree | a21949bfa8d1bbaf9f85d1aa59791c4bc4aa36c2 /chrome/browser/ui/panels/panel_mouse_watcher.cc | |
parent | 27da4f022516b2db00f325e7d76a3265a90c6e4b (diff) | |
download | chromium_src-b9281ac4b0bbe0068d47ff83e153603734c2b264.zip chromium_src-b9281ac4b0bbe0068d47ff83e153603734c2b264.tar.gz chromium_src-b9281ac4b0bbe0068d47ff83e153603734c2b264.tar.bz2 |
Convert PanelMouseWatcher to have more than one observer.
BUG=None
TEST=PanelMouseWatcherTest.*
Review URL: http://codereview.chromium.org/8677031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/panels/panel_mouse_watcher.cc')
-rw-r--r-- | chrome/browser/ui/panels/panel_mouse_watcher.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/ui/panels/panel_mouse_watcher.cc b/chrome/browser/ui/panels/panel_mouse_watcher.cc index dc2ab15..b55ca76 100644 --- a/chrome/browser/ui/panels/panel_mouse_watcher.cc +++ b/chrome/browser/ui/panels/panel_mouse_watcher.cc @@ -4,15 +4,29 @@ #include "chrome/browser/ui/panels/panel_mouse_watcher.h" +#include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" #include "ui/gfx/point.h" -PanelMouseWatcher::PanelMouseWatcher(Observer* observer) - : observer_(observer) { +PanelMouseWatcher::PanelMouseWatcher() { } PanelMouseWatcher::~PanelMouseWatcher() { } +void PanelMouseWatcher::AddObserver(PanelMouseWatcherObserver* observer) { + observers_.AddObserver(observer); + if (observers_.size() == 1) + Start(); +} + +void PanelMouseWatcher::RemoveObserver(PanelMouseWatcherObserver* observer) { + DCHECK(observers_.HasObserver(observer)); + observers_.RemoveObserver(observer); + if (observers_.size() == 0) + Stop(); +} + void PanelMouseWatcher::NotifyMouseMovement(const gfx::Point& mouse_position) { - observer_->OnMouseMove(mouse_position); + FOR_EACH_OBSERVER(PanelMouseWatcherObserver, observers_, + OnMouseMove(mouse_position)); } |