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

Side by Side Diff: remoting/webapp/app_remoting/js/idle_detector.js

Issue 1143453007: remoting.WindowShape clean up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 7 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
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 this.resetTimeoutRef_ = null; 47 this.resetTimeoutRef_ = null;
48 48
49 var manifest = chrome.runtime.getManifest(); 49 var manifest = chrome.runtime.getManifest();
50 var message = this.idleWarning_.querySelector('.idle-warning-message'); 50 var message = this.idleWarning_.querySelector('.idle-warning-message');
51 l10n.localizeElement(message, manifest.name); 51 l10n.localizeElement(message, manifest.name);
52 52
53 var cont = this.idleWarning_.querySelector('.idle-dialog-continue'); 53 var cont = this.idleWarning_.querySelector('.idle-dialog-continue');
54 cont.addEventListener('click', this.onContinue_.bind(this), false); 54 cont.addEventListener('click', this.onContinue_.bind(this), false);
55 var quit = this.idleWarning_.querySelector('.idle-dialog-disconnect'); 55 var quit = this.idleWarning_.querySelector('.idle-dialog-disconnect');
56 quit.addEventListener('click', this.onDisconnect_.bind(this), false); 56 quit.addEventListener('click', this.onDisconnect_.bind(this), false);
57
58 remoting.windowShape.addCallback(this);
59 this.resetTimeout_(); 57 this.resetTimeout_();
60 }; 58 };
61 59
62 /** 60 /**
63 * @param {boolean} register True to register the callbacks; false to remove 61 * @param {boolean} register True to register the callbacks; false to remove
64 * them. 62 * them.
65 * @private 63 * @private
66 */ 64 */
67 remoting.IdleDetector.prototype.registerInputDetectionCallbacks_ = 65 remoting.IdleDetector.prototype.registerInputDetectionCallbacks_ =
68 function(register) { 66 function(register) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 131 }
134 this.onDialogTimeout_(); 132 this.onDialogTimeout_();
135 }; 133 };
136 134
137 /** 135 /**
138 * @param {boolean} show True to show the warning dialog; false to hide it. 136 * @param {boolean} show True to show the warning dialog; false to hide it.
139 * @private 137 * @private
140 */ 138 */
141 remoting.IdleDetector.prototype.showIdleWarning_ = function(show) { 139 remoting.IdleDetector.prototype.showIdleWarning_ = function(show) {
142 this.idleWarning_.hidden = !show; 140 this.idleWarning_.hidden = !show;
143 remoting.windowShape.updateClientWindowShape(); 141 if (show) {
144 } 142 remoting.windowShape.registerClientUI(this);
143 } else {
144 remoting.windowShape.unregisterClientUI(this);
145 }
146 };
145 147
146 /** 148 /**
147 * @param {Array<{left: number, top: number, width: number, height: number}>} 149 * @param {Array<{left: number, top: number, width: number, height: number}>}
148 * rects List of rectangles. 150 * rects List of rectangles.
149 */ 151 */
150 remoting.IdleDetector.prototype.addToRegion = function(rects) { 152 remoting.IdleDetector.prototype.addToRegion = function(rects) {
151 if (!this.idleWarning_.hidden) { 153 if (!this.idleWarning_.hidden) {
152 var dialog = this.idleWarning_.querySelector('.kd-modaldialog'); 154 var dialog = this.idleWarning_.querySelector('.kd-modaldialog');
153 var rect = /** @type {ClientRect} */ (dialog.getBoundingClientRect()); 155 var rect = /** @type {ClientRect} */ (dialog.getBoundingClientRect());
154 rects.push(rect); 156 rects.push(rect);
155 } 157 }
156 }; 158 };
157 159
158 // Time-out after 1hr of no activity. 160 // Time-out after 1hr of no activity.
159 remoting.IdleDetector.kIdleTimeoutMs = 60 * 60 * 1000; 161 remoting.IdleDetector.kIdleTimeoutMs = 60 * 60 * 1000;
160 162
161 // Show the idle warning dialog for 2 minutes. 163 // Show the idle warning dialog for 2 minutes.
162 remoting.IdleDetector.kDialogTimeoutMs = 2 * 60 * 1000; 164 remoting.IdleDetector.kDialogTimeoutMs = 2 * 60 * 1000;
OLDNEW
« no previous file with comments | « remoting/webapp/app_remoting/js/context_menu_dom.js ('k') | remoting/webapp/base/js/connection_stats.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698