Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/idle_linux.cc

Issue 7864022: Fixing the bug, that caused UI to hang after unsupported device was inserted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style fixes Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/idle_chromeos.cc ('k') | chrome/browser/idle_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 bool ScreensaverWindowExists() { 58 bool ScreensaverWindowExists() {
59 ScreensaverWindowFinder finder; 59 ScreensaverWindowFinder finder;
60 gtk_util::EnumerateTopLevelWindows(&finder); 60 gtk_util::EnumerateTopLevelWindows(&finder);
61 return finder.exists(); 61 return finder.exists();
62 } 62 }
63 63
64 } 64 }
65 65
66 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { 66 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
67 // Usually the screensaver is used to lock the screen, so we do not need to 67 if (CheckIdleStateIsLocked()) {
68 // check if the workstation is locked.
69 gdk_error_trap_push();
70 bool result = ScreensaverWindowExists();
71 bool got_error = gdk_error_trap_pop();
72 if (result && !got_error) {
73 notify.Run(IDLE_STATE_LOCKED); 68 notify.Run(IDLE_STATE_LOCKED);
74 return; 69 return;
75 } 70 }
76
77 browser::IdleQueryLinux idle_query; 71 browser::IdleQueryLinux idle_query;
78 unsigned int idle_time = idle_query.IdleTime(); 72 unsigned int idle_time = idle_query.IdleTime();
79 if (idle_time >= idle_threshold) 73 if (idle_time >= idle_threshold)
80 notify.Run(IDLE_STATE_IDLE); 74 notify.Run(IDLE_STATE_IDLE);
81 else 75 else
82 notify.Run(IDLE_STATE_ACTIVE); 76 notify.Run(IDLE_STATE_ACTIVE);
83 } 77 }
78
79 bool CheckIdleStateIsLocked() {
80 // Usually the screensaver is used to lock the screen, so we do not need to
81 // check if the workstation is locked.
82 gdk_error_trap_push();
83 bool result = ScreensaverWindowExists();
84 bool got_error = gdk_error_trap_pop();
85 return result && !got_error;
86 }
OLDNEW
« no previous file with comments | « chrome/browser/idle_chromeos.cc ('k') | chrome/browser/idle_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698