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 /** | 10 /** |
(...skipping 24 matching lines...) Expand all Loading... |
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 }; |
OLD | NEW |