diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc index abea42485fb10..a8331e7b7e782 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc @@ -565,7 +565,8 @@ bool AutofillPopupControllerImpl::HasSuggestions() { id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || id == POPUP_ITEM_ID_PASSWORD_ENTRY || id == POPUP_ITEM_ID_DATALIST_ENTRY || - id == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS; + id == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS || + id == POPUP_ITEM_ID_SCAN_CREDIT_CARD; } void AutofillPopupControllerImpl::SetValues( diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index 2de96fceb2c70..67e7636cd2384 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -299,8 +299,15 @@ bool AutofillManager::ShouldShowScanCreditCard(const FormData& form, return false; AutofillField* autofill_field = GetAutofillField(form, field); - return autofill_field && - autofill_field->Type().GetStorableType() == CREDIT_CARD_NUMBER; + if (!autofill_field || + autofill_field->Type().GetStorableType() != CREDIT_CARD_NUMBER) { + return false; + } + + static const int kShowScanCreditCardMaxValueLength = 6; + return field.value.size() <= kShowScanCreditCardMaxValueLength && + base::ContainsOnlyChars(CreditCard::StripSeparators(field.value), + base::ASCIIToUTF16("0123456789")); } bool AutofillManager::OnFormSubmitted(const FormData& form,