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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_api.cc

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing CR comments. Created 7 years, 3 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 #include "chrome/browser/extensions/api/identity/identity_api.h" 5 #include "chrome/browser/extensions/api/identity/identity_api.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 &app_client_id, &app_client_secret)) { 426 &app_client_id, &app_client_secret)) {
427 login_token_request_ = 427 login_token_request_ =
428 service->StartRequestForClient(app_client_id, 428 service->StartRequestForClient(app_client_id,
429 app_client_secret, 429 app_client_secret,
430 OAuth2TokenService::ScopeSet(), 430 OAuth2TokenService::ScopeSet(),
431 this); 431 this);
432 return; 432 return;
433 } 433 }
434 } 434 }
435 #endif 435 #endif
436 login_token_request_ = service->StartRequest(OAuth2TokenService::ScopeSet(), 436 login_token_request_ = service->StartRequest(
437 this); 437 service->GetPrimaryAccountId(), OAuth2TokenService::ScopeSet(), this);
438 } 438 }
439 439
440 void IdentityGetAuthTokenFunction::StartGaiaRequest( 440 void IdentityGetAuthTokenFunction::StartGaiaRequest(
441 const std::string& login_access_token) { 441 const std::string& login_access_token) {
442 DCHECK(!login_access_token.empty()); 442 DCHECK(!login_access_token.empty());
443 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token)); 443 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token));
444 mint_token_flow_->Start(); 444 mint_token_flow_->Start();
445 } 445 }
446 446
447 void IdentityGetAuthTokenFunction::ShowLoginPopup() { 447 void IdentityGetAuthTokenFunction::ShowLoginPopup() {
(...skipping 23 matching lines...) Expand all
471 OAuth2MintTokenFlow::Parameters( 471 OAuth2MintTokenFlow::Parameters(
472 login_access_token, 472 login_access_token,
473 GetExtension()->id(), 473 GetExtension()->id(),
474 oauth2_client_id_, 474 oauth2_client_id_,
475 oauth2_info.scopes, 475 oauth2_info.scopes,
476 gaia_mint_token_mode_)); 476 gaia_mint_token_mode_));
477 return mint_token_flow; 477 return mint_token_flow;
478 } 478 }
479 479
480 bool IdentityGetAuthTokenFunction::HasLoginToken() const { 480 bool IdentityGetAuthTokenFunction::HasLoginToken() const {
481 return ProfileOAuth2TokenServiceFactory::GetForProfile(profile())-> 481 ProfileOAuth2TokenService* token_service =
482 RefreshTokenIsAvailable(); 482 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
483 return token_service->RefreshTokenIsAvailable(
484 token_service->GetPrimaryAccountId());
483 } 485 }
484 486
485 std::string IdentityGetAuthTokenFunction::MapOAuth2ErrorToDescription( 487 std::string IdentityGetAuthTokenFunction::MapOAuth2ErrorToDescription(
486 const std::string& error) { 488 const std::string& error) {
487 const char kOAuth2ErrorAccessDenied[] = "access_denied"; 489 const char kOAuth2ErrorAccessDenied[] = "access_denied";
488 const char kOAuth2ErrorInvalidScope[] = "invalid_scope"; 490 const char kOAuth2ErrorInvalidScope[] = "invalid_scope";
489 491
490 if (error == kOAuth2ErrorAccessDenied) 492 if (error == kOAuth2ErrorAccessDenied)
491 return std::string(identity_constants::kUserRejected); 493 return std::string(identity_constants::kUserRejected);
492 else if (error == kOAuth2ErrorInvalidScope) 494 else if (error == kOAuth2ErrorInvalidScope)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 const IdentityAPI::TokenCacheKey& rhs) const { 771 const IdentityAPI::TokenCacheKey& rhs) const {
770 if (extension_id < rhs.extension_id) 772 if (extension_id < rhs.extension_id)
771 return true; 773 return true;
772 else if (rhs.extension_id < extension_id) 774 else if (rhs.extension_id < extension_id)
773 return false; 775 return false;
774 776
775 return scopes < rhs.scopes; 777 return scopes < rhs.scopes;
776 } 778 }
777 779
778 } // namespace extensions 780 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698