Commit 03745aac authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Cleanup: remove SigninManagerWrapper methods for querying account ID/email

Instead, use GetAuthenticatedAccountInfo throughout ProfileSyncService.
One more step on the way to eventually getting rid of SigninManagerWrapper.

Bug: 825190
Change-Id: Icca7037b2f47f1bba3c549080f97ba3824ad9f77
Reviewed-on: https://chromium-review.googlesource.com/1046950
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556449}
parent 64feacce
...@@ -486,9 +486,10 @@ SyncCredentials ProfileSyncService::GetCredentials() { ...@@ -486,9 +486,10 @@ SyncCredentials ProfileSyncService::GetCredentials() {
if (IsLocalSyncEnabled()) if (IsLocalSyncEnabled())
return credentials; return credentials;
credentials.account_id = signin_->GetAccountIdToUse(); const AccountInfo account_info = GetAuthenticatedAccountInfo();
credentials.account_id = account_info.account_id;
DCHECK(!credentials.account_id.empty()); DCHECK(!credentials.account_id.empty());
credentials.email = signin_->GetEffectiveUsername(); credentials.email = account_info.email;
credentials.sync_token = access_token_; credentials.sync_token = access_token_;
if (credentials.sync_token.empty()) if (credentials.sync_token.empty())
...@@ -735,13 +736,13 @@ void ProfileSyncService::AccessTokenFetched(const GoogleServiceAuthError& error, ...@@ -735,13 +736,13 @@ void ProfileSyncService::AccessTokenFetched(const GoogleServiceAuthError& error,
void ProfileSyncService::OnRefreshTokenAvailable( void ProfileSyncService::OnRefreshTokenAvailable(
const std::string& account_id) { const std::string& account_id) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (account_id == signin_->GetAccountIdToUse()) if (account_id == GetAuthenticatedAccountInfo().account_id)
OnRefreshTokensLoaded(); OnRefreshTokensLoaded();
} }
void ProfileSyncService::OnRefreshTokenRevoked(const std::string& account_id) { void ProfileSyncService::OnRefreshTokenRevoked(const std::string& account_id) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (account_id == signin_->GetAccountIdToUse()) { if (account_id == GetAuthenticatedAccountInfo().account_id) {
access_token_.clear(); access_token_.clear();
UpdateAuthErrorState( UpdateAuthErrorState(
GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED));
...@@ -751,8 +752,8 @@ void ProfileSyncService::OnRefreshTokenRevoked(const std::string& account_id) { ...@@ -751,8 +752,8 @@ void ProfileSyncService::OnRefreshTokenRevoked(const std::string& account_id) {
void ProfileSyncService::OnRefreshTokensLoaded() { void ProfileSyncService::OnRefreshTokensLoaded() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
GoogleServiceAuthError token_error = GoogleServiceAuthError token_error = oauth2_token_service_->GetAuthError(
oauth2_token_service_->GetAuthError(signin_->GetAccountIdToUse()); GetAuthenticatedAccountInfo().account_id);
if (token_error == GoogleServiceAuthError::FromInvalidGaiaCredentialsReason( if (token_error == GoogleServiceAuthError::FromInvalidGaiaCredentialsReason(
GoogleServiceAuthError::InvalidGaiaCredentialsReason:: GoogleServiceAuthError::InvalidGaiaCredentialsReason::
CREDENTIALS_REJECTED_BY_CLIENT)) { CREDENTIALS_REJECTED_BY_CLIENT)) {
...@@ -1543,8 +1544,8 @@ void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) { ...@@ -1543,8 +1544,8 @@ void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) {
} }
bool ProfileSyncService::IsSignedIn() const { bool ProfileSyncService::IsSignedIn() const {
// Sync is logged in if there is a non-empty effective account id. // Sync is logged in if there is a non-empty account id.
return !signin_->GetAccountIdToUse().empty(); return !GetAuthenticatedAccountInfo().account_id.empty();
} }
bool ProfileSyncService::CanEngineStart() const { bool ProfileSyncService::CanEngineStart() const {
...@@ -1552,7 +1553,7 @@ bool ProfileSyncService::CanEngineStart() const { ...@@ -1552,7 +1553,7 @@ bool ProfileSyncService::CanEngineStart() const {
return true; return true;
return CanSyncStart() && oauth2_token_service_ && return CanSyncStart() && oauth2_token_service_ &&
oauth2_token_service_->RefreshTokenIsAvailable( oauth2_token_service_->RefreshTokenIsAvailable(
signin_->GetAccountIdToUse()); GetAuthenticatedAccountInfo().account_id);
} }
bool ProfileSyncService::IsEngineInitialized() const { bool ProfileSyncService::IsEngineInitialized() const {
...@@ -1963,8 +1964,7 @@ void ProfileSyncService::RequestAccessToken() { ...@@ -1963,8 +1964,7 @@ void ProfileSyncService::RequestAccessToken() {
// token again. // token again.
if (!access_token_.empty()) { if (!access_token_.empty()) {
signin_->GetIdentityManager()->RemoveAccessTokenFromCache( signin_->GetIdentityManager()->RemoveAccessTokenFromCache(
signin_->GetIdentityManager()->GetPrimaryAccountInfo(), oauth2_scopes, GetAuthenticatedAccountInfo(), oauth2_scopes, access_token_);
access_token_);
} }
access_token_.clear(); access_token_.clear();
...@@ -2091,7 +2091,7 @@ void ProfileSyncService::OnGaiaAccountsInCookieUpdatedWithCallback( ...@@ -2091,7 +2091,7 @@ void ProfileSyncService::OnGaiaAccountsInCookieUpdatedWithCallback(
bool ProfileSyncService::HasCookieJarMismatch( bool ProfileSyncService::HasCookieJarMismatch(
const std::vector<gaia::ListedAccount>& cookie_jar_accounts) { const std::vector<gaia::ListedAccount>& cookie_jar_accounts) {
std::string account_id = signin_->GetAccountIdToUse(); std::string account_id = GetAuthenticatedAccountInfo().account_id;
// Iterate through list of accounts, looking for current sync account. // Iterate through list of accounts, looking for current sync account.
for (const auto& account : cookie_jar_accounts) { for (const auto& account : cookie_jar_accounts) {
if (account.id == account_id) if (account.id == account_id)
......
...@@ -20,11 +20,3 @@ identity::IdentityManager* SigninManagerWrapper::GetIdentityManager() { ...@@ -20,11 +20,3 @@ identity::IdentityManager* SigninManagerWrapper::GetIdentityManager() {
SigninManagerBase* SigninManagerWrapper::GetSigninManager() { SigninManagerBase* SigninManagerWrapper::GetSigninManager() {
return signin_manager_; return signin_manager_;
} }
std::string SigninManagerWrapper::GetEffectiveUsername() const {
return identity_manager_->GetPrimaryAccountInfo().email;
}
std::string SigninManagerWrapper::GetAccountIdToUse() const {
return identity_manager_->GetPrimaryAccountInfo().account_id;
}
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef COMPONENTS_SYNC_DRIVER_SIGNIN_MANAGER_WRAPPER_H_ #ifndef COMPONENTS_SYNC_DRIVER_SIGNIN_MANAGER_WRAPPER_H_
#define COMPONENTS_SYNC_DRIVER_SIGNIN_MANAGER_WRAPPER_H_ #define COMPONENTS_SYNC_DRIVER_SIGNIN_MANAGER_WRAPPER_H_
#include <string>
#include "base/macros.h" #include "base/macros.h"
class SigninManagerBase; class SigninManagerBase;
...@@ -23,12 +21,6 @@ class SigninManagerWrapper { ...@@ -23,12 +21,6 @@ class SigninManagerWrapper {
SigninManagerBase* signin_manager); SigninManagerBase* signin_manager);
~SigninManagerWrapper(); ~SigninManagerWrapper();
// Get the email address to use for this account.
std::string GetEffectiveUsername() const;
// Get the unique ID used to represent this account.
std::string GetAccountIdToUse() const;
// Return the original IdentityManager object that was passed in. // Return the original IdentityManager object that was passed in.
identity::IdentityManager* GetIdentityManager(); identity::IdentityManager* GetIdentityManager();
......
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