| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * This class implements the functionality that is specific to application | 7 * This class implements the functionality that is specific to application |
| 8 * remoting ("AppRemoting" or AR). | 8 * remoting ("AppRemoting" or AR). |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return manifest.name; | 204 return manifest.name; |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 /** @return {string} */ | 207 /** @return {string} */ |
| 208 remoting.AppRemoting.prototype.runApplicationUrl = function() { | 208 remoting.AppRemoting.prototype.runApplicationUrl = function() { |
| 209 return remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' + | 209 return remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' + |
| 210 remoting.settings.getAppRemotingApplicationId() + '/run'; | 210 remoting.settings.getAppRemotingApplicationId() + '/run'; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 /** | 213 /** |
| 214 * @return {string} The default remap keys for the current platform. | |
| 215 */ | |
| 216 remoting.AppRemoting.prototype.getDefaultRemapKeys = function() { | |
| 217 // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard | |
| 218 // shortcuts, but we want them to act as natively as possible. | |
| 219 if (remoting.platformIsMac()) { | |
| 220 return '0x0700e3>0x0700e0,0x0700e7>0x0700e4'; | |
| 221 } | |
| 222 return ''; | |
| 223 }; | |
| 224 | |
| 225 /** | |
| 226 * Called when a new session has been connected. | 214 * Called when a new session has been connected. |
| 227 * | 215 * |
| 228 * @param {remoting.ConnectionInfo} connectionInfo | 216 * @param {remoting.ConnectionInfo} connectionInfo |
| 229 * @return {void} Nothing. | 217 * @return {void} Nothing. |
| 230 */ | 218 */ |
| 231 remoting.AppRemoting.prototype.handleConnected = function(connectionInfo) { | 219 remoting.AppRemoting.prototype.handleConnected = function(connectionInfo) { |
| 232 remoting.identity.getUserInfo().then( | 220 remoting.identity.getUserInfo().then( |
| 233 function(userInfo) { | 221 function(userInfo) { |
| 234 remoting.clientSession.sendClientMessage( | 222 remoting.clientSession.sendClientMessage( |
| 235 'setUserDisplayInfo', | 223 'setUserDisplayInfo', |
| 236 JSON.stringify({fullName: userInfo.name})); | 224 JSON.stringify({fullName: userInfo.name})); |
| 237 }); | 225 }); |
| 238 | 226 |
| 239 remoting.app.getSessionConnector().registerProtocolExtension(this); | 227 remoting.app.getSessionConnector().registerProtocolExtension(this); |
| 240 | 228 |
| 241 var clientSession = connectionInfo.session(); | 229 var clientSession = connectionInfo.session(); |
| 242 // Set up a ping at 10-second intervals to test the connection speed. | 230 // Set up a ping at 10-second intervals to test the connection speed. |
| 243 var CONNECTION_SPEED_PING_INTERVAL = 10 * 1000; | 231 var CONNECTION_SPEED_PING_INTERVAL = 10 * 1000; |
| 244 this.pingTimer_ = new base.RepeatingTimer(function () { | 232 this.pingTimer_ = new base.RepeatingTimer(function () { |
| 245 var message = { timestamp: new Date().getTime() }; | 233 var message = { timestamp: new Date().getTime() }; |
| 246 clientSession.sendClientMessage('pingRequest', JSON.stringify(message)); | 234 clientSession.sendClientMessage('pingRequest', JSON.stringify(message)); |
| 247 }, CONNECTION_SPEED_PING_INTERVAL); | 235 }, CONNECTION_SPEED_PING_INTERVAL); |
| 248 | 236 |
| 249 // TODO(kelvinp): Move all app remoting specific logic into | 237 // TODO(kelvinp): Move all app remoting specific logic into |
| 250 // remoting.AppRemotingView. | 238 // remoting.AppRemotingView. |
| 251 this.connectedView_ = new remoting.DesktopConnectedView( | 239 this.connectedView_ = new remoting.DesktopConnectedView( |
| 252 document.getElementById('client-container'), connectionInfo, | 240 document.getElementById('client-container'), connectionInfo); |
| 253 this.getDefaultRemapKeys()); | 241 |
| 242 // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard |
| 243 // shortcuts, but we want them to act as natively as possible. |
| 244 if (remoting.platformIsMac()) { |
| 245 connectionInfo.plugin().setRemapKeys('0x0700e3>0x0700e0,0x0700e7>0x0700e4'); |
| 246 } |
| 254 }; | 247 }; |
| 255 | 248 |
| 256 /** | 249 /** |
| 257 * Called when the current session has been disconnected. | 250 * Called when the current session has been disconnected. |
| 258 * | 251 * |
| 259 * @return {void} Nothing. | 252 * @return {void} Nothing. |
| 260 */ | 253 */ |
| 261 remoting.AppRemoting.prototype.handleDisconnected = function() { | 254 remoting.AppRemoting.prototype.handleDisconnected = function() { |
| 262 // Cancel the ping when the connection closes. | 255 // Cancel the ping when the connection closes. |
| 263 base.dispose(this.pingTimer_); | 256 base.dispose(this.pingTimer_); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 362 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), |
| 370 chrome.i18n.getMessage(error.getTag())); | 363 chrome.i18n.getMessage(error.getTag())); |
| 371 }; | 364 }; |
| 372 | 365 |
| 373 /** | 366 /** |
| 374 * Close the loading window before exiting. | 367 * Close the loading window before exiting. |
| 375 */ | 368 */ |
| 376 remoting.AppRemoting.prototype.handleExit = function() { | 369 remoting.AppRemoting.prototype.handleExit = function() { |
| 377 remoting.LoadingWindow.close(); | 370 remoting.LoadingWindow.close(); |
| 378 }; | 371 }; |
| OLD | NEW |