Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: ash/wm/user_activity_detector.cc

Issue 10544011: chromeos: Notify power manager about user activity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RootWindowEventFilter -> EnvEventFilter Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/user_activity_detector.h ('k') | ash/wm/user_activity_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "ash/wm/user_activity_detector.h"
6
7 #include "ash/wm/user_activity_observer.h"
8
9 namespace ash {
10
11 const double UserActivityDetector::kNotifyIntervalSec = 1.0;
12
13 UserActivityDetector::UserActivityDetector() {
14 }
15
16 UserActivityDetector::~UserActivityDetector() {
17 }
18
19 void UserActivityDetector::AddObserver(UserActivityObserver* observer) {
20 observers_.AddObserver(observer);
21 }
22
23 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) {
24 observers_.RemoveObserver(observer);
25 }
26
27 bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target,
28 aura::KeyEvent* event) {
29 MaybeNotify();
30 return false;
31 }
32
33 bool UserActivityDetector::PreHandleMouseEvent(aura::Window* target,
34 aura::MouseEvent* event) {
35 MaybeNotify();
36 return false;
37 }
38
39 ui::TouchStatus UserActivityDetector::PreHandleTouchEvent(
40 aura::Window* target,
41 aura::TouchEvent* event) {
42 MaybeNotify();
43 return ui::TOUCH_STATUS_UNKNOWN;
44 }
45
46 ui::GestureStatus UserActivityDetector::PreHandleGestureEvent(
47 aura::Window* target,
48 aura::GestureEvent* event) {
49 MaybeNotify();
50 return ui::GESTURE_STATUS_UNKNOWN;
51 }
52
53 void UserActivityDetector::MaybeNotify() {
54 base::TimeTicks now = base::TimeTicks::Now();
55 if (last_observer_notification_time_.is_null() ||
56 (now - last_observer_notification_time_).InSecondsF() >=
57 kNotifyIntervalSec) {
58 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity());
59 last_observer_notification_time_ = now;
60 }
61 }
62
63 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/user_activity_detector.h ('k') | ash/wm/user_activity_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698