| 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_gtk.h" | 
|  | 13 #endif | 
| 12 | 14 | 
| 13 void CalculateIdleStateNotifier(unsigned int idle_treshold, | 15 void CalculateIdleStateNotifier(unsigned int idle_treshold, | 
| 14                                 IdleCallback notify, | 16                                 IdleCallback notify, | 
| 15                                 int64_t idle_time_s) { | 17                                 int64_t idle_time_s) { | 
| 16   if (idle_time_s >= (int64_t)idle_treshold) { | 18   if (idle_time_s >= (int64_t)idle_treshold) { | 
| 17     notify.Run(IDLE_STATE_IDLE); | 19     notify.Run(IDLE_STATE_IDLE); | 
| 18   } else if (idle_time_s < 0) { | 20   } else if (idle_time_s < 0) { | 
| 19     notify.Run(IDLE_STATE_UNKNOWN); | 21     notify.Run(IDLE_STATE_UNKNOWN); | 
| 20   } else { | 22   } else { | 
| 21     notify.Run(IDLE_STATE_ACTIVE); | 23     notify.Run(IDLE_STATE_ACTIVE); | 
| 22   } | 24   } | 
| 23 } | 25 } | 
| 24 | 26 | 
| 25 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { | 27 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { | 
| 26   if (CheckIdleStateIsLocked()) { | 28   if (CheckIdleStateIsLocked()) { | 
| 27     notify.Run(IDLE_STATE_LOCKED); | 29     notify.Run(IDLE_STATE_LOCKED); | 
| 28     return; | 30     return; | 
| 29   } | 31   } | 
| 30   chromeos::CalculateIdleTimeCallback* callback = | 32   chromeos::CalculateIdleTimeCallback* callback = | 
| 31       new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier, | 33       new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier, | 
| 32                                         idle_threshold, | 34                                         idle_threshold, | 
| 33                                         notify)); | 35                                         notify)); | 
| 34   chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); | 36   chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback); | 
| 35 } | 37 } | 
| 36 | 38 | 
| 37 bool CheckIdleStateIsLocked() { | 39 bool CheckIdleStateIsLocked() { | 
| 38   // Usually the screensaver is used to lock the screen, so we do not need to | 40   // Usually the screensaver is used to lock the screen, so we do not need to | 
| 39   // check if the workstation is locked. | 41   // check if the workstation is locked. | 
|  | 42 #if defined(USE_AURA) | 
|  | 43   return false; | 
|  | 44 #else | 
| 40   return ScreensaverWindowFinder::ScreensaverWindowExists(); | 45   return ScreensaverWindowFinder::ScreensaverWindowExists(); | 
|  | 46 #endif | 
| 41 } | 47 } | 
| OLD | NEW | 
|---|