| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Class for detecting when the application is idle. Note that chrome.idle is | 7 * Class for detecting when the application is idle. Note that chrome.idle is |
| 8 * not suitable for this purpose because it detects when the computer is idle, | 8 * not suitable for this purpose because it detects when the computer is idle, |
| 9 * and we'd like to close the application and free up VM resources even if the | 9 * and we'd like to close the application and free up VM resources even if the |
| 10 * user has been using another application for a long time. | 10 * user has been using another application for a long time. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 * @implements {remoting.WindowShape.ClientUI} | 31 * @implements {remoting.WindowShape.ClientUI} |
| 32 */ | 32 */ |
| 33 remoting.IdleDetector = function(idleWarning, callback) { | 33 remoting.IdleDetector = function(idleWarning, callback) { |
| 34 /** @private */ | 34 /** @private */ |
| 35 this.idleWarning_ = idleWarning; | 35 this.idleWarning_ = idleWarning; |
| 36 | 36 |
| 37 /** @private */ | 37 /** @private */ |
| 38 this.callback_ = callback; | 38 this.callback_ = callback; |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * @type {number?} The id of the running timer, or null if no timer is | 41 * @private {number?} The id of the running timer, or null if no timer is |
| 42 * running. | 42 * running. |
| 43 * @private | |
| 44 */ | 43 */ |
| 45 this.timerId_ = null; | 44 this.timerId_ = null; |
| 46 | 45 |
| 47 /** | 46 /** @private {?function():void} */ |
| 48 * @type {?function():void} | |
| 49 * @private | |
| 50 */ | |
| 51 this.resetTimeoutRef_ = null; | 47 this.resetTimeoutRef_ = null; |
| 52 | 48 |
| 53 var manifest = chrome.runtime.getManifest(); | 49 var manifest = chrome.runtime.getManifest(); |
| 54 var message = this.idleWarning_.querySelector('.idle-warning-message'); | 50 var message = this.idleWarning_.querySelector('.idle-warning-message'); |
| 55 l10n.localizeElement(message, manifest.name); | 51 l10n.localizeElement(message, manifest.name); |
| 56 | 52 |
| 57 var cont = this.idleWarning_.querySelector('.idle-dialog-continue'); | 53 var cont = this.idleWarning_.querySelector('.idle-dialog-continue'); |
| 58 cont.addEventListener('click', this.onContinue_.bind(this), false); | 54 cont.addEventListener('click', this.onContinue_.bind(this), false); |
| 59 var quit = this.idleWarning_.querySelector('.idle-dialog-disconnect'); | 55 var quit = this.idleWarning_.querySelector('.idle-dialog-disconnect'); |
| 60 quit.addEventListener('click', this.onDisconnect_.bind(this), false); | 56 quit.addEventListener('click', this.onDisconnect_.bind(this), false); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 var rect = /** @type {ClientRect} */ (dialog.getBoundingClientRect()); | 153 var rect = /** @type {ClientRect} */ (dialog.getBoundingClientRect()); |
| 158 rects.push(rect); | 154 rects.push(rect); |
| 159 } | 155 } |
| 160 }; | 156 }; |
| 161 | 157 |
| 162 // Time-out after 1hr of no activity. | 158 // Time-out after 1hr of no activity. |
| 163 remoting.IdleDetector.kIdleTimeoutMs = 60 * 60 * 1000; | 159 remoting.IdleDetector.kIdleTimeoutMs = 60 * 60 * 1000; |
| 164 | 160 |
| 165 // Show the idle warning dialog for 2 minutes. | 161 // Show the idle warning dialog for 2 minutes. |
| 166 remoting.IdleDetector.kDialogTimeoutMs = 2 * 60 * 1000; | 162 remoting.IdleDetector.kDialogTimeoutMs = 2 * 60 * 1000; |
| OLD | NEW |