diff options
author | courage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-17 03:27:34 +0000 |
---|---|---|
committer | courage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-17 03:27:34 +0000 |
commit | 4c120aff6661abe0ee6e7c79d2aeadebf12837bf (patch) | |
tree | 2187b54667ede7f14c9f488d68039c3efad024d7 /chrome/browser/idle_win.cc | |
parent | d0412114300dd4486f51eb22d728ece2b67d4c77 (diff) | |
download | chromium_src-4c120aff6661abe0ee6e7c79d2aeadebf12837bf.zip chromium_src-4c120aff6661abe0ee6e7c79d2aeadebf12837bf.tar.gz chromium_src-4c120aff6661abe0ee6e7c79d2aeadebf12837bf.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
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=168104
Review URL: https://chromiumcodereview.appspot.com/10985056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168365 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(); } |