| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @suppress {duplicate} */ | 5 /** @suppress {duplicate} */ |
| 6 var remoting = remoting || {}; | 6 var remoting = remoting || {}; |
| 7 | 7 |
| 8 (function() { | 8 (function() { |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * @param {!remoting.ConnectionInfo} connectionInfo | 77 * @param {!remoting.ConnectionInfo} connectionInfo |
| 78 */ | 78 */ |
| 79 remoting.It2MeActivity.prototype.onConnected = function(connectionInfo) { | 79 remoting.It2MeActivity.prototype.onConnected = function(connectionInfo) { |
| 80 this.accessCodeDialog_.inputField().value = ''; | 80 this.accessCodeDialog_.inputField().value = ''; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 remoting.It2MeActivity.prototype.onDisconnected = function() { | 83 remoting.It2MeActivity.prototype.onDisconnected = function() { |
| 84 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | 84 this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @param {!remoting.Error} error | 88 * @param {!remoting.Error} error |
| 89 */ | 89 */ |
| 90 remoting.It2MeActivity.prototype.onError = function(error) { | 90 remoting.It2MeActivity.prototype.onError = function(error) { |
| 91 var errorDiv = document.getElementById('connect-error-message'); | 91 var errorDiv = document.getElementById('connect-error-message'); |
| 92 l10n.localizeElementFromTag(errorDiv, error.getTag()); | 92 l10n.localizeElementFromTag(errorDiv, error.getTag()); |
| 93 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); | 93 this.showFinishDialog_(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 /** |
| 97 * @param {remoting.AppMode} mode |
| 98 * @private |
| 99 */ |
| 100 remoting.It2MeActivity.prototype.showFinishDialog_ = function(mode) { |
| 101 var finishDialog = new remoting.MessageDialog( |
| 102 mode, |
| 103 document.getElementById('client-finished-it2me-button')); |
| 104 finishDialog.show().then(function() { |
| 105 remoting.setMode(remoting.AppMode.HOME); |
| 106 }); |
| 107 }; |
| 96 | 108 |
| 97 /** | 109 /** |
| 98 * @param {string} accessCode | 110 * @param {string} accessCode |
| 99 * @return {Promise} Promise that resolves if the access code is valid. | 111 * @return {Promise} Promise that resolves if the access code is valid. |
| 100 * @private | 112 * @private |
| 101 */ | 113 */ |
| 102 remoting.It2MeActivity.prototype.verifyAccessCode_ = function(accessCode) { | 114 remoting.It2MeActivity.prototype.verifyAccessCode_ = function(accessCode) { |
| 103 var normalizedAccessCode = accessCode.replace(/\s/g, ''); | 115 var normalizedAccessCode = accessCode.replace(/\s/g, ''); |
| 104 if (normalizedAccessCode.length !== ACCESS_CODE_LENGTH) { | 116 if (normalizedAccessCode.length !== ACCESS_CODE_LENGTH) { |
| 105 return Promise.reject(new remoting.Error( | 117 return Promise.reject(new remoting.Error( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 switch (error) { | 179 switch (error) { |
| 168 case 0: return new remoting.Error(remoting.Error.Tag.NETWORK_FAILURE); | 180 case 0: return new remoting.Error(remoting.Error.Tag.NETWORK_FAILURE); |
| 169 case 404: return new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE); | 181 case 404: return new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE); |
| 170 case 502: // No break | 182 case 502: // No break |
| 171 case 503: return new remoting.Error(remoting.Error.Tag.SERVICE_UNAVAILABLE); | 183 case 503: return new remoting.Error(remoting.Error.Tag.SERVICE_UNAVAILABLE); |
| 172 default: return remoting.Error.unexpected(); | 184 default: return remoting.Error.unexpected(); |
| 173 } | 185 } |
| 174 } | 186 } |
| 175 | 187 |
| 176 })(); | 188 })(); |
| OLD | NEW |