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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/user_activity_detector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/user_activity_detector.h
diff --git a/ash/wm/user_activity_detector.h b/ash/wm/user_activity_detector.h
new file mode 100644
index 0000000000000000000000000000000000000000..25bf7e29d010947fe25a7e0d34b5de7cb1986acf
--- /dev/null
+++ b/ash/wm/user_activity_detector.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_USER_ACTIVITY_DETECTOR_H_
+#define ASH_WM_USER_ACTIVITY_DETECTOR_H_
+#pragma once
+
+#include "ash/ash_export.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/observer_list.h"
+#include "base/time.h"
+#include "ui/aura/event_filter.h"
+
+namespace ash {
+
+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.
+ public:
+ // Invoked periodically while the user is active (i.e. generating input
+ // events).
+ virtual void OnUserActivity() = 0;
+
+ protected:
+ virtual ~UserActivityObserver() {}
+};
+
+// Watches for input events and notifies observers that the user is active.
+class ASH_EXPORT UserActivityDetector : public aura::EventFilter {
+ public:
+ // Minimum amount of time between notifications to observers that a video is
+ // playing.
+ static const double kNotifyIntervalSec;
+
+ UserActivityDetector();
+ virtual ~UserActivityDetector();
+
+ void AddObserver(UserActivityObserver* observer);
+ void RemoveObserver(UserActivityObserver* observer);
+
+ // aura::EventFilter implementation.
+ virtual bool PreHandleKeyEvent(
+ 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.
+ virtual bool PreHandleMouseEvent(
+ aura::Window* target, aura::MouseEvent* event) OVERRIDE;
+ virtual ui::TouchStatus PreHandleTouchEvent(
+ aura::Window* target, aura::TouchEvent* event) OVERRIDE;
+ virtual ui::GestureStatus PreHandleGestureEvent(
+ aura::Window* target, aura::GestureEvent* event) OVERRIDE;
+
+ private:
+ // Notifies observers if enough time has passed since the last notification.
+ void MaybeNotify();
+
+ ObserverList<UserActivityObserver> observers_;
+
+ // Last time at which we notified observers that the user was active.
+ base::TimeTicks last_observer_notification_time_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserActivityDetector);
+};
+
+} // namespace ash
+
+#endif // ASH_WM_USER_ACTIVITY_DETECTOR_H_
« 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