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 /** | 8 /** |
9 * Type definition for the RunApplicationResponse returned by the API. | 9 * Type definition for the RunApplicationResponse returned by the API. |
10 * @typedef {{ | 10 * @typedef {{ |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 remoting.Application.Mode.APP_REMOTING, host, | 131 remoting.Application.Mode.APP_REMOTING, host, |
132 new remoting.CredentialsProvider( | 132 new remoting.CredentialsProvider( |
133 {fetchThirdPartyToken: fetchThirdPartyToken})); | 133 {fetchThirdPartyToken: fetchThirdPartyToken})); |
134 | 134 |
135 } else if (response && response.status == 'pending') { | 135 } else if (response && response.status == 'pending') { |
136 this.onError(new remoting.Error( | 136 this.onError(new remoting.Error( |
137 remoting.Error.Tag.SERVICE_UNAVAILABLE)); | 137 remoting.Error.Tag.SERVICE_UNAVAILABLE)); |
138 } | 138 } |
139 } else { | 139 } else { |
140 console.error('Invalid "runApplication" response from server.'); | 140 console.error('Invalid "runApplication" response from server.'); |
141 this.onError(remoting.Error.fromHttpStatus(xhrResponse.status)); | 141 // The orchestrator returns 403 if the user is not whitelisted to run the |
142 // app, which gets translated to a generic error message, so pick something | |
143 // a bit more user-friendly. | |
144 var error = xhrResponse.status == 403 ? | |
145 new remoting.Error(remoting.Error.Tag.APP_NOT_AUTHORIZED) : | |
146 remoting.Error.fromHttpStatus(xhrResponse.status); | |
147 this.onError(error); | |
kelvinp
2015/04/24 22:14:37
need to merge with ToT to call onConnectionFailed(
| |
142 } | 148 } |
143 }; | 149 }; |
144 | 150 |
145 /** | 151 /** |
146 * @param {remoting.ConnectionInfo} connectionInfo | 152 * @param {remoting.ConnectionInfo} connectionInfo |
147 */ | 153 */ |
148 remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { | 154 remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { |
149 this.connectedView_ = new remoting.AppConnectedView( | 155 this.connectedView_ = new remoting.AppConnectedView( |
150 document.getElementById('client-container'), connectionInfo); | 156 document.getElementById('client-container'), connectionInfo); |
151 | 157 |
(...skipping 20 matching lines...) Expand all Loading... | |
172 this.onError(error); | 178 this.onError(error); |
173 }; | 179 }; |
174 | 180 |
175 /** | 181 /** |
176 * @param {!remoting.Error} error The error to be localized and displayed. | 182 * @param {!remoting.Error} error The error to be localized and displayed. |
177 */ | 183 */ |
178 remoting.AppRemotingActivity.prototype.onError = function(error) { | 184 remoting.AppRemotingActivity.prototype.onError = function(error) { |
179 console.error('Connection failed: ' + error.toString()); | 185 console.error('Connection failed: ' + error.toString()); |
180 remoting.LoadingWindow.close(); | 186 remoting.LoadingWindow.close(); |
181 remoting.MessageWindow.showErrorMessage( | 187 remoting.MessageWindow.showErrorMessage( |
182 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 188 remoting.app.getApplicationName(), |
Jamie
2015/04/24 22:04:52
See point (b), above.
| |
183 chrome.i18n.getMessage(error.getTag())); | 189 chrome.i18n.getMessage(error.getTag())); |
184 this.cleanup_(); | 190 this.cleanup_(); |
185 }; | 191 }; |
186 | 192 |
187 })(); | 193 })(); |
OLD | NEW |