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

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

Issue 1004513002: Eliminated named constants for instances of remoting.Error. (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 * OAuth2 class that handles retrieval/storage of an OAuth2 token. 7 * OAuth2 class that handles retrieval/storage of an OAuth2 token.
8 * 8 *
9 * Uses a content script to trampoline the OAuth redirect page back into the 9 * Uses a content script to trampoline the OAuth redirect page back into the
10 * extension context. This works around the lack of native support for 10 * extension context. This works around the lack of native support for
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 /** 316 /**
317 * Asynchronously exchanges an authorization code for a refresh token. 317 * Asynchronously exchanges an authorization code for a refresh token.
318 * 318 *
319 * @param {string} code The OAuth2 authorization code. 319 * @param {string} code The OAuth2 authorization code.
320 * @param {function():void} onDone Callback to invoke on completion. 320 * @param {function():void} onDone Callback to invoke on completion.
321 * @return {void} Nothing. 321 * @return {void} Nothing.
322 */ 322 */
323 remoting.OAuth2.prototype.exchangeCodeForToken = function(code, onDone) { 323 remoting.OAuth2.prototype.exchangeCodeForToken = function(code, onDone) {
324 /** @param {!remoting.Error} error */ 324 /** @param {!remoting.Error} error */
325 var onError = function(error) { 325 var onError = function(error) {
326 console.error('Unable to exchange code for token: ', error); 326 console.error('Unable to exchange code for token: ' + error.toString());
327 }; 327 };
328 328
329 remoting.oauth2Api.exchangeCodeForTokens( 329 remoting.oauth2Api.exchangeCodeForTokens(
330 this.onTokens_.bind(this, onDone), onError, 330 this.onTokens_.bind(this, onDone), onError,
331 this.getClientId_(), this.getClientSecret_(), code, 331 this.getClientId_(), this.getClientSecret_(), code,
332 this.getRedirectUri_()); 332 this.getRedirectUri_());
333 }; 333 };
334 334
335 /** 335 /**
336 * Print a command-line that can be used to register a host on Linux platforms. 336 * Print a command-line that can be used to register a host on Linux platforms.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 if (refreshToken) { 368 if (refreshToken) {
369 if (that.needsNewAccessToken_()) { 369 if (that.needsNewAccessToken_()) {
370 remoting.oauth2Api.refreshAccessToken( 370 remoting.oauth2Api.refreshAccessToken(
371 that.onAccessToken_.bind(that, resolve), reject, 371 that.onAccessToken_.bind(that, resolve), reject,
372 that.getClientId_(), that.getClientSecret_(), 372 that.getClientId_(), that.getClientSecret_(),
373 refreshToken); 373 refreshToken);
374 } else { 374 } else {
375 resolve(that.getAccessTokenInternal_()['token']); 375 resolve(that.getAccessTokenInternal_()['token']);
376 } 376 }
377 } else { 377 } else {
378 reject(remoting.Error.NOT_AUTHENTICATED); 378 reject(new remoting.Error(remoting.Error.Tag.NOT_AUTHENTICATED));
379 } 379 }
380 }); 380 });
381 }; 381 };
382 382
383 /** 383 /**
384 * Get the user's email address. 384 * Get the user's email address.
385 * 385 *
386 * @return {!Promise<string>} Promise resolved with the user's email 386 * @return {!Promise<string>} Promise resolved with the user's email
387 * address or rejected with a remoting.Error. 387 * address or rejected with a remoting.Error.
388 */ 388 */
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 window.localStorage.setItem(that.KEY_FULLNAME_, name); 441 window.localStorage.setItem(that.KEY_FULLNAME_, name);
442 resolve({email: email, name: name}); 442 resolve({email: email, name: name});
443 }; 443 };
444 444
445 that.getToken().then( 445 that.getToken().then(
446 remoting.oauth2Api.getUserInfo.bind( 446 remoting.oauth2Api.getUserInfo.bind(
447 remoting.oauth2Api, onResponse, reject), 447 remoting.oauth2Api, onResponse, reject),
448 reject); 448 reject);
449 }); 449 });
450 }; 450 };
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/mock_signal_strategy.js ('k') | remoting/webapp/crd/js/oauth2_api_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698