diff options
author | courage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 02:00:03 +0000 |
---|---|---|
committer | courage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 02:00:03 +0000 |
commit | 99fd10c7cd3f68cd0346a98cf536fc6546e1ff20 (patch) | |
tree | 1f71ddd46466cf7289b7664ebfe326628b665d77 /chrome/browser/idle_win.cc | |
parent | 6d1710f48c3ede83eaf1382ad5b5676ed409d7ea (diff) | |
download | chromium_src-99fd10c7cd3f68cd0346a98cf536fc6546e1ff20.zip chromium_src-99fd10c7cd3f68cd0346a98cf536fc6546e1ff20.tar.gz chromium_src-99fd10c7cd3f68cd0346a98cf536fc6546e1ff20.tar.bz2 |
1) added "idle" and "locked" transitions to idle.onStateChanged
2) Per-app/extension idle threshold, settable via idle.setDetectionInterval
3) Bug fixes
BUG=143275
Review URL: https://chromiumcodereview.appspot.com/10985056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/idle_win.cc')
-rw-r--r-- | chrome/browser/idle_win.cc | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/chrome/browser/idle_win.cc b/chrome/browser/idle_win.cc index 784bee7..3c6c7d5 100644 --- a/chrome/browser/idle_win.cc +++ b/chrome/browser/idle_win.cc @@ -7,15 +7,9 @@ #include <limits.h> #include <windows.h> -static bool IsScreensaverRunning(); -static bool IsWorkstationLocked(); - -void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { - if (CheckIdleStateIsLocked()) { - notify.Run(IDLE_STATE_LOCKED); - return; - } +namespace { +DWORD CalculateIdleTimeInternal() { LASTINPUTINFO last_input_info = {0}; last_input_info.cbSize = sizeof(LASTINPUTINFO); DWORD current_idle_time = 0; @@ -37,10 +31,7 @@ void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { current_idle_time /= 1000; } - if (current_idle_time >= idle_threshold) - notify.Run(IDLE_STATE_IDLE); - else - notify.Run(IDLE_STATE_ACTIVE); + return current_idle_time; } bool IsScreensaverRunning() { @@ -68,6 +59,12 @@ bool IsWorkstationLocked() { return is_locked; } +} // namespace + +void CalculateIdleTime(IdleTimeCallback notify) { + notify.Run(static_cast<int>(CalculateIdleTimeInternal())); +} + bool CheckIdleStateIsLocked() { return IsWorkstationLocked() || IsScreensaverRunning(); } |