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(
content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess();
service->FetchPolicyForSignedInUser(
AccountTrackerServiceFactory::GetForProfile(profile_)
->FindAccountInfoByEmail(username_)
.GetAccountId(),
AccountIdFromAccountInfo(
AccountTrackerServiceFactory::GetForProfile(profile_)
->FindAccountInfoByEmail(username_)),
dm_token_, client_id_, profile_->GetRequestContext(),
url_loader_factory,
base::Bind(&SigninManagerAndroid::OnPolicyFetchDone,
......
......@@ -176,7 +176,7 @@ void UserPolicySigninService::TryInitializeForSignedInUser() {
}
InitializeForSignedInUser(
signin_manager()->GetAuthenticatedAccountInfo().GetAccountId(),
AccountIdFromAccountInfo(signin_manager()->GetAuthenticatedAccountInfo()),
profile_->GetRequestContext(),
content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess());
......
......@@ -197,7 +197,7 @@ void UserPolicySigninServiceBase::InitializeOnProfileReady(Profile* profile) {
signin_manager()->AddObserver(this);
AccountId account_id =
signin_manager()->GetAuthenticatedAccountInfo().GetAccountId();
AccountIdFromAccountInfo(signin_manager()->GetAuthenticatedAccountInfo());
if (!account_id.is_valid())
ShutdownUserCloudPolicyManager();
else
......
......@@ -251,7 +251,7 @@ void DiceTurnSyncOnHelper::LoadPolicyWithCachedCredentials() {
policy::UserPolicySigninService* policy_service =
policy::UserPolicySigninServiceFactory::GetForProfile(profile_);
policy_service->FetchPolicyForSignedInUser(
account_info_.GetAccountId(), dm_token_, client_id_,
AccountIdFromAccountInfo(account_info_), dm_token_, client_id_,
profile_->GetRequestContext(),
content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess(),
......
......@@ -55,9 +55,10 @@ bool AccountInfo::UpdateWith(const AccountInfo& other) {
return modified;
}
AccountId AccountInfo::GetAccountId() const {
if (IsEmpty())
AccountId AccountIdFromAccountInfo(const AccountInfo& account_info) {
if (account_info.IsEmpty())
return EmptyAccountId();
DCHECK(!email.empty() && !gaia.empty());
return AccountId::FromUserEmailGaiaId(email, gaia);
}
\ No newline at end of file
DCHECK(!account_info.email.empty() && !account_info.gaia.empty());
return AccountId::FromUserEmailGaiaId(account_info.email, account_info.gaia);
}
......@@ -34,9 +34,9 @@ struct AccountInfo {
// Updates the empty fields of |this| with |other|. Returns whether at least
// one field was updated.
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_
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