Commit ef561eec authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert AccountInfo::GetAccountId to a free function

Converting the method to a free function allows to decouple
AccountInfo from AccountId, eventually allowing to move it
to services/identity/public/cpp or even converting to the
mojo structure.

Bug: none
Change-Id: I020dad29ae286cd9da23c819ce0f32c57da3fb8c
Reviewed-on: https://chromium-review.googlesource.com/1124453Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574184}
parent 63cff337
...@@ -178,9 +178,9 @@ void SigninManagerAndroid::FetchPolicyBeforeSignIn( ...@@ -178,9 +178,9 @@ void SigninManagerAndroid::FetchPolicyBeforeSignIn(
content::BrowserContext::GetDefaultStoragePartition(profile_) content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess(); ->GetURLLoaderFactoryForBrowserProcess();
service->FetchPolicyForSignedInUser( service->FetchPolicyForSignedInUser(
AccountIdFromAccountInfo(
AccountTrackerServiceFactory::GetForProfile(profile_) AccountTrackerServiceFactory::GetForProfile(profile_)
->FindAccountInfoByEmail(username_) ->FindAccountInfoByEmail(username_)),
.GetAccountId(),
dm_token_, client_id_, profile_->GetRequestContext(), dm_token_, client_id_, profile_->GetRequestContext(),
url_loader_factory, url_loader_factory,
base::Bind(&SigninManagerAndroid::OnPolicyFetchDone, base::Bind(&SigninManagerAndroid::OnPolicyFetchDone,
......
...@@ -176,7 +176,7 @@ void UserPolicySigninService::TryInitializeForSignedInUser() { ...@@ -176,7 +176,7 @@ void UserPolicySigninService::TryInitializeForSignedInUser() {
} }
InitializeForSignedInUser( InitializeForSignedInUser(
signin_manager()->GetAuthenticatedAccountInfo().GetAccountId(), AccountIdFromAccountInfo(signin_manager()->GetAuthenticatedAccountInfo()),
profile_->GetRequestContext(), profile_->GetRequestContext(),
content::BrowserContext::GetDefaultStoragePartition(profile_) content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess()); ->GetURLLoaderFactoryForBrowserProcess());
......
...@@ -197,7 +197,7 @@ void UserPolicySigninServiceBase::InitializeOnProfileReady(Profile* profile) { ...@@ -197,7 +197,7 @@ void UserPolicySigninServiceBase::InitializeOnProfileReady(Profile* profile) {
signin_manager()->AddObserver(this); signin_manager()->AddObserver(this);
AccountId account_id = AccountId account_id =
signin_manager()->GetAuthenticatedAccountInfo().GetAccountId(); AccountIdFromAccountInfo(signin_manager()->GetAuthenticatedAccountInfo());
if (!account_id.is_valid()) if (!account_id.is_valid())
ShutdownUserCloudPolicyManager(); ShutdownUserCloudPolicyManager();
else else
......
...@@ -251,7 +251,7 @@ void DiceTurnSyncOnHelper::LoadPolicyWithCachedCredentials() { ...@@ -251,7 +251,7 @@ void DiceTurnSyncOnHelper::LoadPolicyWithCachedCredentials() {
policy::UserPolicySigninService* policy_service = policy::UserPolicySigninService* policy_service =
policy::UserPolicySigninServiceFactory::GetForProfile(profile_); policy::UserPolicySigninServiceFactory::GetForProfile(profile_);
policy_service->FetchPolicyForSignedInUser( policy_service->FetchPolicyForSignedInUser(
account_info_.GetAccountId(), dm_token_, client_id_, AccountIdFromAccountInfo(account_info_), dm_token_, client_id_,
profile_->GetRequestContext(), profile_->GetRequestContext(),
content::BrowserContext::GetDefaultStoragePartition(profile_) content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess(), ->GetURLLoaderFactoryForBrowserProcess(),
......
...@@ -55,9 +55,10 @@ bool AccountInfo::UpdateWith(const AccountInfo& other) { ...@@ -55,9 +55,10 @@ bool AccountInfo::UpdateWith(const AccountInfo& other) {
return modified; return modified;
} }
AccountId AccountInfo::GetAccountId() const { AccountId AccountIdFromAccountInfo(const AccountInfo& account_info) {
if (IsEmpty()) if (account_info.IsEmpty())
return EmptyAccountId(); return EmptyAccountId();
DCHECK(!email.empty() && !gaia.empty());
return AccountId::FromUserEmailGaiaId(email, gaia); DCHECK(!account_info.email.empty() && !account_info.gaia.empty());
return AccountId::FromUserEmailGaiaId(account_info.email, account_info.gaia);
} }
...@@ -34,9 +34,9 @@ struct AccountInfo { ...@@ -34,9 +34,9 @@ struct AccountInfo {
// Updates the empty fields of |this| with |other|. Returns whether at least // Updates the empty fields of |this| with |other|. Returns whether at least
// one field was updated. // one field was updated.
bool UpdateWith(const AccountInfo& other); bool UpdateWith(const AccountInfo& other);
// Returns AccountId populated from the account info.
AccountId GetAccountId() const;
}; };
// Returns AccountID populated from |account_info|.
AccountId AccountIdFromAccountInfo(const AccountInfo& account_info);
#endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_INFO_H_ #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_INFO_H_
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