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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 6 7 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" 8 #include "ui/gfx/point.h" 9 10 PanelMouseWatcher::PanelMouseWatcher() { 11 } 12 13 PanelMouseWatcher::~PanelMouseWatcher() { 14 } 15 16 void PanelMouseWatcher::AddObserver(PanelMouseWatcherObserver* observer) { 17 bool already_started = observers_.might_have_observers(); 18 observers_.AddObserver(observer); 19 if (!already_started) 20 Start(); 21 } 22 23 void PanelMouseWatcher::RemoveObserver(PanelMouseWatcherObserver* observer) { 24 DCHECK(observers_.HasObserver(observer)); 25 observers_.RemoveObserver(observer); 26 if (!observers_.might_have_observers()) 27 Stop(); 28 } 29 30 void PanelMouseWatcher::NotifyMouseMovement(const gfx::Point& mouse_position) { 31 FOR_EACH_OBSERVER(PanelMouseWatcherObserver, observers_, 32 OnMouseMove(mouse_position)); 33 } 34