| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 */ | 111 */ |
| 112 this.clientSession_ = null; | 112 this.clientSession_ = null; |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * @type {XMLHttpRequest} | 115 * @type {XMLHttpRequest} |
| 116 * @private | 116 * @private |
| 117 */ | 117 */ |
| 118 this.pendingXhr_ = null; | 118 this.pendingXhr_ = null; |
| 119 | 119 |
| 120 /** | 120 /** |
| 121 * @type {function(function(string):void): void} | 121 * Function to interactively obtain the PIN from the user. |
| 122 * @type {function(boolean, function(string):void):void} |
| 122 * @private | 123 * @private |
| 123 */ | 124 */ |
| 124 this.fetchPin_ = function(onPinFetched) {}; | 125 this.fetchPin_ = function(onPinFetched) {}; |
| 125 | 126 |
| 126 /** | 127 /** |
| 127 * @type {function(string, string, string, | 128 * @type {function(string, string, string, |
| 128 * function(string, string):void): void} | 129 * function(string, string):void): void} |
| 129 * @private | 130 * @private |
| 130 */ | 131 */ |
| 131 this.fetchThirdPartyToken_ = function( | 132 this.fetchThirdPartyToken_ = function( |
| 132 tokenUrl, scope, onThirdPartyTokenFetched) {}; | 133 tokenUrl, scope, onThirdPartyTokenFetched) {}; |
| 133 | 134 |
| 134 /** | 135 /** |
| 135 * Host 'name', as displayed in the client tool-bar. For a Me2Me connection, | 136 * Host 'name', as displayed in the client tool-bar. For a Me2Me connection, |
| 136 * this is the name of the host; for an IT2Me connection, it is the email | 137 * this is the name of the host; for an IT2Me connection, it is the email |
| 137 * address of the person sharing their computer. | 138 * address of the person sharing their computer. |
| 138 * | 139 * |
| 139 * @type {string} | 140 * @type {string} |
| 140 * @private | 141 * @private |
| 141 */ | 142 */ |
| 142 this.hostDisplayName_ = ''; | 143 this.hostDisplayName_ = ''; |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 /** | 146 /** |
| 146 * Initiate a Me2Me connection. | 147 * Initiate a Me2Me connection. |
| 147 * | 148 * |
| 148 * @param {remoting.Host} host The Me2Me host to which to connect. | 149 * @param {remoting.Host} host The Me2Me host to which to connect. |
| 149 * @param {function(function(string):void):void} fetchPin Function to | 150 * @param {function(boolean, function(string):void):void} fetchPin Function to |
| 150 * interactively obtain the PIN from the user. | 151 * interactively obtain the PIN from the user. |
| 151 * @param {function(string, string, string, | 152 * @param {function(string, string, string, |
| 152 * function(string, string): void): void} | 153 * function(string, string): void): void} |
| 153 * fetchThirdPartyToken Function to obtain a token from a third party | 154 * fetchThirdPartyToken Function to obtain a token from a third party |
| 154 * authenticaiton server. | 155 * authenticaiton server. |
| 155 * @return {void} Nothing. | 156 * @return {void} Nothing. |
| 156 */ | 157 */ |
| 157 remoting.SessionConnector.prototype.connectMe2Me = function( | 158 remoting.SessionConnector.prototype.connectMe2Me = function( |
| 158 host, fetchPin, fetchThirdPartyToken) { | 159 host, fetchPin, fetchThirdPartyToken) { |
| 159 // Cancel any existing connect operation. | 160 // Cancel any existing connect operation. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 * If both the client and host JIDs are available, create a session and connect. | 307 * If both the client and host JIDs are available, create a session and connect. |
| 307 * | 308 * |
| 308 * @return {void} Nothing. | 309 * @return {void} Nothing. |
| 309 * @private | 310 * @private |
| 310 */ | 311 */ |
| 311 remoting.SessionConnector.prototype.createSessionIfReady_ = function() { | 312 remoting.SessionConnector.prototype.createSessionIfReady_ = function() { |
| 312 if (!this.clientJid_ || !this.hostJid_) { | 313 if (!this.clientJid_ || !this.hostJid_) { |
| 313 return; | 314 return; |
| 314 } | 315 } |
| 315 | 316 |
| 316 var securityTypes = 'third_party,spake2_hmac,spake2_plain'; | 317 var securityTypes = 'third_party,spake2_pair,spake2_hmac,spake2_plain'; |
| 317 this.clientSession_ = new remoting.ClientSession( | 318 this.clientSession_ = new remoting.ClientSession( |
| 318 this.hostJid_, this.clientJid_, this.hostPublicKey_, this.passPhrase_, | 319 this.hostJid_, this.clientJid_, this.hostPublicKey_, this.passPhrase_, |
| 319 this.fetchPin_, this.fetchThirdPartyToken_, securityTypes, this.hostId_, | 320 this.fetchPin_, this.fetchThirdPartyToken_, securityTypes, this.hostId_, |
| 320 this.connectionMode_, this.hostDisplayName_); | 321 this.connectionMode_, this.hostDisplayName_); |
| 321 this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_); | 322 this.clientSession_.logHostOfflineErrors(!this.refreshHostJidIfOffline_); |
| 322 this.clientSession_.setOnStateChange(this.onStateChange_.bind(this)); | 323 this.clientSession_.setOnStateChange(this.onStateChange_.bind(this)); |
| 323 this.clientSession_.createPluginAndConnect(this.pluginParent_); | 324 this.clientSession_.createPluginAndConnect(this.pluginParent_); |
| 324 }; | 325 }; |
| 325 | 326 |
| 326 /** | 327 /** |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 * Normalize the access code entered by the user. | 465 * Normalize the access code entered by the user. |
| 465 * | 466 * |
| 466 * @param {string} accessCode The access code, as entered by the user. | 467 * @param {string} accessCode The access code, as entered by the user. |
| 467 * @return {string} The normalized form of the code (whitespace removed). | 468 * @return {string} The normalized form of the code (whitespace removed). |
| 468 */ | 469 */ |
| 469 remoting.SessionConnector.prototype.normalizeAccessCode_ = | 470 remoting.SessionConnector.prototype.normalizeAccessCode_ = |
| 470 function(accessCode) { | 471 function(accessCode) { |
| 471 // Trim whitespace. | 472 // Trim whitespace. |
| 472 return accessCode.replace(/\s/g, ''); | 473 return accessCode.replace(/\s/g, ''); |
| 473 }; | 474 }; |
| OLD | NEW |