| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_BASE_USER_ACTIVITY_USER_ACTIVITY_DETECTOR_H_ | 5 #ifndef UI_BASE_USER_ACTIVITY_USER_ACTIVITY_DETECTOR_H_ |
| 6 #define UI_BASE_USER_ACTIVITY_USER_ACTIVITY_DETECTOR_H_ | 6 #define UI_BASE_USER_ACTIVITY_USER_ACTIVITY_DETECTOR_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // is received that displays' power states are being changed. | 27 // is received that displays' power states are being changed. |
| 28 static const int kDisplayPowerChangeIgnoreMouseMs; | 28 static const int kDisplayPowerChangeIgnoreMouseMs; |
| 29 | 29 |
| 30 UserActivityDetector(); | 30 UserActivityDetector(); |
| 31 ~UserActivityDetector() override; | 31 ~UserActivityDetector() override; |
| 32 | 32 |
| 33 // Returns the UserActivityDetector instance if one was created. | 33 // Returns the UserActivityDetector instance if one was created. |
| 34 static UserActivityDetector* Get(); | 34 static UserActivityDetector* Get(); |
| 35 | 35 |
| 36 base::TimeTicks last_activity_time() const { return last_activity_time_; } | 36 base::TimeTicks last_activity_time() const { return last_activity_time_; } |
| 37 std::string last_activity_name() const { return last_activity_name_; } |
| 37 | 38 |
| 38 void set_now_for_test(base::TimeTicks now) { now_for_test_ = now; } | 39 void set_now_for_test(base::TimeTicks now) { now_for_test_ = now; } |
| 39 | 40 |
| 40 bool HasObserver(const UserActivityObserver* observer) const; | 41 bool HasObserver(const UserActivityObserver* observer) const; |
| 41 void AddObserver(UserActivityObserver* observer); | 42 void AddObserver(UserActivityObserver* observer); |
| 42 void RemoveObserver(UserActivityObserver* observer); | 43 void RemoveObserver(UserActivityObserver* observer); |
| 43 | 44 |
| 44 // Called when displays are about to be turned on or off. | 45 // Called when displays are about to be turned on or off. |
| 45 void OnDisplayPowerChanging(); | 46 void OnDisplayPowerChanging(); |
| 46 | 47 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 // Updates |last_activity_time_|. Additionally notifies observers and | 61 // Updates |last_activity_time_|. Additionally notifies observers and |
| 61 // updates |last_observer_notification_time_| if enough time has passed | 62 // updates |last_observer_notification_time_| if enough time has passed |
| 62 // since the last notification. | 63 // since the last notification. |
| 63 void HandleActivity(const ui::Event* event); | 64 void HandleActivity(const ui::Event* event); |
| 64 | 65 |
| 65 base::ObserverList<UserActivityObserver> observers_; | 66 base::ObserverList<UserActivityObserver> observers_; |
| 66 | 67 |
| 67 // Last time at which user activity was observed. | 68 // Last time at which user activity was observed. |
| 68 base::TimeTicks last_activity_time_; | 69 base::TimeTicks last_activity_time_; |
| 69 | 70 |
| 71 // Name of the last user activity event. |
| 72 std::string last_activity_name_; |
| 73 |
| 70 // Last time at which we notified observers that the user was active. | 74 // Last time at which we notified observers that the user was active. |
| 71 base::TimeTicks last_observer_notification_time_; | 75 base::TimeTicks last_observer_notification_time_; |
| 72 | 76 |
| 73 // If set, used when the current time is needed. This can be set by tests to | 77 // If set, used when the current time is needed. This can be set by tests to |
| 74 // simulate the passage of time. | 78 // simulate the passage of time. |
| 75 base::TimeTicks now_for_test_; | 79 base::TimeTicks now_for_test_; |
| 76 | 80 |
| 77 // If set, mouse events will be ignored until this time is reached. This | 81 // If set, mouse events will be ignored until this time is reached. This |
| 78 // is to avoid reporting mouse events that occur when displays are turned | 82 // is to avoid reporting mouse events that occur when displays are turned |
| 79 // on or off as user activity. | 83 // on or off as user activity. |
| 80 base::TimeTicks honor_mouse_events_time_; | 84 base::TimeTicks honor_mouse_events_time_; |
| 81 | 85 |
| 82 DISALLOW_COPY_AND_ASSIGN(UserActivityDetector); | 86 DISALLOW_COPY_AND_ASSIGN(UserActivityDetector); |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 } // namespace ui | 89 } // namespace ui |
| 86 | 90 |
| 87 #endif // UI_BASE_USER_ACTIVITY_USER_ACTIVITY_DETECTOR_H_ | 91 #endif // UI_BASE_USER_ACTIVITY_USER_ACTIVITY_DETECTOR_H_ |
| OLD | NEW |