| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Wrapper class for Chrome's identity API. | 7 * Wrapper class for Chrome's identity API. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 while (this.pendingCallbacks_.length > 0) { | 117 while (this.pendingCallbacks_.length > 0) { |
| 118 var callback = /** @type {remoting.Identity.Callbacks} */ | 118 var callback = /** @type {remoting.Identity.Callbacks} */ |
| 119 this.pendingCallbacks_.shift(); | 119 this.pendingCallbacks_.shift(); |
| 120 callback.onOk(token); | 120 callback.onOk(token); |
| 121 } | 121 } |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // If not, pass an error back to the callback(s) if we've already prompted the | 125 // If not, pass an error back to the callback(s) if we've already prompted the |
| 126 // user for permission. | 126 // user for permission. |
| 127 // TODO(jamiewalch): Figure out what to do with the error in this case. | |
| 128 if (interactive) { | 127 if (interactive) { |
| 129 console.error(chrome.runtime.lastError); | 128 console.error(chrome.runtime.lastError); |
| 130 while (this.pendingCallbacks_.length > 0) { | 129 while (this.pendingCallbacks_.length > 0) { |
| 131 var callback = /** @type {remoting.Identity.Callbacks} */ | 130 var callback = /** @type {remoting.Identity.Callbacks} */ |
| 132 this.pendingCallbacks_.shift(); | 131 this.pendingCallbacks_.shift(); |
| 133 callback.onError(remoting.Error.UNEXPECTED); | 132 callback.onError(remoting.Error.NOT_AUTHENTICATED); |
| 134 } | 133 } |
| 135 return; | 134 return; |
| 136 } | 135 } |
| 137 | 136 |
| 138 // If there's no token, but we haven't yet prompted for permission, do so | 137 // If there's no token, but we haven't yet prompted for permission, do so |
| 139 // now. The consent callback is responsible for continuing the auth flow. | 138 // now. The consent callback is responsible for continuing the auth flow. |
| 140 this.consentCallback_(this.onAuthContinue_.bind(this)); | 139 this.consentCallback_(this.onAuthContinue_.bind(this)); |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 /** | 142 /** |
| (...skipping 23 matching lines...) Expand all Loading... |
| 167 }; | 166 }; |
| 168 | 167 |
| 169 /** | 168 /** |
| 170 * Returns whether the web app has authenticated with the Google services. | 169 * Returns whether the web app has authenticated with the Google services. |
| 171 * | 170 * |
| 172 * @return {boolean} | 171 * @return {boolean} |
| 173 */ | 172 */ |
| 174 remoting.Identity.prototype.isAuthenticated = function() { | 173 remoting.Identity.prototype.isAuthenticated = function() { |
| 175 return remoting.identity.email_ != null; | 174 return remoting.identity.email_ != null; |
| 176 }; | 175 }; |
| OLD | NEW |