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

Side by Side Diff: remoting/webapp/crd/js/host_setup_dialog.js

Issue 955283002: Converted remoting.Error from an enum to a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Requested changes. Created 5 years, 9 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 (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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 if (this.currentStep_ < this.sequence_.length - 1) { 60 if (this.currentStep_ < this.sequence_.length - 1) {
61 this.currentStep_ += 1; 61 this.currentStep_ += 1;
62 this.state_ = this.sequence_[this.currentStep_]; 62 this.state_ = this.sequence_[this.currentStep_];
63 } else { 63 } else {
64 this.state_ = remoting.HostSetupFlow.State.NONE; 64 this.state_ = remoting.HostSetupFlow.State.NONE;
65 } 65 }
66 }; 66 };
67 67
68 /** 68 /**
69 * @param {remoting.Error} error 69 * @param {!remoting.Error} error
70 */ 70 */
71 remoting.HostSetupFlow.prototype.switchToErrorState = function(error) { 71 remoting.HostSetupFlow.prototype.switchToErrorState = function(error) {
72 if (error == remoting.Error.CANCELLED) { 72 if (error.tag == remoting.Error.Tag.CANCELLED) {
73 // Stop the setup flow if user rejected one of the actions. 73 // Stop the setup flow if user rejected one of the actions.
74 this.state_ = remoting.HostSetupFlow.State.NONE; 74 this.state_ = remoting.HostSetupFlow.State.NONE;
75 } else { 75 } else {
76 // Current step failed, so switch to corresponding error state. 76 // Current step failed, so switch to corresponding error state.
77 if (this.state_ == remoting.HostSetupFlow.State.STARTING_HOST) { 77 if (this.state_ == remoting.HostSetupFlow.State.STARTING_HOST) {
78 if (error == remoting.Error.REGISTRATION_FAILED) { 78 if (error.tag == remoting.Error.Tag.REGISTRATION_FAILED) {
79 this.state_ = remoting.HostSetupFlow.State.REGISTRATION_FAILED; 79 this.state_ = remoting.HostSetupFlow.State.REGISTRATION_FAILED;
80 } else { 80 } else {
81 this.state_ = remoting.HostSetupFlow.State.START_HOST_FAILED; 81 this.state_ = remoting.HostSetupFlow.State.START_HOST_FAILED;
82 } 82 }
83 } else if (this.state_ == remoting.HostSetupFlow.State.UPDATING_PIN) { 83 } else if (this.state_ == remoting.HostSetupFlow.State.UPDATING_PIN) {
84 this.state_ = remoting.HostSetupFlow.State.UPDATE_PIN_FAILED; 84 this.state_ = remoting.HostSetupFlow.State.UPDATE_PIN_FAILED;
85 } else if (this.state_ == remoting.HostSetupFlow.State.STOPPING_HOST) { 85 } else if (this.state_ == remoting.HostSetupFlow.State.STOPPING_HOST) {
86 this.state_ = remoting.HostSetupFlow.State.STOP_HOST_FAILED; 86 this.state_ = remoting.HostSetupFlow.State.STOP_HOST_FAILED;
87 } else { 87 } else {
88 // TODO(sergeyu): Add other error states and use them here. 88 // TODO(sergeyu): Add other error states and use them here.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 checkBoxLabel.classList.toggle('disabled', set_by_policy); 200 checkBoxLabel.classList.toggle('disabled', set_by_policy);
201 201
202 if (set_by_policy) { 202 if (set_by_policy) {
203 that.usageStats_.title = l10n.getTranslationOrError( 203 that.usageStats_.title = l10n.getTranslationOrError(
204 /*i18n-content*/ 'SETTING_MANAGED_BY_POLICY'); 204 /*i18n-content*/ 'SETTING_MANAGED_BY_POLICY');
205 } else { 205 } else {
206 that.usageStats_.title = ''; 206 that.usageStats_.title = '';
207 } 207 }
208 } 208 }
209 209
210 /** @param {remoting.Error} error */ 210 /** @param {!remoting.Error} error */
211 function onError(error) { 211 function onError(error) {
212 console.error('Error getting consent status: ' + error); 212 console.error('Error getting consent status: ' + error);
213 } 213 }
214 214
215 this.usageStats_.hidden = true; 215 this.usageStats_.hidden = true;
216 this.usageStatsCheckbox_.checked = false; 216 this.usageStatsCheckbox_.checked = false;
217 217
218 // Prevent user from ticking the box until the current consent status is 218 // Prevent user from ticking the box until the current consent status is
219 // known. 219 // known.
220 this.usageStatsCheckbox_.disabled = true; 220 this.usageStatsCheckbox_.disabled = true;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 /** 353 /**
354 * Shows the prompt that asks the user to install the host. 354 * Shows the prompt that asks the user to install the host.
355 */ 355 */
356 remoting.HostSetupDialog.prototype.installHost_ = function() { 356 remoting.HostSetupDialog.prototype.installHost_ = function() {
357 /** @type {remoting.HostSetupDialog} */ 357 /** @type {remoting.HostSetupDialog} */
358 var that = this; 358 var that = this;
359 /** @type {remoting.HostSetupFlow} */ 359 /** @type {remoting.HostSetupFlow} */
360 var flow = this.flow_; 360 var flow = this.flow_;
361 361
362 /** @param {remoting.Error} error */ 362 /** @param {!remoting.Error} error */
363 var onError = function(error) { 363 var onError = function(error) {
364 flow.switchToErrorState(error); 364 flow.switchToErrorState(error);
365 that.updateState_(); 365 that.updateState_();
366 }; 366 };
367 367
368 var onDone = function() { 368 var onDone = function() {
369 that.hostController_.getLocalHostState(onHostState); 369 that.hostController_.getLocalHostState(onHostState);
370 }; 370 };
371 371
372 /** @param {remoting.HostController.State} state */ 372 /** @param {remoting.HostController.State} state */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 return true; 408 return true;
409 } 409 }
410 410
411 function onHostStarted() { 411 function onHostStarted() {
412 if (isFlowActive()) { 412 if (isFlowActive()) {
413 flow.switchToNextStep(); 413 flow.switchToNextStep();
414 that.updateState_(); 414 that.updateState_();
415 } 415 }
416 } 416 }
417 417
418 /** @param {remoting.Error} error */ 418 /** @param {!remoting.Error} error */
419 function onError(error) { 419 function onError(error) {
420 if (isFlowActive()) { 420 if (isFlowActive()) {
421 flow.switchToErrorState(error); 421 flow.switchToErrorState(error);
422 that.updateState_(); 422 that.updateState_();
423 } 423 }
424 } 424 }
425 425
426 this.hostController_.start(this.flow_.pin, this.flow_.consent, onHostStarted, 426 this.hostController_.start(this.flow_.pin, this.flow_.consent, onHostStarted,
427 onError); 427 onError);
428 }; 428 };
(...skipping 14 matching lines...) Expand all
443 return true; 443 return true;
444 } 444 }
445 445
446 function onPinUpdated() { 446 function onPinUpdated() {
447 if (isFlowActive()) { 447 if (isFlowActive()) {
448 flow.switchToNextStep(); 448 flow.switchToNextStep();
449 that.updateState_(); 449 that.updateState_();
450 } 450 }
451 } 451 }
452 452
453 /** @param {remoting.Error} error */ 453 /** @param {!remoting.Error} error */
454 function onError(error) { 454 function onError(error) {
455 if (isFlowActive()) { 455 if (isFlowActive()) {
456 flow.switchToErrorState(error); 456 flow.switchToErrorState(error);
457 that.updateState_(); 457 that.updateState_();
458 } 458 }
459 } 459 }
460 460
461 this.hostController_.updatePin(flow.pin, onPinUpdated, onError); 461 this.hostController_.updatePin(flow.pin, onPinUpdated, onError);
462 }; 462 };
463 463
(...skipping 16 matching lines...) Expand all
480 return true; 480 return true;
481 } 481 }
482 482
483 function onHostStopped() { 483 function onHostStopped() {
484 if (isFlowActive()) { 484 if (isFlowActive()) {
485 flow.switchToNextStep(); 485 flow.switchToNextStep();
486 that.updateState_(); 486 that.updateState_();
487 } 487 }
488 } 488 }
489 489
490 /** @param {remoting.Error} error */ 490 /** @param {!remoting.Error} error */
491 function onError(error) { 491 function onError(error) {
492 if (isFlowActive()) { 492 if (isFlowActive()) {
493 flow.switchToErrorState(error); 493 flow.switchToErrorState(error);
494 that.updateState_(); 494 that.updateState_();
495 } 495 }
496 } 496 }
497 497
498 this.hostController_.stop(onHostStopped, onError); 498 this.hostController_.stop(onHostStopped, onError);
499 }; 499 };
500 500
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 var c = pin.charAt(i); 562 var c = pin.charAt(i);
563 if ((c < '0') || (c > '9')) { 563 if ((c < '0') || (c > '9')) {
564 return false; 564 return false;
565 } 565 }
566 } 566 }
567 return true; 567 return true;
568 }; 568 };
569 569
570 /** @type {remoting.HostSetupDialog} */ 570 /** @type {remoting.HostSetupDialog} */
571 remoting.hostSetupDialog = null; 571 remoting.hostSetupDialog = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698