| 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 <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 return value.find("screensaver") != std::string::npos; | 50 return value.find("screensaver") != std::string::npos; |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool exists_; | 53 bool exists_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(ScreensaverWindowFinder); | 55 DISALLOW_COPY_AND_ASSIGN(ScreensaverWindowFinder); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 bool ScreensaverWindowExists() { | 58 bool ScreensaverWindowExists() { |
| 59 #if defined(USE_AURA) |
| 60 // TOOD(saintlou): |
| 61 return false; |
| 62 #else |
| 59 ScreensaverWindowFinder finder; | 63 ScreensaverWindowFinder finder; |
| 60 gtk_util::EnumerateTopLevelWindows(&finder); | 64 gtk_util::EnumerateTopLevelWindows(&finder); |
| 61 return finder.exists(); | 65 return finder.exists(); |
| 66 #endif |
| 62 } | 67 } |
| 63 | 68 |
| 64 } | 69 } |
| 65 | 70 |
| 66 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { | 71 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { |
| 67 if (CheckIdleStateIsLocked()) { | 72 if (CheckIdleStateIsLocked()) { |
| 68 notify.Run(IDLE_STATE_LOCKED); | 73 notify.Run(IDLE_STATE_LOCKED); |
| 69 return; | 74 return; |
| 70 } | 75 } |
| 71 browser::IdleQueryLinux idle_query; | 76 browser::IdleQueryLinux idle_query; |
| 72 unsigned int idle_time = idle_query.IdleTime(); | 77 unsigned int idle_time = idle_query.IdleTime(); |
| 73 if (idle_time >= idle_threshold) | 78 if (idle_time >= idle_threshold) |
| 74 notify.Run(IDLE_STATE_IDLE); | 79 notify.Run(IDLE_STATE_IDLE); |
| 75 else | 80 else |
| 76 notify.Run(IDLE_STATE_ACTIVE); | 81 notify.Run(IDLE_STATE_ACTIVE); |
| 77 } | 82 } |
| 78 | 83 |
| 79 bool CheckIdleStateIsLocked() { | 84 bool CheckIdleStateIsLocked() { |
| 80 // Usually the screensaver is used to lock the screen, so we do not need to | 85 // Usually the screensaver is used to lock the screen, so we do not need to |
| 81 // check if the workstation is locked. | 86 // check if the workstation is locked. |
| 82 gdk_error_trap_push(); | 87 gdk_error_trap_push(); |
| 83 bool result = ScreensaverWindowExists(); | 88 bool result = ScreensaverWindowExists(); |
| 84 bool got_error = gdk_error_trap_pop(); | 89 bool got_error = gdk_error_trap_pop(); |
| 85 return result && !got_error; | 90 return result && !got_error; |
| 86 } | 91 } |
| OLD | NEW |