Home | History | Annotate | Download | only in panels
      1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
      6 #define CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
      7 
      8 #include "base/gtest_prod_util.h"
      9 #include "base/observer_list.h"
     10 
     11 namespace gfx {
     12 class Point;
     13 }
     14 
     15 class PanelMouseWatcherObserver;
     16 
     17 // This is the base class for functionality to watch for mouse movements.
     18 // The specific implementation of this abstract class differ in how they
     19 // track mouse movements.
     20 class PanelMouseWatcher {
     21  public:
     22   // Returns an instance of the platform specific implementation.
     23   static PanelMouseWatcher* Create();
     24 
     25   // clang gives an error asking for an out of line destructor.
     26   virtual ~PanelMouseWatcher();
     27 
     28   void AddObserver(PanelMouseWatcherObserver* observer);
     29   void RemoveObserver(PanelMouseWatcherObserver* observer);
     30 
     31   // Returns current mouse position. This may be different from the
     32   // mouse position in NotifyMouseMovement.
     33   virtual gfx::Point GetMousePosition() const = 0;
     34 
     35  protected:
     36   PanelMouseWatcher();
     37 
     38   // |mouse_position| is in screen coordinates.
     39   virtual void NotifyMouseMovement(const gfx::Point& mouse_position);
     40 
     41   // Returns true if watching mouse movements.
     42   virtual bool IsActive() const = 0;
     43 
     44  private:
     45   friend class PanelMouseWatcherTest;
     46   FRIEND_TEST_ALL_PREFIXES(PanelMouseWatcherTest, StartStopWatching);
     47   friend class BasePanelBrowserTest;
     48 
     49   // Start/stop tracking mouse movements.
     50   virtual void Start() = 0;
     51   virtual void Stop() = 0;
     52 
     53   ObserverList<PanelMouseWatcherObserver> observers_;
     54 };
     55 
     56 #endif  // CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
     57