| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/idle.h" | 5 #include "chrome/browser/idle.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/cros/power_library.h" | 10 #include "chrome/browser/chromeos/cros/power_library.h" |
| 11 #include "chrome/browser/screensaver_window_finder_linux.h" | 11 #if defined(USE_AURA) |
| 12 #include "chrome/browser/screensaver_window_finder_aura.h" |
| 13 #else |
| 14 #include "chrome/browser/screensaver_window_finder_gtk.h" |
| 15 #endif |
| 12 | 16 |
| 13 void CalculateIdleStateNotifier(unsigned int idle_treshold, | 17 void CalculateIdleStateNotifier(unsigned int idle_treshold, |
| 14 IdleCallback notify, | 18 IdleCallback notify, |
| 15 int64_t idle_time_s) { | 19 int64_t idle_time_s) { |
| 16 if (idle_time_s >= (int64_t)idle_treshold) { | 20 if (idle_time_s >= (int64_t)idle_treshold) { |
| 17 notify.Run(IDLE_STATE_IDLE); | 21 notify.Run(IDLE_STATE_IDLE); |
| 18 } else if (idle_time_s < 0) { | 22 } else if (idle_time_s < 0) { |
| 19 notify.Run(IDLE_STATE_UNKNOWN); | 23 notify.Run(IDLE_STATE_UNKNOWN); |
| 20 } else { | 24 } else { |
| 21 notify.Run(IDLE_STATE_ACTIVE); | 25 notify.Run(IDLE_STATE_ACTIVE); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 idle_threshold, | 36 idle_threshold, |
| 33 notify)); | 37 notify)); |
| 34 chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); | 38 chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); |
| 35 } | 39 } |
| 36 | 40 |
| 37 bool CheckIdleStateIsLocked() { | 41 bool CheckIdleStateIsLocked() { |
| 38 // Usually the screensaver is used to lock the screen, so we do not need to | 42 // Usually the screensaver is used to lock the screen, so we do not need to |
| 39 // check if the workstation is locked. | 43 // check if the workstation is locked. |
| 40 return ScreensaverWindowFinder::ScreensaverWindowExists(); | 44 return ScreensaverWindowFinder::ScreensaverWindowExists(); |
| 41 } | 45 } |
| OLD | NEW |