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.
5 #ifndef UI_BASE_IDLE_IDLE_H_
6 #define UI_BASE_IDLE_IDLE_H_
8 #include "base/callback.h"
9 #include "ui/base/ui_base_export.h"
14 IDLE_STATE_ACTIVE
= 0,
15 IDLE_STATE_IDLE
= 1, // No activity within threshold.
16 IDLE_STATE_LOCKED
= 2, // Only available on supported systems.
17 IDLE_STATE_UNKNOWN
= 3 // Used when waiting for the Idle state or in error
21 // For MacOSX, InitIdleMonitor needs to be called first to setup the monitor.
22 #if defined(OS_MACOSX)
23 UI_BASE_EXPORT
void InitIdleMonitor();
26 typedef base::Callback
<void(IdleState
)> IdleCallback
;
27 typedef base::Callback
<void(int)> IdleTimeCallback
;
29 // Calculate the Idle state and notify the callback. |idle_threshold| is the
30 // amount of time (in seconds) before considered idle. |notify| is
31 // asynchronously called on some platforms.
32 UI_BASE_EXPORT
void CalculateIdleState(int idle_threshold
, IdleCallback notify
);
34 // Calculate Idle time in seconds and notify the callback
35 UI_BASE_EXPORT
void CalculateIdleTime(IdleTimeCallback notify
);
37 // Checks synchronously if Idle state is IDLE_STATE_LOCKED.
38 UI_BASE_EXPORT
bool CheckIdleStateIsLocked();
42 #endif // UI_BASE_IDLE_IDLE_H_