summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/panels/panel_mouse_watcher.h
blob: 7ba476794db87575f7687855c39ac5d534c9dfa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
#define CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_

#include "base/gtest_prod_util.h"
#include "base/observer_list.h"

namespace gfx {
class Point;
}

class PanelMouseWatcherObserver;

// This is the base class for functionality to watch for mouse movements.
// The specific implementation of this abstract class differ in how they
// track mouse movements.
class PanelMouseWatcher {
 public:
  // Returns an instance of the platform specific implementation.
  static PanelMouseWatcher* Create();

  // clang gives an error asking for an out of line destructor.
  virtual ~PanelMouseWatcher();

  void AddObserver(PanelMouseWatcherObserver* observer);
  void RemoveObserver(PanelMouseWatcherObserver* observer);

  // Returns current mouse position. This may be different from the
  // mouse position in NotifyMouseMovement.
  virtual gfx::Point GetMousePosition() const = 0;

 protected:
  PanelMouseWatcher();

  // |mouse_position| is in screen coordinates.
  virtual void NotifyMouseMovement(const gfx::Point& mouse_position);

  // Returns true if watching mouse movements.
  virtual bool IsActive() const = 0;

 private:
  friend class PanelMouseWatcherTest;
  FRIEND_TEST_ALL_PREFIXES(PanelMouseWatcherTest, StartStopWatching);
  friend class BasePanelBrowserTest;

  // Start/stop tracking mouse movements.
  virtual void Start() = 0;
  virtual void Stop() = 0;

  ObserverList<PanelMouseWatcherObserver> observers_;
};

#endif  // CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_