summaryrefslogtreecommitdiffstats
path: root/chrome/browser/idle_win.cc
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 02:40:09 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 02:40:09 +0000
commit6405a9a2c316766d3fbda622fbf8bfe33e402c28 (patch)
treef5282e1e7e1e2cac053f9f4f4dc6d2436900e5a4 /chrome/browser/idle_win.cc
parentb6b9b4ec85ba5dee24bf190adec3338a67f54e0e (diff)
downloadchromium_src-6405a9a2c316766d3fbda622fbf8bfe33e402c28.zip
chromium_src-6405a9a2c316766d3fbda622fbf8bfe33e402c28.tar.gz
chromium_src-6405a9a2c316766d3fbda622fbf8bfe33e402c28.tar.bz2
Revert 168104 because it broke interactive_ui_tests and browser_tests on debug builds.
=== 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 TBR=courage@chromium.org Review URL: https://codereview.chromium.org/11418024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/idle_win.cc')
-rw-r--r--chrome/browser/idle_win.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/chrome/browser/idle_win.cc b/chrome/browser/idle_win.cc
index 3c6c7d5..784bee7 100644
--- a/chrome/browser/idle_win.cc
+++ b/chrome/browser/idle_win.cc
@@ -7,9 +7,15 @@
#include <limits.h>
#include <windows.h>
-namespace {
+static bool IsScreensaverRunning();
+static bool IsWorkstationLocked();
+
+void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
+ if (CheckIdleStateIsLocked()) {
+ notify.Run(IDLE_STATE_LOCKED);
+ return;
+ }
-DWORD CalculateIdleTimeInternal() {
LASTINPUTINFO last_input_info = {0};
last_input_info.cbSize = sizeof(LASTINPUTINFO);
DWORD current_idle_time = 0;
@@ -31,7 +37,10 @@ DWORD CalculateIdleTimeInternal() {
current_idle_time /= 1000;
}
- return current_idle_time;
+ if (current_idle_time >= idle_threshold)
+ notify.Run(IDLE_STATE_IDLE);
+ else
+ notify.Run(IDLE_STATE_ACTIVE);
}
bool IsScreensaverRunning() {
@@ -59,12 +68,6 @@ bool IsWorkstationLocked() {
return is_locked;
}
-} // namespace
-
-void CalculateIdleTime(IdleTimeCallback notify) {
- notify.Run(static_cast<int>(CalculateIdleTimeInternal()));
-}
-
bool CheckIdleStateIsLocked() {
return IsWorkstationLocked() || IsScreensaverRunning();
}