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

Side by Side Diff: chrome/browser/idle_mac.mm

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: small 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #import "chrome/browser/idle.h" 5 #import "chrome/browser/idle.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #import <CoreGraphics/CGEventSource.h> 8 #import <CoreGraphics/CGEventSource.h>
9 9
10 @interface MacScreenMonitor : NSObject { 10 @interface MacScreenMonitor : NSObject {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (!g_screenMonitor) 78 if (!g_screenMonitor)
79 g_screenMonitor = [[MacScreenMonitor alloc] init]; 79 g_screenMonitor = [[MacScreenMonitor alloc] init];
80 } 80 }
81 81
82 void StopIdleMonitor() { 82 void StopIdleMonitor() {
83 [g_screenMonitor release]; 83 [g_screenMonitor release];
84 g_screenMonitor = nil; 84 g_screenMonitor = nil;
85 } 85 }
86 86
87 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) { 87 void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
88 if ([g_screenMonitor isScreensaverRunning] || 88 if (IsWorkstationInLockedState()) {
89 [g_screenMonitor isScreenLocked]) {
90 notify.Run(IDLE_STATE_LOCKED); 89 notify.Run(IDLE_STATE_LOCKED);
91 return; 90 return;
92 } 91 }
93 92
94 CFTimeInterval idle_time = CGEventSourceSecondsSinceLastEventType( 93 CFTimeInterval idle_time = CGEventSourceSecondsSinceLastEventType(
95 kCGEventSourceStateCombinedSessionState, 94 kCGEventSourceStateCombinedSessionState,
96 kCGAnyInputEventType); 95 kCGAnyInputEventType);
97 if (idle_time >= idle_threshold) 96 if (idle_time >= idle_threshold)
98 notify.Run(IDLE_STATE_IDLE); 97 notify.Run(IDLE_STATE_IDLE);
99 else 98 else
100 notify.Run(IDLE_STATE_ACTIVE); 99 notify.Run(IDLE_STATE_ACTIVE);
101 } 100 }
101
102 bool IsWorkstationInLockedState() {
103 return [g_screenMonitor isScreensaverRunning] ||
104 [g_screenMonitor isScreenLocked];
tonibarzic 2011/09/10 00:37:40 align with [ in the row above
sidor 2011/09/10 02:18:28 Won't fit.
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698