diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-26 21:14:18 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-26 21:14:18 +0000 |
commit | 52787305fc89e955af6f4fd19fce95d8990c745a (patch) | |
tree | 879129b5177a6ac13b62b99382a07bee03f12403 /remoting | |
parent | 64ceb1681c34f5116d76947c993eb10115086976 (diff) | |
download | chromium_src-52787305fc89e955af6f4fd19fce95d8990c745a.zip chromium_src-52787305fc89e955af6f4fd19fce95d8990c745a.tar.gz chromium_src-52787305fc89e955af6f4fd19fce95d8990c745a.tar.bz2 |
Don't transition to in-session mode until the connection has been established.
BUG=83648
TEST=
Review URL: http://codereview.chromium.org/7511001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/me2mom/choice.html | 2 | ||||
-rw-r--r-- | remoting/webapp/me2mom/client_session.js | 9 | ||||
-rw-r--r-- | remoting/webapp/me2mom/remoting.js | 11 |
3 files changed, 17 insertions, 5 deletions
diff --git a/remoting/webapp/me2mom/choice.html b/remoting/webapp/me2mom/choice.html index 956a0d1..5c83cca 100644 --- a/remoting/webapp/me2mom/choice.html +++ b/remoting/webapp/me2mom/choice.html @@ -239,7 +239,7 @@ found in the LICENSE file. </footer> </section> <!-- choice-mode --> - <section id="session-mode" class="mode in-session-element"> + <section id="session-mode" class="mode in-session-element client-element"> </section> <!-- session-mode --> diff --git a/remoting/webapp/me2mom/client_session.js b/remoting/webapp/me2mom/client_session.js index 50127dd..6a38e26 100644 --- a/remoting/webapp/me2mom/client_session.js +++ b/remoting/webapp/me2mom/client_session.js @@ -23,7 +23,9 @@ var remoting = remoting || {}; * @param {string} accessCode The access code for the IT2Me connection. * @param {string} email The username for the talk network. * @param {function(remoting.ClientSession.State):void} onStateChange - * The callback to invoke when the session changes state. + * The callback to invoke when the session changes state. This callback + * occurs after the state changes and is passed the previous state; the + * new state is accessible via ClientSession's |state| property. * @constructor */ remoting.ClientSession = function(hostJid, hostPublicKey, accessCode, email, @@ -111,6 +113,8 @@ remoting.ClientSession.prototype.createPluginAndConnect = this.plugin.id = this.PLUGIN_ID; this.plugin.src = 'about://none'; this.plugin.type = 'pepper-application/x-chromoting'; + this.plugin.width = 0; + this.plugin.height = 0; container.appendChild(this.plugin); if (!this.isPluginVersionSupported_(this.plugin)) { @@ -320,9 +324,10 @@ remoting.ClientSession.prototype.connectionInfoUpdateCallback = function() { * @return {void} Nothing. */ remoting.ClientSession.prototype.setState_ = function(state) { + var oldState = state; this.state = state; if (this.onStateChange) { - this.onStateChange(this.state); + this.onStateChange(oldState); } }; diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js index 8433a90..695bb84 100644 --- a/remoting/webapp/me2mom/remoting.js +++ b/remoting/webapp/me2mom/remoting.js @@ -438,7 +438,8 @@ function updateStatistics() { window.setTimeout(updateStatistics, 1000); } -function onClientStateChange_(state) { +function onClientStateChange_(oldState) { + var state = remoting.session.state; if (state == remoting.ClientSession.State.UNKNOWN) { setClientStateMessage('Unknown'); } else if (state == remoting.ClientSession.State.CREATED) { @@ -458,9 +459,16 @@ function onClientStateChange_(state) { host = split[0]; } setClientStateMessage('Connected to', host); + setGlobalMode(remoting.AppMode.IN_SESSION); updateStatistics(); } else if (state == remoting.ClientSession.State.CLOSED) { setClientStateMessage('Closed'); + if (oldState != remoting.ClientSession.State.CONNECTED) { + // TODO(jamiewalch): This is not quite correct, as it will report + // "Invalid access code", regardless of what actually went wrong. + // Fix this up by having the host send a suitable error code. + showConnectError_(404); + } } else if (state == remoting.ClientSession.State.CONNECTION_FAILED) { setClientStateMessage('Failed'); } else { @@ -471,7 +479,6 @@ function onClientStateChange_(state) { function startSession_() { remoting.debug.log('Starting session...'); remoting.username = getEmail(); - setGlobalMode(remoting.AppMode.IN_SESSION); remoting.session = new remoting.ClientSession(remoting.hostJid, remoting.hostPublicKey, remoting.accessCode, getEmail(), |