Commit 02f8a46c authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Implement legacy methods in PrimaryAccountMutator related to signin process

Implement the following methods at the same time, so that we can also
provide decent unit tests that would require of all of them to make
sure functionality works as expected:

  * LegacyStartSigninWithRefreshTokenForPrimaryAccount()
  * LegacyCompletePendingPrimaryAccountSignin()
  * LegacyIsPrimaryAccountAuthInProgress()
  * LegacyPrimaryAccountForAuthInProgress()

Also, PrimaryAccountMutatorTests unit tests for each of those methods as
part of this CL, based on those from SigninManagerTest, including a new
test for ClearPrimaryAccount (i.e. ClearPrimaryAccount_NotSignedIn) to
check that it reports FALSE when there is neither a primary account nor
an authentication process ongoing (now we can finally implement that).

Bug: 906058, 906059, 906063, 906064
Change-Id: I2164c867f35020806225da4e69659364c3429a92
Reviewed-on: https://chromium-review.googlesource.com/c/1342559
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612159}
parent 90b1f2b6
......@@ -41,6 +41,12 @@ bool PrimaryAccountMutatorImpl::ClearPrimaryAccount(
ClearAccountsAction action,
signin_metrics::ProfileSignout source_metric,
signin_metrics::SignoutDelete delete_metric) {
// Check if and auth process is ongoing before reporting failure to support
// the legacy workflow of cancelling it by clearing the primary account.
if (!signin_manager_->IsAuthenticated() &&
!LegacyIsPrimaryAccountAuthInProgress())
return false;
// TODO: report failure if SignOut is not allowed.
switch (action) {
......@@ -88,11 +94,12 @@ void PrimaryAccountMutatorImpl::
const std::string& username,
const std::string& password,
base::OnceCallback<void(const std::string&)> callback) {
NOTIMPLEMENTED();
signin_manager_->StartSignInWithRefreshToken(refresh_token, gaia_id, username,
password, std::move(callback));
}
void PrimaryAccountMutatorImpl::LegacyCompletePendingPrimaryAccountSignin() {
NOTIMPLEMENTED();
signin_manager_->CompletePendingSignin();
}
void PrimaryAccountMutatorImpl::LegacyMergeSigninCredentialIntoCookieJar() {
......@@ -100,14 +107,20 @@ void PrimaryAccountMutatorImpl::LegacyMergeSigninCredentialIntoCookieJar() {
}
bool PrimaryAccountMutatorImpl::LegacyIsPrimaryAccountAuthInProgress() const {
NOTIMPLEMENTED();
return false;
return signin_manager_->AuthInProgress();
}
AccountInfo PrimaryAccountMutatorImpl::LegacyPrimaryAccountForAuthInProgress()
const {
NOTIMPLEMENTED();
return AccountInfo{};
if (!LegacyIsPrimaryAccountAuthInProgress())
return AccountInfo{};
AccountInfo account_info;
account_info.account_id = signin_manager_->GetAccountIdForAuthInProgress();
account_info.gaia = signin_manager_->GetGaiaIdForAuthInProgress();
account_info.email = signin_manager_->GetUsernameForAuthInProgress();
return account_info;
}
void PrimaryAccountMutatorImpl::LegacyCopyCredentialsFrom(
......
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