OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_WM_USER_ACTIVITY_DETECTOR_H_ | 5 #ifndef ASH_WM_USER_ACTIVITY_DETECTOR_H_ |
6 #define ASH_WM_USER_ACTIVITY_DETECTOR_H_ | 6 #define ASH_WM_USER_ACTIVITY_DETECTOR_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 void set_now_for_test(base::TimeTicks now) { now_for_test_ = now; } | 28 void set_now_for_test(base::TimeTicks now) { now_for_test_ = now; } |
29 | 29 |
30 bool HasObserver(UserActivityObserver* observer) const; | 30 bool HasObserver(UserActivityObserver* observer) const; |
31 void AddObserver(UserActivityObserver* observer); | 31 void AddObserver(UserActivityObserver* observer); |
32 void RemoveObserver(UserActivityObserver* observer); | 32 void RemoveObserver(UserActivityObserver* observer); |
33 | 33 |
34 // Called when chrome has received a request to turn of all displays. | 34 // Called when chrome has received a request to turn of all displays. |
35 void OnAllOutputsTurnedOff(); | 35 void OnAllOutputsTurnedOff(); |
36 | 36 |
37 // ui::EventHandler implementation. | 37 // ui::EventHandler implementation. |
38 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 38 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
39 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 39 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
40 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 40 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
41 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 41 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
42 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 42 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
43 | 43 |
44 private: | 44 private: |
45 // Notifies observers if enough time has passed since the last notification. | 45 // Notifies observers if enough time has passed since the last notification. |
46 void MaybeNotify(); | 46 void MaybeNotify(); |
47 | 47 |
48 ObserverList<UserActivityObserver> observers_; | 48 ObserverList<UserActivityObserver> observers_; |
49 | 49 |
50 // Last time at which we notified observers that the user was active. | 50 // Last time at which we notified observers that the user was active. |
51 base::TimeTicks last_observer_notification_time_; | 51 base::TimeTicks last_observer_notification_time_; |
52 | 52 |
53 // If set, used when the current time is needed. This can be set by tests to | 53 // If set, used when the current time is needed. This can be set by tests to |
54 // simulate the passage of time. | 54 // simulate the passage of time. |
55 base::TimeTicks now_for_test_; | 55 base::TimeTicks now_for_test_; |
56 | 56 |
57 // When this is true, the next mouse event is ignored. This is to | 57 // When this is true, the next mouse event is ignored. This is to |
58 // avoid mis-detecting a mouse enter event that occurs when turning | 58 // avoid mis-detecting a mouse enter event that occurs when turning |
59 // off display as a user activity. | 59 // off display as a user activity. |
60 bool ignore_next_mouse_event_; | 60 bool ignore_next_mouse_event_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(UserActivityDetector); | 62 DISALLOW_COPY_AND_ASSIGN(UserActivityDetector); |
63 }; | 63 }; |
64 | 64 |
65 } // namespace ash | 65 } // namespace ash |
66 | 66 |
67 #endif // ASH_WM_USER_ACTIVITY_DETECTOR_H_ | 67 #endif // ASH_WM_USER_ACTIVITY_DETECTOR_H_ |
OLD | NEW |