[email protected] | 64e19925 | 2012-04-06 01:54:36 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 7bf5902 | 2011-09-08 21:24:21 | [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 | |||||
5 | #include "chrome/browser/idle.h" | ||||
6 | |||||
7 | #include "base/bind.h" | ||||
8 | #include "base/callback.h" | ||||
[email protected] | 64e19925 | 2012-04-06 01:54:36 | [diff] [blame] | 9 | #include "chromeos/dbus/dbus_thread_manager.h" |
10 | #include "chromeos/dbus/power_manager_client.h" | ||||
[email protected] | 7bf5902 | 2011-09-08 21:24:21 | [diff] [blame] | 11 | |
12 | void CalculateIdleStateNotifier(unsigned int idle_treshold, | ||||
13 | IdleCallback notify, | ||||
14 | int64_t idle_time_s) { | ||||
15 | if (idle_time_s >= (int64_t)idle_treshold) { | ||||
16 | notify.Run(IDLE_STATE_IDLE); | ||||
17 | } else if (idle_time_s < 0) { | ||||
18 | notify.Run(IDLE_STATE_UNKNOWN); | ||||
19 | } else { | ||||
20 | notify.Run(IDLE_STATE_ACTIVE); | ||||
21 | } | ||||
22 | } | ||||
23 | |||||
24 | void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { | ||||
[email protected] | 360e7a0 | 2011-11-15 22:24:51 | [diff] [blame] | 25 | chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
26 | CalculateIdleTime(base::Bind(&CalculateIdleStateNotifier, idle_threshold, | ||||
27 | notify)); | ||||
[email protected] | 7bf5902 | 2011-09-08 21:24:21 | [diff] [blame] | 28 | } |
[email protected] | 80722b2 | 2011-09-10 07:54:50 | [diff] [blame] | 29 | |
30 | bool CheckIdleStateIsLocked() { | ||||
[email protected] | 0b5758b | 2011-09-16 22:16:44 | [diff] [blame] | 31 | // Usually the screensaver is used to lock the screen, so we do not need to |
32 | // check if the workstation is locked. | ||||
[email protected] | 64e19925 | 2012-04-06 01:54:36 | [diff] [blame] | 33 | // TODO(oshima): Verify if this behavior is correct. |
[email protected] | 042d699 | 2011-09-20 18:09:47 | [diff] [blame] | 34 | return false; |
[email protected] | 80722b2 | 2011-09-10 07:54:50 | [diff] [blame] | 35 | } |