OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** | 10 /** |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 return; // Otherwise the "submit" action can't be triggered by Enter. | 129 return; // Otherwise the "submit" action can't be triggered by Enter. |
130 } | 130 } |
131 if ((event.which >= 48) && (event.which <= 57)) { | 131 if ((event.which >= 48) && (event.which <= 57)) { |
132 return; | 132 return; |
133 } | 133 } |
134 event.preventDefault(); | 134 event.preventDefault(); |
135 }; | 135 }; |
136 this.pinEntry_.addEventListener('keypress', onDaemonPinEntryKeyPress, false); | 136 this.pinEntry_.addEventListener('keypress', onDaemonPinEntryKeyPress, false); |
137 this.pinEntry_.addEventListener('keypress', noDigitsInPin, false); | 137 this.pinEntry_.addEventListener('keypress', noDigitsInPin, false); |
138 this.pinConfirm_.addEventListener('keypress', noDigitsInPin, false); | 138 this.pinConfirm_.addEventListener('keypress', noDigitsInPin, false); |
139 | |
140 this.usageStats_ = document.getElementById('usagestats-consent'); | |
141 this.usageStatsCheckbox_ = | |
142 document.getElementById('usagestats-consent-checkbox'); | |
139 }; | 143 }; |
140 | 144 |
141 /** | 145 /** |
142 * Show the dialog in order to get a PIN prior to starting the daemon. When the | 146 * Show the dialog in order to get a PIN prior to starting the daemon. When the |
143 * user clicks OK, the dialog shows a spinner until the daemon has started. | 147 * user clicks OK, the dialog shows a spinner until the daemon has started. |
144 * | 148 * |
145 * @return {void} Nothing. | 149 * @return {void} Nothing. |
146 */ | 150 */ |
147 remoting.HostSetupDialog.prototype.showForStart = function() { | 151 remoting.HostSetupDialog.prototype.showForStart = function() { |
152 /** @type {remoting.HostSetupDialog} */ | |
153 var that = this; | |
154 | |
155 /** | |
156 * @param {boolean} supported True if crash dumps reporting is supported by | |
Jamie
2012/06/21 18:47:52
Nit: s/dumps/dump/ here and elsewhere.
alexeypa (please no reviews)
2012/06/21 23:30:26
Done.
| |
157 * the host. | |
158 * @param {boolean} allowed True if crash dumps reporting is allowed. | |
159 * @param {boolean} set_by_policy True if crash dump reporting is controlled | |
160 * by policy. | |
161 */ | |
162 var onGetConsent = function(supported, allowed, set_by_policy) { | |
163 that.usageStats_.hidden = !supported; | |
164 that.usageStatsCheckbox_.checked = allowed; | |
165 that.usageStatsCheckbox_.disabled = set_by_policy; | |
166 }; | |
167 this.usageStats_.hidden = true; | |
Jamie
2012/06/21 18:47:52
Optional: I'm not sure hiding it and having it app
alexeypa (please no reviews)
2012/06/21 23:30:26
Done.
| |
168 this.hostController_.getConsent(onGetConsent); | |
169 | |
148 var flow = [ | 170 var flow = [ |
149 remoting.HostSetupFlow.State.ASK_PIN, | 171 remoting.HostSetupFlow.State.ASK_PIN, |
150 remoting.HostSetupFlow.State.STARTING_HOST, | 172 remoting.HostSetupFlow.State.STARTING_HOST, |
151 remoting.HostSetupFlow.State.HOST_STARTED]; | 173 remoting.HostSetupFlow.State.HOST_STARTED]; |
152 | 174 |
153 if (navigator.platform.indexOf('Mac') != -1 && | 175 if (navigator.platform.indexOf('Mac') != -1 && |
154 this.hostController_.state() == | 176 this.hostController_.state() == |
155 remoting.HostController.State.NOT_INSTALLED) { | 177 remoting.HostController.State.NOT_INSTALLED) { |
156 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); | 178 flow.unshift(remoting.HostSetupFlow.State.INSTALL_HOST); |
157 } | 179 } |
158 | 180 |
159 this.startNewFlow_(flow); | 181 this.startNewFlow_(flow); |
160 }; | 182 }; |
161 | 183 |
162 /** | 184 /** |
163 * Show the dialog in order to change the PIN associated with a running daemon. | 185 * Show the dialog in order to change the PIN associated with a running daemon. |
164 * | 186 * |
165 * @return {void} Nothing. | 187 * @return {void} Nothing. |
166 */ | 188 */ |
167 remoting.HostSetupDialog.prototype.showForPin = function() { | 189 remoting.HostSetupDialog.prototype.showForPin = function() { |
190 this.usageStats_.hidden = true; | |
168 this.startNewFlow_( | 191 this.startNewFlow_( |
169 [remoting.HostSetupFlow.State.ASK_PIN, | 192 [remoting.HostSetupFlow.State.ASK_PIN, |
170 remoting.HostSetupFlow.State.UPDATING_PIN, | 193 remoting.HostSetupFlow.State.UPDATING_PIN, |
171 remoting.HostSetupFlow.State.UPDATED_PIN]); | 194 remoting.HostSetupFlow.State.UPDATED_PIN]); |
172 }; | 195 }; |
173 | 196 |
174 /** | 197 /** |
175 * Show the dialog in order to stop the daemon. | 198 * Show the dialog in order to stop the daemon. |
176 * | 199 * |
177 * @return {void} Nothing. | 200 * @return {void} Nothing. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 function onHostStarted(result) { | 312 function onHostStarted(result) { |
290 if (flow !== that.flow_ || | 313 if (flow !== that.flow_ || |
291 flow.getState() != remoting.HostSetupFlow.State.STARTING_HOST) { | 314 flow.getState() != remoting.HostSetupFlow.State.STARTING_HOST) { |
292 console.error('Host setup was interrupted when starting the host'); | 315 console.error('Host setup was interrupted when starting the host'); |
293 return; | 316 return; |
294 } | 317 } |
295 | 318 |
296 flow.switchToNextStep(result); | 319 flow.switchToNextStep(result); |
297 that.updateState_(); | 320 that.updateState_(); |
298 } | 321 } |
299 this.hostController_.start(this.flow_.pin, onHostStarted); | 322 this.hostController_.start(this.flow_.pin, this.flow_.consent, onHostStarted); |
300 }; | 323 }; |
301 | 324 |
302 remoting.HostSetupDialog.prototype.updatePin_ = function() { | 325 remoting.HostSetupDialog.prototype.updatePin_ = function() { |
303 /** @type {remoting.HostSetupDialog} */ | 326 /** @type {remoting.HostSetupDialog} */ |
304 var that = this; | 327 var that = this; |
305 /** @type {remoting.HostSetupFlow} */ | 328 /** @type {remoting.HostSetupFlow} */ |
306 var flow = this.flow_; | 329 var flow = this.flow_; |
307 | 330 |
308 /** @param {remoting.HostController.AsyncResult} result */ | 331 /** @param {remoting.HostController.AsyncResult} result */ |
309 function onPinUpdated(result) { | 332 function onPinUpdated(result) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 } | 383 } |
361 if (!remoting.HostSetupDialog.validPin_(pin1)) { | 384 if (!remoting.HostSetupDialog.validPin_(pin1)) { |
362 l10n.localizeElementFromTag( | 385 l10n.localizeElementFromTag( |
363 this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN'); | 386 this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN'); |
364 this.pinErrorDiv_.hidden = false; | 387 this.pinErrorDiv_.hidden = false; |
365 this.prepareForPinEntry_(); | 388 this.prepareForPinEntry_(); |
366 return; | 389 return; |
367 } | 390 } |
368 this.pinErrorDiv_.hidden = true; | 391 this.pinErrorDiv_.hidden = true; |
369 this.flow_.pin = pin1; | 392 this.flow_.pin = pin1; |
393 /** @type {boolean} */ | |
394 var consent = !this.usageStats_.hidden && this.usageStatsCheckbox_.checked; | |
395 this.flow_.consent = consent; | |
370 this.flow_.switchToNextStep(remoting.HostController.AsyncResult.OK); | 396 this.flow_.switchToNextStep(remoting.HostController.AsyncResult.OK); |
371 this.updateState_(); | 397 this.updateState_(); |
372 }; | 398 }; |
373 | 399 |
374 /** @private */ | 400 /** @private */ |
375 remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() { | 401 remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() { |
376 this.pinEntry_.value = ''; | 402 this.pinEntry_.value = ''; |
377 this.pinConfirm_.value = ''; | 403 this.pinConfirm_.value = ''; |
378 this.pinEntry_.focus(); | 404 this.pinEntry_.focus(); |
379 }; | 405 }; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 | 439 |
414 /** | 440 /** |
415 * @return {void} Nothing. | 441 * @return {void} Nothing. |
416 */ | 442 */ |
417 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { | 443 remoting.HostSetupDialog.prototype.onInstallDialogRetry = function() { |
418 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); | 444 remoting.setMode(remoting.AppMode.HOST_SETUP_INSTALL); |
419 } | 445 } |
420 | 446 |
421 /** @type {remoting.HostSetupDialog} */ | 447 /** @type {remoting.HostSetupDialog} */ |
422 remoting.hostSetupDialog = null; | 448 remoting.hostSetupDialog = null; |
OLD | NEW |