OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Connect set-up state machine for Me2Me and IT2Me | 7 * Connect set-up state machine for Me2Me and IT2Me |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 remoting.SessionConnector.prototype.connectMe2Me = | 187 remoting.SessionConnector.prototype.connectMe2Me = |
188 function(host, fetchPin, fetchThirdPartyToken, | 188 function(host, fetchPin, fetchThirdPartyToken, |
189 clientPairingId, clientPairedSecret) { | 189 clientPairingId, clientPairedSecret) { |
190 this.connectMe2MeInternal_( | 190 this.connectMe2MeInternal_( |
191 host.hostId, host.jabberId, host.publicKey, host.hostName, | 191 host.hostId, host.jabberId, host.publicKey, host.hostName, |
192 fetchPin, fetchThirdPartyToken, | 192 fetchPin, fetchThirdPartyToken, |
193 clientPairingId, clientPairedSecret, true); | 193 clientPairingId, clientPairedSecret, true); |
194 }; | 194 }; |
195 | 195 |
196 /** | 196 /** |
| 197 * Update the pairing info so that the reconnect function will work correctly. |
| 198 * |
| 199 * @param {string} clientId The paired client id. |
| 200 * @param {string} sharedSecret The shared secret. |
| 201 */ |
| 202 remoting.SessionConnector.prototype.updatePairingInfo = |
| 203 function(clientId, sharedSecret) { |
| 204 this.clientPairingId_ = clientId; |
| 205 this.clientPairedSecret_ = sharedSecret; |
| 206 }; |
| 207 |
| 208 /** |
197 * Initiate a Me2Me connection. | 209 * Initiate a Me2Me connection. |
198 * | 210 * |
199 * @param {string} hostId ID of the Me2Me host. | 211 * @param {string} hostId ID of the Me2Me host. |
200 * @param {string} hostJid XMPP JID of the host. | 212 * @param {string} hostJid XMPP JID of the host. |
201 * @param {string} hostPublicKey Public Key of the host. | 213 * @param {string} hostPublicKey Public Key of the host. |
202 * @param {string} hostDisplayName Display name (friendly name) of the host. | 214 * @param {string} hostDisplayName Display name (friendly name) of the host. |
203 * @param {function(boolean, function(string):void):void} fetchPin Function to | 215 * @param {function(boolean, function(string):void):void} fetchPin Function to |
204 * interactively obtain the PIN from the user. | 216 * interactively obtain the PIN from the user. |
205 * @param {function(string, string, string, | 217 * @param {function(string, string, string, |
206 * function(string, string): void): void} | 218 * function(string, string): void): void} |
(...skipping 10 matching lines...) Expand all Loading... |
217 */ | 229 */ |
218 remoting.SessionConnector.prototype.connectMe2MeInternal_ = | 230 remoting.SessionConnector.prototype.connectMe2MeInternal_ = |
219 function(hostId, hostJid, hostPublicKey, hostDisplayName, | 231 function(hostId, hostJid, hostPublicKey, hostDisplayName, |
220 fetchPin, fetchThirdPartyToken, | 232 fetchPin, fetchThirdPartyToken, |
221 clientPairingId, clientPairedSecret, | 233 clientPairingId, clientPairedSecret, |
222 refreshHostJidIfOffline) { | 234 refreshHostJidIfOffline) { |
223 // Cancel any existing connect operation. | 235 // Cancel any existing connect operation. |
224 this.cancel(); | 236 this.cancel(); |
225 | 237 |
226 this.hostId_ = hostId; | 238 this.hostId_ = hostId; |
227 this.clientPairingId_ = clientPairingId; | |
228 this.clientPairedSecret_ = clientPairedSecret; | |
229 this.hostJid_ = hostJid; | 239 this.hostJid_ = hostJid; |
230 this.hostPublicKey_ = hostPublicKey; | 240 this.hostPublicKey_ = hostPublicKey; |
231 this.fetchPin_ = fetchPin; | 241 this.fetchPin_ = fetchPin; |
232 this.fetchThirdPartyToken_ = fetchThirdPartyToken; | 242 this.fetchThirdPartyToken_ = fetchThirdPartyToken; |
233 this.hostDisplayName_ = hostDisplayName; | 243 this.hostDisplayName_ = hostDisplayName; |
234 this.connectionMode_ = remoting.ClientSession.Mode.ME2ME; | 244 this.connectionMode_ = remoting.ClientSession.Mode.ME2ME; |
235 this.refreshHostJidIfOffline_ = refreshHostJidIfOffline; | 245 this.refreshHostJidIfOffline_ = refreshHostJidIfOffline; |
| 246 this.updatePairingInfo(clientPairingId, clientPairedSecret); |
236 this.createSessionIfReady_(); | 247 this.createSessionIfReady_(); |
237 }; | 248 }; |
238 | 249 |
239 /** | 250 /** |
240 * Initiate an IT2Me connection. | 251 * Initiate an IT2Me connection. |
241 * | 252 * |
242 * @param {string} accessCode The access code as entered by the user. | 253 * @param {string} accessCode The access code as entered by the user. |
243 * @return {void} Nothing. | 254 * @return {void} Nothing. |
244 */ | 255 */ |
245 remoting.SessionConnector.prototype.connectIT2Me = function(accessCode) { | 256 remoting.SessionConnector.prototype.connectIT2Me = function(accessCode) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 * Normalize the access code entered by the user. | 554 * Normalize the access code entered by the user. |
544 * | 555 * |
545 * @param {string} accessCode The access code, as entered by the user. | 556 * @param {string} accessCode The access code, as entered by the user. |
546 * @return {string} The normalized form of the code (whitespace removed). | 557 * @return {string} The normalized form of the code (whitespace removed). |
547 */ | 558 */ |
548 remoting.SessionConnector.prototype.normalizeAccessCode_ = | 559 remoting.SessionConnector.prototype.normalizeAccessCode_ = |
549 function(accessCode) { | 560 function(accessCode) { |
550 // Trim whitespace. | 561 // Trim whitespace. |
551 return accessCode.replace(/\s/g, ''); | 562 return accessCode.replace(/\s/g, ''); |
552 }; | 563 }; |
OLD | NEW |