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

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

Issue 955283002: Converted remoting.Error from an enum to a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
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 /** @suppress {duplicate} */ 9 /** @suppress {duplicate} */
10 var remoting = remoting || {}; 10 var remoting = remoting || {};
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 // If not, pass an error back to the callback(s) if we've already prompted the 183 // If not, pass an error back to the callback(s) if we've already prompted the
184 // user for permission. 184 // user for permission.
185 if (this.interactive_) { 185 if (this.interactive_) {
186 var error_message = 186 var error_message =
187 chrome.runtime.lastError ? chrome.runtime.lastError.message 187 chrome.runtime.lastError ? chrome.runtime.lastError.message
188 : 'Unknown error.'; 188 : 'Unknown error.';
189 console.error(error_message); 189 console.error(error_message);
190 var error = (error_message == USER_CANCELLED) ? 190 var error = (error_message == USER_CANCELLED) ?
191 remoting.Error.CANCELLED : remoting.Error.NOT_AUTHENTICATED; 191 remoting.Error.Tag.CANCELLED : remoting.Error.Tag.NOT_AUTHENTICATED;
192 authTokenDeferred.reject(error); 192 authTokenDeferred.reject(error);
193 this.authTokenDeferred_ = null; 193 this.authTokenDeferred_ = null;
194 return; 194 return;
195 } 195 }
196 196
197 // If there's no token, but we haven't yet prompted for permission, do so 197 // If there's no token, but we haven't yet prompted for permission, do so
198 // now. 198 // now.
199 var that = this; 199 var that = this;
200 var showConsentDialog = 200 var showConsentDialog =
201 (this.consentDialog_) ? this.consentDialog_.show() : Promise.resolve(); 201 (this.consentDialog_) ? this.consentDialog_.show() : Promise.resolve();
202 showConsentDialog.then(function() { 202 showConsentDialog.then(function() {
203 that.interactive_ = true; 203 that.interactive_ = true;
204 chrome.identity.getAuthToken({'interactive': that.interactive_}, 204 chrome.identity.getAuthToken({'interactive': that.interactive_},
205 that.onAuthComplete_.bind(that)); 205 that.onAuthComplete_.bind(that));
206 }); 206 });
207 }; 207 };
208 208
209 /** 209 /**
210 * Returns whether the web app has authenticated with the Google services. 210 * Returns whether the web app has authenticated with the Google services.
211 * 211 *
212 * @return {boolean} 212 * @return {boolean}
213 */ 213 */
214 remoting.Identity.prototype.isAuthenticated = function() { 214 remoting.Identity.prototype.isAuthenticated = function() {
215 return remoting.identity.email_ !== ''; 215 return remoting.identity.email_ !== '';
216 }; 216 };
217 217
218 })(); 218 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698