diff options
-rw-r--r-- | components/autofill/core/browser/autofill_manager.cc | 21 | ||||
-rw-r--r-- | components/autofill/core/browser/autofill_manager_unittest.cc | 35 |
2 files changed, 45 insertions, 11 deletions
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index c0a5bff..5df3ca1 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -821,20 +821,19 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) return; - // Don't offer to save any cards that were recently unmasked. - if (recently_unmasked_cards_.end() != - std::find_if(recently_unmasked_cards_.begin(), - recently_unmasked_cards_.end(), - [&imported_credit_card](const CreditCard& unmasked) -> bool { - return unmasked.TypeAndLastFourDigits() == - imported_credit_card->TypeAndLastFourDigits(); - })) { - return; - } - // If credit card information was submitted, we need to confirm whether to // save it. if (imported_credit_card) { + // Don't offer to save any cards that were recently unmasked. + if (recently_unmasked_cards_.end() != + std::find_if( + recently_unmasked_cards_.begin(), recently_unmasked_cards_.end(), + [&imported_credit_card](const CreditCard& unmasked) -> bool { + return unmasked.TypeAndLastFourDigits() == + imported_credit_card->TypeAndLastFourDigits(); + })) { + return; + } client_->ConfirmSaveCreditCard( base::Bind( base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc index cc04eb0..b8466a9 100644 --- a/components/autofill/core/browser/autofill_manager_unittest.cc +++ b/components/autofill/core/browser/autofill_manager_unittest.cc @@ -3216,6 +3216,41 @@ TEST_F(AutofillManagerTest, DontOfferToSaveWalletCard) { autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, "4012888888881881"); autofill_manager_->OnFormSubmitted(form); + + // The rest of this test is a regression test for http://crbug.com/483602. + // The goal is not to crash. + EXPECT_CALL(*autofill_driver_, SendFormDataToRenderer(_, _, _)); + for (size_t i = 0; i < form.fields.size(); ++i) { + form.fields[i].value.clear(); + } + autofill_manager_->FillOrPreviewCreditCardForm( + AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form, + form.fields[0], card, 0); + autofill_manager_->OnUnmaskResponse(response); + autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, + "4012888888881881"); + + form = FormData(); + test::CreateTestAddressFormData(&form); + forms[0] = form; + FormsSeen(forms); + for (size_t i = 0; i < form.fields.size(); ++i) { + if (form.fields[i].name == ASCIIToUTF16("firstname")) + form.fields[i].value = ASCIIToUTF16("Flo"); + else if (form.fields[i].name == ASCIIToUTF16("lastname")) + form.fields[i].value = ASCIIToUTF16("Master"); + else if (form.fields[i].name == ASCIIToUTF16("addr1")) + form.fields[i].value = ASCIIToUTF16("123 Maple"); + else if (form.fields[i].name == ASCIIToUTF16("city")) + form.fields[i].value = ASCIIToUTF16("Dallas"); + else if (form.fields[i].name == ASCIIToUTF16("state")) + form.fields[i].value = ASCIIToUTF16("Texas"); + else if (form.fields[i].name == ASCIIToUTF16("zipcode")) + form.fields[i].value = ASCIIToUTF16("77401"); + else if (form.fields[i].name == ASCIIToUTF16("country")) + form.fields[i].value = ASCIIToUTF16("US"); + } + autofill_manager_->OnFormSubmitted(form); } } // namespace autofill |