blob: 9ea9f439fb848883e8622f065478ac02f317578a [file] [log] [blame]
[email protected]08b14a52012-07-02 23:30:361// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]f5205412010-03-16 00:19:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
derat49b2fd52015-01-16 15:32:125#ifndef UI_BASE_IDLE_IDLE_H_
6#define UI_BASE_IDLE_IDLE_H_
[email protected]f5205412010-03-16 00:19:347
[email protected]97156b72011-08-18 13:32:128#include "base/callback.h"
avi20f6a6d532015-12-23 08:05:249#include "build/build_config.h"
derat49b2fd52015-01-16 15:32:1210#include "ui/base/ui_base_export.h"
11
12namespace ui {
[email protected]97156b72011-08-18 13:32:1213
[email protected]f5205412010-03-16 00:19:3414enum IdleState {
15 IDLE_STATE_ACTIVE = 0,
[email protected]9e5fbc92011-12-09 11:40:4916 IDLE_STATE_IDLE = 1, // No activity within threshold.
[email protected]97156b72011-08-18 13:32:1217 IDLE_STATE_LOCKED = 2, // Only available on supported systems.
18 IDLE_STATE_UNKNOWN = 3 // Used when waiting for the Idle state or in error
19 // conditions
[email protected]f5205412010-03-16 00:19:3420};
21
[email protected]3c645372011-01-25 20:54:0622// For MacOSX, InitIdleMonitor needs to be called first to setup the monitor.
[email protected]3c645372011-01-25 20:54:0623#if defined(OS_MACOSX)
derat49b2fd52015-01-16 15:32:1224UI_BASE_EXPORT void InitIdleMonitor();
[email protected]3c645372011-01-25 20:54:0625#endif
26
[email protected]97156b72011-08-18 13:32:1227typedef base::Callback<void(IdleState)> IdleCallback;
[email protected]4c120af2012-11-17 03:27:3428typedef base::Callback<void(int)> IdleTimeCallback;
[email protected]97156b72011-08-18 13:32:1229
[email protected]484deaa2013-03-01 03:10:3730// Calculate the Idle state and notify the callback. |idle_threshold| is the
31// amount of time (in seconds) before considered idle. |notify| is
32// asynchronously called on some platforms.
derat49b2fd52015-01-16 15:32:1233UI_BASE_EXPORT void CalculateIdleState(int idle_threshold, IdleCallback notify);
[email protected]4c120af2012-11-17 03:27:3434
35// Calculate Idle time in seconds and notify the callback
derat49b2fd52015-01-16 15:32:1236UI_BASE_EXPORT void CalculateIdleTime(IdleTimeCallback notify);
[email protected]f5205412010-03-16 00:19:3437
[email protected]80722b22011-09-10 07:54:5038// Checks synchronously if Idle state is IDLE_STATE_LOCKED.
derat49b2fd52015-01-16 15:32:1239UI_BASE_EXPORT bool CheckIdleStateIsLocked();
[email protected]08b14a52012-07-02 23:30:3640
derat49b2fd52015-01-16 15:32:1241} // namespace ui
42
43#endif // UI_BASE_IDLE_IDLE_H_