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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_
6 #define CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/compiler_specific.h"
11 #include "base/time/time.h"
12 #include "base/timer/timer.h"
13 #include "ui/base/user_activity/user_activity_observer.h"
17 class IdleDetector
: public ui::UserActivityObserver
{
19 explicit IdleDetector(const base::Closure
& on_idle_callback
);
20 ~IdleDetector() override
;
22 void Start(const base::TimeDelta
& timeout
);
25 // ui::UserActivityObserver overrides:
26 void OnUserActivity(const ui::Event
* event
) override
;
28 // Resets |timer_| to fire when we reach our idle timeout.
31 base::OneShotTimer
<IdleDetector
> timer_
;
33 base::Closure idle_callback_
;
35 base::TimeDelta timeout_
;
37 DISALLOW_COPY_AND_ASSIGN(IdleDetector
);
40 } // namespace chromeos
42 #endif // CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_