Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[autofill] Credit card scanning fixes and enhancements.
Browse files Browse the repository at this point in the history
- Do not hide the 'scan new card' popup on every character typed.
- Show 'scan new card' only when user is typing digits or separators.
- Hide 'scan new card' suggestion after user typed in 6 digits.

BUG=449646, 441536

Review URL: https://codereview.chromium.org/857633003

Cr-Commit-Position: refs/heads/master@{#312009}
  • Loading branch information
rsolomakhin authored and Commit bot committed Jan 17, 2015
1 parent 501f0a9 commit 25f305d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 9 additions & 2 deletions components/autofill/core/browser/autofill_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 25f305d

Please sign in to comment.