Commit 1844fb3a authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Password Update doesn't require gaia reauth

This CL makes sure the account store opt-in flow isn't triggered upon
password update even if the user hasn't opted in yet.

Bug: 1107384
Change-Id: I35c0bb359af3ca5ed7cc33b74d052fd7cd769b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306092
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790050}
parent 3ea2fb1f
...@@ -153,10 +153,12 @@ void SaveUpdateWithAccountStoreBubbleController::OnSaveClicked() { ...@@ -153,10 +153,12 @@ void SaveUpdateWithAccountStoreBubbleController::OnSaveClicked() {
dismissal_reason_ = metrics_util::CLICKED_ACCEPT; dismissal_reason_ = metrics_util::CLICKED_ACCEPT;
if (delegate_) { if (delegate_) {
CleanStatisticsForSite(GetProfile(), origin_); CleanStatisticsForSite(GetProfile(), origin_);
if (!IsUsingAccountStore() || if (IsCurrentStateUpdate() || !IsUsingAccountStore() ||
delegate_->GetPasswordFeatureManager()->IsOptedInForAccountStorage()) { delegate_->GetPasswordFeatureManager()->IsOptedInForAccountStorage()) {
// User is saving locally or already has opted in to the account store. // The following cases don't require gaia reauth:
// Save directly without the need for reauth. // 1. Password Update.
// 2. User is saving locally .
// 3. User has already opted in to the account store.
delegate_->SavePassword(pending_password_.username_value, delegate_->SavePassword(pending_password_.username_value,
pending_password_.password_value); pending_password_.password_value);
} else { } else {
......
...@@ -348,6 +348,30 @@ TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest, ...@@ -348,6 +348,30 @@ TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest,
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_ACCEPT); DestroyModelExpectReason(password_manager::metrics_util::CLICKED_ACCEPT);
} }
TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest,
ClickUpdateWhileNotOptedIn) {
// This is testing that updating a password should not trigger an account
// store opt in flow even if the user isn't opted in.
ON_CALL(*password_feature_manager(), GetDefaultPasswordStore)
.WillByDefault(Return(autofill::PasswordForm::Store::kAccountStore));
ON_CALL(*password_feature_manager(), IsOptedInForAccountStorage)
.WillByDefault(Return(false));
PretendUpdatePasswordWaiting();
EXPECT_TRUE(controller()->enable_editing());
EXPECT_TRUE(controller()->IsCurrentStateUpdate());
EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
EXPECT_CALL(*delegate(), SavePassword(pending_password().username_value,
pending_password().password_value));
EXPECT_CALL(*delegate(), NeverSavePassword()).Times(0);
EXPECT_CALL(*delegate(), OnNopeUpdateClicked()).Times(0);
EXPECT_CALL(*delegate(), AuthenticateUserForAccountStoreOptInAndSavePassword)
.Times(0);
controller()->OnSaveClicked();
DestroyModelExpectReason(password_manager::metrics_util::CLICKED_ACCEPT);
}
TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest, ClickSaveInUpdateState) { TEST_F(SaveUpdateWithAccountStoreBubbleControllerTest, ClickSaveInUpdateState) {
PretendUpdatePasswordWaiting(); PretendUpdatePasswordWaiting();
......
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