Commit 1735535b authored by Anastasiia N's avatar Anastasiia N Committed by Commit Bot

Use async HasDummyGaiaToken in PO2TS Delegate Chrome OS

Bug: 1135980
Change-Id: Icc9ddf49dc0aa4f077a6312931f6aedd69823bd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453990
Commit-Queue: Anastasiia N <anastasiian@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816971}
parent 69bc3063
...@@ -281,23 +281,9 @@ void ProfileOAuth2TokenServiceDelegateChromeOS::OnGetAccounts( ...@@ -281,23 +281,9 @@ void ProfileOAuth2TokenServiceDelegateChromeOS::OnGetAccounts(
FireRefreshTokensLoaded(); FireRefreshTokensLoaded();
} }
void ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted( void ProfileOAuth2TokenServiceDelegateChromeOS::ContinueTokenUpsertProcessing(
const chromeos::AccountManager::Account& account) { const CoreAccountId& account_id,
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); bool has_dummy_token) {
account_keys_.insert(account.key);
if (account.key.account_type !=
chromeos::account_manager::AccountType::ACCOUNT_TYPE_GAIA) {
return;
}
// All Gaia accounts in Chrome OS Account Manager must have an email
// associated with them (https://crbug.com/933307).
DCHECK(!account.raw_email.empty());
CoreAccountId account_id = account_tracker_service_->SeedAccountInfo(
account.key.id /* gaia_id */, account.raw_email);
DCHECK(!account_id.empty());
GoogleServiceAuthError error(GoogleServiceAuthError::AuthErrorNone()); GoogleServiceAuthError error(GoogleServiceAuthError::AuthErrorNone());
// Clear any previously cached errors for |account_id|. // Clear any previously cached errors for |account_id|.
// Don't call |FireAuthErrorChanged|, since we call it at the end of this // Don't call |FireAuthErrorChanged|, since we call it at the end of this
...@@ -308,7 +294,7 @@ void ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted( ...@@ -308,7 +294,7 @@ void ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted(
// However, if we know that |account_key| has a dummy token, store a // However, if we know that |account_key| has a dummy token, store a
// persistent error against it, so that we can pre-emptively reject access // persistent error against it, so that we can pre-emptively reject access
// token requests for it. // token requests for it.
if (account_manager_->HasDummyGaiaTokenSync(account.key)) { if (has_dummy_token) {
error = GoogleServiceAuthError::FromInvalidGaiaCredentialsReason( error = GoogleServiceAuthError::FromInvalidGaiaCredentialsReason(
GoogleServiceAuthError::InvalidGaiaCredentialsReason:: GoogleServiceAuthError::InvalidGaiaCredentialsReason::
CREDENTIALS_REJECTED_BY_CLIENT); CREDENTIALS_REJECTED_BY_CLIENT);
...@@ -323,6 +309,29 @@ void ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted( ...@@ -323,6 +309,29 @@ void ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted(
FireAuthErrorChanged(account_id, error); FireAuthErrorChanged(account_id, error);
} }
void ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted(
const chromeos::AccountManager::Account& account) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
account_keys_.insert(account.key);
if (account.key.account_type !=
chromeos::account_manager::AccountType::ACCOUNT_TYPE_GAIA) {
return;
}
// All Gaia accounts in Chrome OS Account Manager must have an email
// associated with them (https://crbug.com/933307).
DCHECK(!account.raw_email.empty());
CoreAccountId account_id = account_tracker_service_->SeedAccountInfo(
account.key.id /* gaia_id */, account.raw_email);
DCHECK(!account_id.empty());
account_manager_->HasDummyGaiaToken(
account.key, base::BindOnce(&ProfileOAuth2TokenServiceDelegateChromeOS::
ContinueTokenUpsertProcessing,
weak_factory_.GetWeakPtr(), account_id));
}
void ProfileOAuth2TokenServiceDelegateChromeOS::OnAccountRemoved( void ProfileOAuth2TokenServiceDelegateChromeOS::OnAccountRemoved(
const chromeos::AccountManager::Account& account) { const chromeos::AccountManager::Account& account) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
...@@ -84,6 +84,10 @@ class ProfileOAuth2TokenServiceDelegateChromeOS ...@@ -84,6 +84,10 @@ class ProfileOAuth2TokenServiceDelegateChromeOS
void OnGetAccounts( void OnGetAccounts(
const std::vector<chromeos::AccountManager::Account>& accounts); const std::vector<chromeos::AccountManager::Account>& accounts);
// Callback handler for |chromeos::AccountManager::HasDummyGaiaToken|.
void ContinueTokenUpsertProcessing(const CoreAccountId& account_id,
bool has_dummy_token);
// Non-owning pointers. // Non-owning pointers.
AccountTrackerService* const account_tracker_service_; AccountTrackerService* const account_tracker_service_;
network::NetworkConnectionTracker* const network_connection_tracker_; network::NetworkConnectionTracker* const network_connection_tracker_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment