| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 {fetchThirdPartyToken: fetchThirdPartyToken}); | 133 {fetchThirdPartyToken: fetchThirdPartyToken}); |
| 134 var that = this; | 134 var that = this; |
| 135 | 135 |
| 136 this.sessionFactory_.createSession(this).then( | 136 this.sessionFactory_.createSession(this).then( |
| 137 function(/** remoting.ClientSession */ session) { | 137 function(/** remoting.ClientSession */ session) { |
| 138 that.session_ = session; | 138 that.session_ = session; |
| 139 session.logHostOfflineErrors(true); | 139 session.logHostOfflineErrors(true); |
| 140 session.connect(host, credentialsProvider); | 140 session.connect(host, credentialsProvider); |
| 141 }); | 141 }); |
| 142 } else if (response && response.status == 'pending') { | 142 } else if (response && response.status == 'pending') { |
| 143 this.onError(new remoting.Error( | 143 this.onConnectionFailed(new remoting.Error( |
| 144 remoting.Error.Tag.SERVICE_UNAVAILABLE)); | 144 remoting.Error.Tag.SERVICE_UNAVAILABLE)); |
| 145 } | 145 } |
| 146 } else { | 146 } else { |
| 147 console.error('Invalid "runApplication" response from server.'); | 147 console.error('Invalid "runApplication" response from server.'); |
| 148 this.onError(remoting.Error.fromHttpStatus(xhrResponse.status)); | 148 this.onConnectionFailed(remoting.Error.fromHttpStatus(xhrResponse.status)); |
| 149 } | 149 } |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * @param {remoting.ConnectionInfo} connectionInfo | 153 * @param {remoting.ConnectionInfo} connectionInfo |
| 154 */ | 154 */ |
| 155 remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { | 155 remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { |
| 156 this.connectedView_ = new remoting.AppConnectedView( | 156 this.connectedView_ = new remoting.AppConnectedView( |
| 157 document.getElementById('client-container'), connectionInfo); | 157 document.getElementById('client-container'), connectionInfo); |
| 158 | 158 |
| 159 var idleDetector = new remoting.IdleDetector( | 159 var idleDetector = new remoting.IdleDetector( |
| 160 document.getElementById('idle-dialog'), this.stop.bind(this)); | 160 document.getElementById('idle-dialog'), this.stop.bind(this)); |
| 161 | 161 |
| 162 // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard | 162 // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard |
| 163 // shortcuts, but we want them to act as natively as possible. | 163 // shortcuts, but we want them to act as natively as possible. |
| 164 if (remoting.platformIsMac()) { | 164 if (remoting.platformIsMac()) { |
| 165 connectionInfo.plugin().setRemapKeys('0x0700e3>0x0700e0,0x0700e7>0x0700e4'); | 165 connectionInfo.plugin().setRemapKeys('0x0700e3>0x0700e0,0x0700e7>0x0700e4'); |
| 166 } | 166 } |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 remoting.AppRemotingActivity.prototype.onDisconnected = function() { | 169 /** |
| 170 * @param {remoting.Error} error |
| 171 */ |
| 172 remoting.AppRemotingActivity.prototype.onDisconnected = function(error) { |
| 173 if (error.isNone()) { |
| 174 chrome.app.window.current().close(); |
| 175 } else { |
| 176 this.showErrorMessage_(error); |
| 177 } |
| 170 this.cleanup_(); | 178 this.cleanup_(); |
| 171 chrome.app.window.current().close(); | |
| 172 }; | 179 }; |
| 173 | 180 |
| 174 /** | 181 /** |
| 175 * @param {!remoting.Error} error | 182 * @param {!remoting.Error} error |
| 176 */ | 183 */ |
| 177 remoting.AppRemotingActivity.prototype.onConnectionFailed = function(error) { | 184 remoting.AppRemotingActivity.prototype.onConnectionFailed = function(error) { |
| 178 this.onError(error); | 185 remoting.LoadingWindow.close(); |
| 186 this.showErrorMessage_(error); |
| 187 this.cleanup_(); |
| 179 }; | 188 }; |
| 180 | 189 |
| 181 /** | 190 /** |
| 182 * @param {!remoting.Error} error The error to be localized and displayed. | 191 * @param {!remoting.Error} error The error to be localized and displayed. |
| 192 * @private |
| 183 */ | 193 */ |
| 184 remoting.AppRemotingActivity.prototype.onError = function(error) { | 194 remoting.AppRemotingActivity.prototype.showErrorMessage_ = function(error) { |
| 185 console.error('Connection failed: ' + error.toString()); | 195 console.error('Connection failed: ' + error.toString()); |
| 186 remoting.LoadingWindow.close(); | |
| 187 remoting.MessageWindow.showErrorMessage( | 196 remoting.MessageWindow.showErrorMessage( |
| 188 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 197 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), |
| 189 chrome.i18n.getMessage(error.getTag())); | 198 chrome.i18n.getMessage(error.getTag())); |
| 190 this.cleanup_(); | |
| 191 }; | 199 }; |
| 192 | 200 |
| 193 })(); | 201 })(); |
| OLD | NEW |