Commit 025ccef9 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Show "Move to account" bubble only in save-to-account mode

Bug: 1107422
Change-Id: Ib3f37fa164053f4afacf9db646bf62fef8007cde
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308714
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790358}
parent 603f811c
......@@ -87,6 +87,8 @@ bool PasswordManagerClientHelper::ShouldPromptToMovePasswordToAccount(
const PasswordFormManagerForUI& submitted_manager) const {
return delegate_->GetPasswordFeatureManager()
->ShouldShowAccountStorageBubbleUi() &&
delegate_->GetPasswordFeatureManager()->GetDefaultPasswordStore() ==
autofill::PasswordForm::Store::kAccountStore &&
submitted_manager.IsMovableToAccountStore() &&
!delegate_->IsIncognito();
}
......
......@@ -121,14 +121,33 @@ TEST_F(PasswordManagerClientHelperTest,
CreateFormManager(&form, /*is_movable=*/true));
}
TEST_F(PasswordManagerClientHelperTest, PromptMoveForMovableForm) {
TEST_F(PasswordManagerClientHelperTest, PromptMoveForMovableFormInAccountMode) {
EXPECT_CALL(*client()->GetPasswordFeatureManager(),
ShouldShowAccountStorageBubbleUi)
.WillOnce(Return(true));
EXPECT_CALL(*client()->GetPasswordFeatureManager(), GetDefaultPasswordStore)
.WillOnce(Return(autofill::PasswordForm::Store::kAccountStore));
EXPECT_CALL(*client(), PromptUserToMovePasswordToAccount);
EXPECT_CALL(*client(), PromptUserToEnableAutosignin).Times(0);
// Indicate successful login without matching form.
// Indicate successful login.
const PasswordForm form =
CreateForm(kTestUsername, kTestPassword, GURL(kTestOrigin));
helper()->NotifySuccessfulLoginWithExistingPassword(
CreateFormManager(&form, /*is_movable=*/true));
}
TEST_F(PasswordManagerClientHelperTest,
NoPromptToMoveForMovableFormInProfileMode) {
EXPECT_CALL(*client()->GetPasswordFeatureManager(),
ShouldShowAccountStorageBubbleUi)
.WillOnce(Return(true));
EXPECT_CALL(*client()->GetPasswordFeatureManager(), GetDefaultPasswordStore)
.WillOnce(Return(autofill::PasswordForm::Store::kProfileStore));
EXPECT_CALL(*client(), PromptUserToMovePasswordToAccount).Times(0);
EXPECT_CALL(*client(), PromptUserToEnableAutosignin).Times(0);
// Indicate successful login.
const PasswordForm form =
CreateForm(kTestUsername, kTestPassword, GURL(kTestOrigin));
helper()->NotifySuccessfulLoginWithExistingPassword(
......
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