| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 5 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" | 7 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
| 8 #include "ui/gfx/point.h" | 8 #include "ui/gfx/geometry/point.h" |
| 9 | 9 |
| 10 PanelMouseWatcher::PanelMouseWatcher() { | 10 PanelMouseWatcher::PanelMouseWatcher() { |
| 11 } | 11 } |
| 12 | 12 |
| 13 PanelMouseWatcher::~PanelMouseWatcher() { | 13 PanelMouseWatcher::~PanelMouseWatcher() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 void PanelMouseWatcher::AddObserver(PanelMouseWatcherObserver* observer) { | 16 void PanelMouseWatcher::AddObserver(PanelMouseWatcherObserver* observer) { |
| 17 bool already_started = observers_.might_have_observers(); | 17 bool already_started = observers_.might_have_observers(); |
| 18 observers_.AddObserver(observer); | 18 observers_.AddObserver(observer); |
| 19 if (!already_started) | 19 if (!already_started) |
| 20 Start(); | 20 Start(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void PanelMouseWatcher::RemoveObserver(PanelMouseWatcherObserver* observer) { | 23 void PanelMouseWatcher::RemoveObserver(PanelMouseWatcherObserver* observer) { |
| 24 DCHECK(observers_.HasObserver(observer)); | 24 DCHECK(observers_.HasObserver(observer)); |
| 25 observers_.RemoveObserver(observer); | 25 observers_.RemoveObserver(observer); |
| 26 if (!observers_.might_have_observers()) | 26 if (!observers_.might_have_observers()) |
| 27 Stop(); | 27 Stop(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void PanelMouseWatcher::NotifyMouseMovement(const gfx::Point& mouse_position) { | 30 void PanelMouseWatcher::NotifyMouseMovement(const gfx::Point& mouse_position) { |
| 31 FOR_EACH_OBSERVER(PanelMouseWatcherObserver, observers_, | 31 FOR_EACH_OBSERVER(PanelMouseWatcherObserver, observers_, |
| 32 OnMouseMove(mouse_position)); | 32 OnMouseMove(mouse_position)); |
| 33 } | 33 } |
| OLD | NEW |