| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 remoting.initElementEventHandlers = function() { | 10 remoting.initElementEventHandlers = function() { |
| 11 var goHome = function() { | 11 var goHome = function() { |
| 12 remoting.setMode(remoting.AppMode.HOME); | 12 remoting.setMode(remoting.AppMode.HOME); |
| 13 }; | 13 }; |
| 14 var goEnterAccessCode = function() { | 14 var goEnterAccessCode = function() { |
| 15 // We don't need a token until we authenticate, but asking for one here | 15 // We don't need a token until we authenticate, but asking for one here |
| 16 // handles the token-expired case earlier, avoiding asking the user for | 16 // handles the token-expired case earlier, avoiding asking the user for |
| 17 // the access code both before and after re-authentication. | 17 // the access code both before and after re-authentication. |
| 18 remoting.identity.callWithToken( | 18 remoting.identity.getToken(). |
| 19 /** @param {string} token */ | 19 then(function(token) { |
| 20 function(token) { | |
| 21 remoting.setMode(remoting.AppMode.CLIENT_UNCONNECTED); | 20 remoting.setMode(remoting.AppMode.CLIENT_UNCONNECTED); |
| 22 }, | 21 }). |
| 23 remoting.showErrorMessage); | 22 catch(remoting.Error.handler(remoting.showErrorMessage)); |
| 24 }; | 23 }; |
| 25 var goFinishedIT2Me = function() { | 24 var goFinishedIT2Me = function() { |
| 26 if (remoting.currentMode == remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME) { | 25 if (remoting.currentMode == remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME) { |
| 27 remoting.setMode(remoting.AppMode.CLIENT_UNCONNECTED); | 26 remoting.setMode(remoting.AppMode.CLIENT_UNCONNECTED); |
| 28 } else { | 27 } else { |
| 29 goHome(); | 28 goHome(); |
| 30 } | 29 } |
| 31 }; | 30 }; |
| 32 /** @param {Event} event The event. */ | 31 /** @param {Event} event The event. */ |
| 33 var sendAccessCode = function(event) { | 32 var sendAccessCode = function(event) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 { event: 'click', id: 'sign-out', fn:remoting.signOut }, | 87 { event: 'click', id: 'sign-out', fn:remoting.signOut }, |
| 89 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, | 88 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, |
| 90 { event: 'click', id: 'token-refresh-error-sign-in', | 89 { event: 'click', id: 'token-refresh-error-sign-in', |
| 91 fn: remoting.handleAuthFailureAndRelaunch } | 90 fn: remoting.handleAuthFailureAndRelaunch } |
| 92 ]; | 91 ]; |
| 93 registerEventListeners(it2me_actions); | 92 registerEventListeners(it2me_actions); |
| 94 registerEventListeners(me2me_actions); | 93 registerEventListeners(me2me_actions); |
| 95 registerEventListeners(host_actions); | 94 registerEventListeners(host_actions); |
| 96 registerEventListeners(auth_actions); | 95 registerEventListeners(auth_actions); |
| 97 } | 96 } |
| OLD | NEW |