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

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

Issue 10544011: chromeos: Notify power manager about user activity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/shell.cc ('k') | ash/wm/user_activity_detector.cc » ('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 #ifndef ASH_WM_USER_ACTIVITY_DETECTOR_H_
6 #define ASH_WM_USER_ACTIVITY_DETECTOR_H_
7 #pragma once
8
9 #include "ash/ash_export.h"
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/observer_list.h"
13 #include "base/time.h"
14 #include "ui/aura/event_filter.h"
15
16 namespace ash {
17
18 class ASH_EXPORT UserActivityObserver {
sky 2012/06/05 20:24:21 nit: move into its own header.
Daniel Erat 2012/06/05 20:56:43 Done.
19 public:
20 // Invoked periodically while the user is active (i.e. generating input
21 // events).
22 virtual void OnUserActivity() = 0;
23
24 protected:
25 virtual ~UserActivityObserver() {}
26 };
27
28 // Watches for input events and notifies observers that the user is active.
29 class ASH_EXPORT UserActivityDetector : public aura::EventFilter {
30 public:
31 // Minimum amount of time between notifications to observers that a video is
32 // playing.
33 static const double kNotifyIntervalSec;
34
35 UserActivityDetector();
36 virtual ~UserActivityDetector();
37
38 void AddObserver(UserActivityObserver* observer);
39 void RemoveObserver(UserActivityObserver* observer);
40
41 // aura::EventFilter implementation.
42 virtual bool PreHandleKeyEvent(
43 aura::Window* target, aura::KeyEvent* event) OVERRIDE;
sky 2012/06/05 20:24:21 nit: its my understanding once you wrap, then each
Daniel Erat 2012/06/05 20:56:43 Wasn't aware of this. Done.
44 virtual bool PreHandleMouseEvent(
45 aura::Window* target, aura::MouseEvent* event) OVERRIDE;
46 virtual ui::TouchStatus PreHandleTouchEvent(
47 aura::Window* target, aura::TouchEvent* event) OVERRIDE;
48 virtual ui::GestureStatus PreHandleGestureEvent(
49 aura::Window* target, aura::GestureEvent* event) OVERRIDE;
50
51 private:
52 // Notifies observers if enough time has passed since the last notification.
53 void MaybeNotify();
54
55 ObserverList<UserActivityObserver> observers_;
56
57 // Last time at which we notified observers that the user was active.
58 base::TimeTicks last_observer_notification_time_;
59
60 DISALLOW_COPY_AND_ASSIGN(UserActivityDetector);
61 };
62
63 } // namespace ash
64
65 #endif // ASH_WM_USER_ACTIVITY_DETECTOR_H_
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/user_activity_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698