Skip to content

Commit

Permalink
[Autofill] Introduce TriggerOutcome alias
Browse files Browse the repository at this point in the history
This CL introduces a private alias for
TouchToFillCreditCardTriggerOutcome to reduce visual noise in the
followup CLs.

This CL is a no-op.

Bug: 1379149
Change-Id: I4f2bd373b8076c40b321b5951ddbab69c721c613
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4269550
Reviewed-by: Florian Leimgruber <fleimgruber@google.com>
Commit-Queue: Christoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/main@{#1107392}
  • Loading branch information
schwering authored and Chromium LUCI CQ committed Feb 20, 2023
1 parent 7d6520e commit dcc7ef2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 10 additions & 11 deletions components/autofill/core/browser/touch_to_fill_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,25 @@ bool TouchToFillDelegateImpl::TryToShowTouchToFill(const FormData& form,
if (!manager_->client()->IsTouchToFillCreditCardSupported())
return false;

TouchToFillCreditCardTriggerOutcome outcome =
TouchToFillCreditCardTriggerOutcome::kShown;
TriggerOutcome outcome = TriggerOutcome::kShown;
// Trigger only for complete forms (contining the fields for the card number
// and the card expiration date).
FormStructure* form_structure =
manager_->FindCachedFormById(form.global_id());
if (form_structure && !FormHasAllCreditCardFields(*form_structure)) {
outcome = TouchToFillCreditCardTriggerOutcome::kIncompleteForm;
outcome = TriggerOutcome::kIncompleteForm;
}
// Trigger only if not shown before.
if (ttf_credit_card_state_ != TouchToFillState::kShouldShow) {
outcome = TouchToFillCreditCardTriggerOutcome::kShownBefore;
outcome = TriggerOutcome::kShownBefore;
}
// Trigger only if the client and the form are not insecure.
if (IsFormOrClientNonSecure(manager_->client(), form)) {
outcome = TouchToFillCreditCardTriggerOutcome::kFormOrClientNotSecure;
outcome = TriggerOutcome::kFormOrClientNotSecure;
}
// Trigger only on focusable empty field.
if (!field.is_focusable || !SanitizedFieldIsEmpty(field.value)) {
outcome = TouchToFillCreditCardTriggerOutcome::kFieldNotEmptyOrNotFocusable;
outcome = TriggerOutcome::kFieldNotEmptyOrNotFocusable;
}
// Trigger only if there is at least 1 complete valid credit card on file.
// Complete = contains number, expiration date and name on card.
Expand All @@ -76,22 +75,22 @@ bool TouchToFillDelegateImpl::TryToShowTouchToFill(const FormData& form,
// Not showing the sheet if all the cards are incomplete or invalid.
if (base::ranges::none_of(cards_to_suggest,
&CreditCard::IsCompleteValidCard)) {
outcome = TouchToFillCreditCardTriggerOutcome::kNoValidCards;
outcome = TriggerOutcome::kNoValidCards;
}
// Trigger only if the UI is available.
if (!manager_->CanShowAutofillUi()) {
outcome = TouchToFillCreditCardTriggerOutcome::kCannotShowAutofillUi;
outcome = TriggerOutcome::kCannotShowAutofillUi;
}
// Finally try showing the surface
if (outcome == TouchToFillCreditCardTriggerOutcome::kShown &&
if (outcome == TriggerOutcome::kShown &&
!manager_->client()->ShowTouchToFillCreditCard(
GetWeakPtr(), std::move(cards_to_suggest))) {
outcome = TouchToFillCreditCardTriggerOutcome::kFailedToDisplayBottomSheet;
outcome = TriggerOutcome::kFailedToDisplayBottomSheet;
}
base::UmaHistogramEnumeration(kUmaTouchToFillCreditCardTriggerOutcome,
outcome);
// Return if didn't show the sheet
if (outcome != TouchToFillCreditCardTriggerOutcome::kShown) {
if (outcome != TriggerOutcome::kShown) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class TouchToFillDelegateImpl : public TouchToFillDelegate {
kWasShown,
};

using TriggerOutcome = TouchToFillCreditCardTriggerOutcome;

bool HasAnyAutofilledFields(const FormStructure& submitted_form) const;

TouchToFillState ttf_credit_card_state_ = TouchToFillState::kShouldShow;
Expand Down

0 comments on commit dcc7ef2

Please sign in to comment.