Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: remoting/webapp/crd/js/crd_event_handlers.js

Issue 937593002: Changed identity API to use promises instead of callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed bad merge Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/client_session.js ('k') | remoting/webapp/crd/js/error.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/client_session.js ('k') | remoting/webapp/crd/js/error.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698