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 #include "ash/wm/user_activity_detector.h" | 5 #include "ash/wm/user_activity_detector.h" |
6 | 6 |
7 #include "ash/wm/property_util.h" | 7 #include "ash/wm/property_util.h" |
8 #include "ash/wm/user_activity_observer.h" | 8 #include "ash/wm/user_activity_observer.h" |
9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 ui::EventResult UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) { | 51 ui::EventResult UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) { |
52 MaybeNotify(); | 52 MaybeNotify(); |
53 return ui::ER_UNHANDLED; | 53 return ui::ER_UNHANDLED; |
54 } | 54 } |
55 | 55 |
56 ui::EventResult UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { | 56 ui::EventResult UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { |
57 MaybeNotify(); | 57 MaybeNotify(); |
58 return ui::ER_UNHANDLED; | 58 return ui::ER_UNHANDLED; |
59 } | 59 } |
60 | 60 |
61 ui::EventResult UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { | 61 void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { |
62 MaybeNotify(); | 62 MaybeNotify(); |
63 return ui::ER_UNHANDLED; | |
64 } | 63 } |
65 | 64 |
66 void UserActivityDetector::MaybeNotify() { | 65 void UserActivityDetector::MaybeNotify() { |
67 base::TimeTicks now = | 66 base::TimeTicks now = |
68 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); | 67 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); |
69 if (last_observer_notification_time_.is_null() || | 68 if (last_observer_notification_time_.is_null() || |
70 (now - last_observer_notification_time_).InMillisecondsF() >= | 69 (now - last_observer_notification_time_).InMillisecondsF() >= |
71 kNotifyIntervalMs) { | 70 kNotifyIntervalMs) { |
72 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); | 71 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); |
73 last_observer_notification_time_ = now; | 72 last_observer_notification_time_ = now; |
74 } | 73 } |
75 } | 74 } |
76 | 75 |
77 } // namespace ash | 76 } // namespace ash |
OLD | NEW |