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

Side by Side Diff: remoting/webapp/base/js/auth_init.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/base/js/auth_dialog.js ('k') | remoting/webapp/base/js/base.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 /** 10 /**
(...skipping 24 matching lines...) Expand all
35 remoting.identity = /** @type {remoting.Identity} */ (oauth2); 35 remoting.identity = /** @type {remoting.Identity} */ (oauth2);
36 if (!remoting.identity.isAuthenticated()) { 36 if (!remoting.identity.isAuthenticated()) {
37 remoting.AuthDialog.getInstance().show().then(function() { 37 remoting.AuthDialog.getInstance().show().then(function() {
38 remoting.oauth2.doAuthRedirect(function(){ 38 remoting.oauth2.doAuthRedirect(function(){
39 window.location.reload(); 39 window.location.reload();
40 }); 40 });
41 }); 41 });
42 } 42 }
43 } 43 }
44 44
45 remoting.identity.getUserInfo(onUserInfoAvailable, 45 remoting.identity.getUserInfo().then(function(userInfo) {
46 onGetIdentityInfoError); 46 onUserInfoAvailable(userInfo.email, userInfo.name);
47 }).catch(function(error) {
48 onGetIdentityInfoError(
49 /** @type {remoting.Error} */ (error));
50 });
47 }; 51 };
48 52
49 /** 53 /**
50 * Removes the cached token and restarts the app. 54 * Removes the cached token and restarts the app.
51 * 55 *
52 * @return {void} Nothing. 56 * @return {void} Nothing.
53 */ 57 */
54 remoting.handleAuthFailureAndRelaunch = function() { 58 remoting.handleAuthFailureAndRelaunch = function() {
55 remoting.identity.removeCachedAuthToken(function(){ 59 remoting.identity.removeCachedAuthToken().then(function(){
56 if (base.isAppsV2()) { 60 if (base.isAppsV2()) {
57 base.Ipc.invoke('remoting.ActivationHandler.restart', 61 base.Ipc.invoke('remoting.ActivationHandler.restart',
58 chrome.app.window.current().id); 62 chrome.app.window.current().id);
59 } else { 63 } else {
60 window.location.reload(); 64 window.location.reload();
61 } 65 }
62 }); 66 });
63 }; 67 };
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/auth_dialog.js ('k') | remoting/webapp/base/js/base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698