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

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: Fixing a bug affecting ProfileSyncService and 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 case IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND: 215 case IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND:
216 #if defined(OS_CHROMEOS) 216 #if defined(OS_CHROMEOS)
217 // Always force minting token for ChromeOS kiosk app. 217 // Always force minting token for ChromeOS kiosk app.
218 if (chromeos::UserManager::Get()->IsLoggedInAsKioskApp()) { 218 if (chromeos::UserManager::Get()->IsLoggedInAsKioskApp()) {
219 if (g_browser_process->browser_policy_connector()-> 219 if (g_browser_process->browser_policy_connector()->
220 IsEnterpriseManaged()) { 220 IsEnterpriseManaged()) {
221 OAuth2TokenService::ScopeSet scope_set(oauth2_info.scopes.begin(), 221 OAuth2TokenService::ScopeSet scope_set(oauth2_info.scopes.begin(),
222 oauth2_info.scopes.end()); 222 oauth2_info.scopes.end());
223 device_token_request_ = 223 device_token_request_ =
224 chromeos::DeviceOAuth2TokenServiceFactory::Get()->StartRequest( 224 chromeos::DeviceOAuth2TokenServiceFactory::Get()->StartRequest(
225 scope_set, this); 225 std::string(), scope_set, this);
Andrew T Wilson (Slow) 2013/08/30 10:47:00 See my previous comment about adding GetDeviceAcco
fgorski 2013/08/30 20:10:16 Done.
226 } else { 226 } else {
227 gaia_mint_token_mode_ = OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE; 227 gaia_mint_token_mode_ = OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE;
228 StartLoginAccessTokenRequest(); 228 StartLoginAccessTokenRequest();
229 } 229 }
230 return; 230 return;
231 } 231 }
232 #endif 232 #endif
233 233
234 if (oauth2_info.auto_approve) 234 if (oauth2_info.auto_approve)
235 // oauth2_info.auto_approve is protected by a whitelist in 235 // oauth2_info.auto_approve is protected by a whitelist in
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 void IdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() { 418 void IdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() {
419 ProfileOAuth2TokenService* service = 419 ProfileOAuth2TokenService* service =
420 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); 420 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
421 #if defined(OS_CHROMEOS) 421 #if defined(OS_CHROMEOS)
422 if (chrome::IsRunningInForcedAppMode()) { 422 if (chrome::IsRunningInForcedAppMode()) {
423 std::string app_client_id; 423 std::string app_client_id;
424 std::string app_client_secret; 424 std::string app_client_secret;
425 if (chromeos::UserManager::Get()->GetAppModeChromeClientOAuthInfo( 425 if (chromeos::UserManager::Get()->GetAppModeChromeClientOAuthInfo(
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(std::string(),
429 app_client_id,
429 app_client_secret, 430 app_client_secret,
430 OAuth2TokenService::ScopeSet(), 431 OAuth2TokenService::ScopeSet(),
431 this); 432 this);
432 return; 433 return;
433 } 434 }
434 } 435 }
435 #endif 436 #endif
436 login_token_request_ = service->StartRequest(OAuth2TokenService::ScopeSet(), 437 login_token_request_ = service->StartRequest(
437 this); 438 service->GetPrimaryAccountId(), OAuth2TokenService::ScopeSet(), this);
438 } 439 }
439 440
440 void IdentityGetAuthTokenFunction::StartGaiaRequest( 441 void IdentityGetAuthTokenFunction::StartGaiaRequest(
441 const std::string& login_access_token) { 442 const std::string& login_access_token) {
442 DCHECK(!login_access_token.empty()); 443 DCHECK(!login_access_token.empty());
443 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token)); 444 mint_token_flow_.reset(CreateMintTokenFlow(login_access_token));
444 mint_token_flow_->Start(); 445 mint_token_flow_->Start();
445 } 446 }
446 447
447 void IdentityGetAuthTokenFunction::ShowLoginPopup() { 448 void IdentityGetAuthTokenFunction::ShowLoginPopup() {
(...skipping 23 matching lines...) Expand all
471 OAuth2MintTokenFlow::Parameters( 472 OAuth2MintTokenFlow::Parameters(
472 login_access_token, 473 login_access_token,
473 GetExtension()->id(), 474 GetExtension()->id(),
474 oauth2_client_id_, 475 oauth2_client_id_,
475 oauth2_info.scopes, 476 oauth2_info.scopes,
476 gaia_mint_token_mode_)); 477 gaia_mint_token_mode_));
477 return mint_token_flow; 478 return mint_token_flow;
478 } 479 }
479 480
480 bool IdentityGetAuthTokenFunction::HasLoginToken() const { 481 bool IdentityGetAuthTokenFunction::HasLoginToken() const {
481 return ProfileOAuth2TokenServiceFactory::GetForProfile(profile())-> 482 ProfileOAuth2TokenService* token_service =
482 RefreshTokenIsAvailable(); 483 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
484 return token_service->RefreshTokenIsAvailable(
485 token_service->GetPrimaryAccountId());
483 } 486 }
484 487
485 std::string IdentityGetAuthTokenFunction::MapOAuth2ErrorToDescription( 488 std::string IdentityGetAuthTokenFunction::MapOAuth2ErrorToDescription(
486 const std::string& error) { 489 const std::string& error) {
487 const char kOAuth2ErrorAccessDenied[] = "access_denied"; 490 const char kOAuth2ErrorAccessDenied[] = "access_denied";
488 const char kOAuth2ErrorInvalidScope[] = "invalid_scope"; 491 const char kOAuth2ErrorInvalidScope[] = "invalid_scope";
489 492
490 if (error == kOAuth2ErrorAccessDenied) 493 if (error == kOAuth2ErrorAccessDenied)
491 return std::string(identity_constants::kUserRejected); 494 return std::string(identity_constants::kUserRejected);
492 else if (error == kOAuth2ErrorInvalidScope) 495 else if (error == kOAuth2ErrorInvalidScope)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 const IdentityAPI::TokenCacheKey& rhs) const { 772 const IdentityAPI::TokenCacheKey& rhs) const {
770 if (extension_id < rhs.extension_id) 773 if (extension_id < rhs.extension_id)
771 return true; 774 return true;
772 else if (rhs.extension_id < extension_id) 775 else if (rhs.extension_id < extension_id)
773 return false; 776 return false;
774 777
775 return scopes < rhs.scopes; 778 return scopes < rhs.scopes;
776 } 779 }
777 780
778 } // namespace extensions 781 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698