Delete and recreate the client plugin if WCS is reloaded.

Note that I can't reproduce the problem in the linked bug, but based on
your analysis this seems like it should fix it.

BUG=244103

Review URL: https://chromiumcodereview.appspot.com/17449017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207854 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f7da7fc
......@@ -317,7 +317,7 @@ remoting.SessionConnector.prototype.onIT2MeHostInfo_ = function(xhr) {
* @private
*/
remoting.SessionConnector.prototype.loadWcs_ = function(token) {
remoting.wcsSandbox.setOnReady(this.onWcsLoaded_.bind(this));
remoting.wcsSandbox.setOnLocalJid(this.onLocalJid_.bind(this));
remoting.wcsSandbox.setOnError(this.onError_);
remoting.wcsSandbox.setAccessToken(token);
this.startAccessTokenRefreshTimer_();
......@@ -330,7 +330,7 @@ remoting.SessionConnector.prototype.loadWcs_ = function(token) {
* @return {void} Nothing.
* @private
*/
remoting.SessionConnector.prototype.onWcsLoaded_ = function(clientJid) {
remoting.SessionConnector.prototype.onLocalJid_ = function(clientJid) {
this.clientJid_ = clientJid;
this.createSessionIfReady_();
};
......@@ -346,6 +346,14 @@ remoting.SessionConnector.prototype.createSessionIfReady_ = function() {
return;
}
// In some circumstances, the WCS <iframe> can get reloaded, which results
// in a new clientJid and a new callback. In this case, remove the old
// client plugin before instantiating a new one.
if (this.clientSession_) {
this.clientSession_.removePlugin();
this.clientSession_ = null;
}
var securityTypes = 'third_party,spake2_pair,spake2_hmac,spake2_plain';
this.clientSession_ = new remoting.ClientSession(
this.hostJid_, this.clientJid_, this.hostPublicKey_, this.passPhrase_,
......
......@@ -22,7 +22,7 @@ var remoting = remoting || {};
remoting.WcsSandboxContainer = function(sandbox) {
this.sandbox_ = sandbox;
/** @type {?function(string):void} */
this.onReady_ = null;
this.onLocalJid_ = null;
/** @type {?function(remoting.Error):void} */
this.onError_ = null;
/** @type {?function(string):void} */
......@@ -34,12 +34,14 @@ remoting.WcsSandboxContainer = function(sandbox) {
};
/**
* @param {?function(string):void} onReady Callback invoked with the client JID
* when the WCS code has loaded.
* @param {?function(string):void} onLocalJid Callback invoked with the client
* JID when the WCS code has loaded. Note that this may be called more than
* once (potentially with a different JID) if the WCS node is reloaded for
* any reason.
* @return {void} Nothing.
*/
remoting.WcsSandboxContainer.prototype.setOnReady = function(onReady) {
this.onReady_ = onReady;
remoting.WcsSandboxContainer.prototype.setOnLocalJid = function(onLocalJid) {
this.onLocalJid_ = onLocalJid;
};
/**
......@@ -92,15 +94,15 @@ remoting.WcsSandboxContainer.prototype.sendIq = function(stanza) {
remoting.WcsSandboxContainer.prototype.onMessage_ = function(event) {
switch (event.data['command']) {
case 'onReady':
case 'onLocalJid':
/** @type {string} */
var clientJid = event.data['clientJid'];
if (clientJid === undefined) {
console.error('onReady: missing client JID');
break;
}
if (this.onReady_) {
this.onReady_(clientJid);
if (this.onLocalJid_) {
this.onLocalJid_(clientJid);
}
break;
......
......@@ -75,7 +75,7 @@ remoting.WcsSandboxContent.prototype.onMessage_ = function(event) {
} else if (!remoting.wcsLoader) {
remoting.wcsLoader = new remoting.WcsLoader();
remoting.wcsLoader.start(token,
this.onReady_.bind(this),
this.onLocalJid_.bind(this),
this.onError_.bind(this));
}
break;
......@@ -121,10 +121,10 @@ remoting.WcsSandboxContent.prototype.onMessage_ = function(event) {
* @param {string} clientJid The full JID of the WCS client.
* @private
*/
remoting.WcsSandboxContent.prototype.onReady_ = function(clientJid) {
remoting.WcsSandboxContent.prototype.onLocalJid_ = function(clientJid) {
remoting.wcs.setOnIq(this.onIq_.bind(this));
var message = {
'command': 'onReady',
'command': 'onLocalJid',
'clientJid': clientJid
};
this.parentWindow_.postMessage(message, '*');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment