Commit 1f351119 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Fix manual saving on accounts.google.com

This is a regression after the old parser removal.
PasswordManager::ShowManualFallbackForSaving uses the result of the old
parser. This CL makes using the result of the new parser.

Bug: 1011732
Change-Id: I0537b472984e029aa2b002ee4d79717ac3f86765
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1875102
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708588}
parent f15028b1
......@@ -409,8 +409,7 @@ void PasswordManager::ShowManualFallbackForSaving(
if (!client_->GetProfilePasswordStore()->IsAbleToSavePasswords() ||
!client_->IsSavingAndFillingEnabled(password_form.origin) ||
ShouldBlockPasswordForSameOriginButDifferentScheme(
password_form.origin) ||
!client_->GetStoreResultFilter()->ShouldSave(password_form)) {
password_form.origin)) {
return;
}
......@@ -423,6 +422,11 @@ void PasswordManager::ShowManualFallbackForSaving(
if (!manager)
return;
if (!client_->GetStoreResultFilter()->ShouldSave(
*manager->GetSubmittedForm())) {
return;
}
// Show the fallback if a prompt or a confirmation bubble should be available.
bool has_generated_password = manager->HasGeneratedPassword();
if (ShouldPromptUserToSavePassword(*manager) || has_generated_password) {
......
......@@ -92,6 +92,10 @@ MATCHER_P(FormIgnoreDate, expected, "") {
return arg == expected_with_date;
}
MATCHER_P(HasUsernameValue, expected_username, "") {
return arg.username_value == expected_username;
}
class MockLeakDetectionCheck : public LeakDetectionCheck {
public:
MOCK_METHOD3(Start, void(const GURL&, base::string16, base::string16));
......@@ -181,6 +185,8 @@ class MockPasswordManagerClient : public StubPasswordManagerClient {
EXPECT_CALL(filter_, ShouldSave(_)).WillRepeatedly(Return(false));
}
testing::NiceMock<MockStoreResultFilter>* filter() { return &filter_; }
private:
testing::NiceMock<MockStoreResultFilter> filter_;
};
......@@ -3375,4 +3381,25 @@ TEST_F(PasswordManagerTest, FormSubmittedOnIFrameMainFrameLoaded) {
true /* did stop loading */);
}
TEST_F(PasswordManagerTest, ShowManualFallbackParsedFormIsUsed) {
EXPECT_CALL(client_, IsSavingAndFillingEnabled(_))
.WillRepeatedly(Return(true));
EXPECT_CALL(*store_, GetLogins(_, _))
.WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms()));
// Create a PasswordForm, with only form_data set.
PasswordForm form;
form.form_data = MakeSimpleForm().form_data;
manager()->OnPasswordFormsParsed(&driver_, {form} /*observed*/);
// Check that the parsed form from |form.form_data| rather than |form| is used
// for checking whether the form should be saved.
EXPECT_CALL(*client_.filter(),
ShouldSave(HasUsernameValue(ASCIIToUTF16("googleuser"))))
.WillOnce(Return(true));
manager()->ShowManualFallbackForSaving(&driver_, form);
}
} // namespace password_manager
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