Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
derat | 49b2fd5 | 2015-01-16 15:32:12 | [diff] [blame] | 5 | #ifndef UI_BASE_IDLE_IDLE_H_ |
6 | #define UI_BASE_IDLE_IDLE_H_ | ||||
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 7 | |
Steven Bennetts | 2b2d9cf | 2019-03-15 17:36:31 | [diff] [blame] | 8 | #include "base/component_export.h" |
avi | 20f6a6d53 | 2015-12-23 08:05:24 | [diff] [blame] | 9 | #include "build/build_config.h" |
derat | 49b2fd5 | 2015-01-16 15:32:12 | [diff] [blame] | 10 | |
11 | namespace ui { | ||||
[email protected] | 97156b7 | 2011-08-18 13:32:12 | [diff] [blame] | 12 | |
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 13 | enum IdleState { |
14 | IDLE_STATE_ACTIVE = 0, | ||||
[email protected] | 9e5fbc9 | 2011-12-09 11:40:49 | [diff] [blame] | 15 | IDLE_STATE_IDLE = 1, // No activity within threshold. |
[email protected] | 97156b7 | 2011-08-18 13:32:12 | [diff] [blame] | 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 | ||||
18 | // conditions | ||||
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 19 | }; |
20 | |||||
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 21 | // For MacOSX, InitIdleMonitor needs to be called first to setup the monitor. |
Xiaohan Wang | 8407409 | 2022-01-20 21:25:54 | [diff] [blame] | 22 | #if BUILDFLAG(IS_APPLE) |
Steven Bennetts | 2b2d9cf | 2019-03-15 17:36:31 | [diff] [blame] | 23 | COMPONENT_EXPORT(UI_BASE_IDLE) void InitIdleMonitor(); |
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 24 | #endif |
25 | |||||
Reilly Grant | e26b611 | 2018-12-20 17:32:58 | [diff] [blame] | 26 | // Calculate the Idle state. |idle_threshold| is the amount of time (in seconds) |
27 | // before the user is considered idle. | ||||
Steven Bennetts | 2b2d9cf | 2019-03-15 17:36:31 | [diff] [blame] | 28 | COMPONENT_EXPORT(UI_BASE_IDLE) IdleState CalculateIdleState(int idle_threshold); |
[email protected] | 97156b7 | 2011-08-18 13:32:12 | [diff] [blame] | 29 | |
Reilly Grant | e26b611 | 2018-12-20 17:32:58 | [diff] [blame] | 30 | // Calculate Idle time in seconds. |
Steven Bennetts | 2b2d9cf | 2019-03-15 17:36:31 | [diff] [blame] | 31 | COMPONENT_EXPORT(UI_BASE_IDLE) int CalculateIdleTime(); |
[email protected] | f520541 | 2010-03-16 00:19:34 | [diff] [blame] | 32 | |
[email protected] | 80722b2 | 2011-09-10 07:54:50 | [diff] [blame] | 33 | // Checks synchronously if Idle state is IDLE_STATE_LOCKED. |
Steven Bennetts | 2b2d9cf | 2019-03-15 17:36:31 | [diff] [blame] | 34 | COMPONENT_EXPORT(UI_BASE_IDLE) bool CheckIdleStateIsLocked(); |
[email protected] | 08b14a5 | 2012-07-02 23:30:36 | [diff] [blame] | 35 | |
derat | 49b2fd5 | 2015-01-16 15:32:12 | [diff] [blame] | 36 | } // namespace ui |
37 | |||||
38 | #endif // UI_BASE_IDLE_IDLE_H_ |