[AF] Implement "Maximize rewards" suggestion selection [chromium/src : main]

0 views
Skip to first unread message

Haochen Feng (Gerrit)

unread,
Jun 22, 2026, 8:14:16 PM (2 days ago) Jun 22
to Chromium LUCI CQ, Fernando Ramirez, chromium...@chromium.org, armalhotra+a...@google.com, browser-comp...@chromium.org, osaul+aut...@google.com, shgar+aut...@google.com, siashah+au...@chromium.org, siyua+aut...@chromium.org, vinnypersky+...@google.com
Attention needed from Fernando Ramirez

Haochen Feng added 6 comments

Patchset-level comments
File-level comment, Patchset 15 (Latest):
Haochen Feng . resolved

Thanks for the comments! I had mistakenly moved the commit for all the code and unit tests surrounding the `is_card_number_field_empty_` variable elsewhere, sorry about that.

Commit Message
Line 7, Patchset 9:[AF] Implement "Maximize Rewards" Suggestion Selection
Fernando Ramirez . resolved

"Maximize rewards" suggestion selection

Haochen Feng

Done

Line 9, Patchset 10:This CL contains the necessary code to support the suggestion selection flow for the `MaximizeRewardsEntry` suggestion and the corresponding `AiCardRecommendationManager`. It routes suggestion selection to `OnUserDecisionToUseMaximizeRewards`, where it stops at triggering `TriggerCheckoutAmountExtractionWithAi`.
Fernando Ramirez . unresolved

This CL doesn't trigger amount extraction though.

Haochen Feng

My bad, I seem to have mistakenly moved a commit from this CL to another branch when rebasing. I undid that and double-checked this new CL.

Line 9, Patchset 9:This CL contains the necessary code to support the suggestion selection flow for the `MaximizeRewardsEntry` suggestion and the corresponding `AiCardRecommendationManager`. It routes suggestion selection to `OnUserDecisionToUseMaximizeRewards`, where it stops at triggering `TriggerCheckoutAmountExtractionWithAi`.

Additionally, it handles unit tests, and maintaining a private variable `is_card_number_field_empty_`, denoting if the credit card number box is empty or not, which is updated by `NotifyOfFieldState`.
Fernando Ramirez . resolved

Long lines should be wrapped to 72 columns for easier log message
viewing in terminals: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/contributing.md#uploading-a-change-for-review

Haochen Feng

Done

Line 11, Patchset 10:Additionally, it handles unit tests, and maintaining a private variable `is_card_number_field_empty_`, denoting if the credit card number box is empty or not, which is updated by `NotifyOfFieldState`.
Fernando Ramirez . resolved

Also, this CL doesn't store the private variable `is_card_number_field_empty_`. Did you plan to do this in a separate CL?

Haochen Feng

ditto

File components/autofill/core/browser/payments/ai_card_recommendation_manager.cc
Line 19, Patchset 10: OnUserDecisionToUseMaximizeCreditCardBenefits() {}
Fernando Ramirez . resolved

If you plan to implement this in a later CL leave a todo and `NOTIMPLEMENTED()` here.

Haochen Feng

ditto

Open in Gerrit

Related details

Attention is currently required from:
  • Fernando Ramirez
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9d00a358dc03e891d98a8e5fc4537282f1f198e9
Gerrit-Change-Number: 7945046
Gerrit-PatchSet: 15
Gerrit-Owner: Haochen Feng <haoc...@google.com>
Gerrit-Reviewer: Fernando Ramirez <fe...@google.com>
Gerrit-Reviewer: Haochen Feng <haoc...@google.com>
Gerrit-Attention: Fernando Ramirez <fe...@google.com>
Gerrit-Comment-Date: Tue, 23 Jun 2026 00:14:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Fernando Ramirez <fe...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fernando Ramirez (Gerrit)

unread,
Jun 22, 2026, 9:40:06 PM (2 days ago) Jun 22
to Haochen Feng, Chromium LUCI CQ, chromium...@chromium.org, armalhotra+a...@google.com, browser-comp...@chromium.org, osaul+aut...@google.com, shgar+aut...@google.com, siashah+au...@chromium.org, siyua+aut...@chromium.org, vinnypersky+...@google.com
Attention needed from Haochen Feng

Fernando Ramirez added 5 comments

Commit Message
Line 9, Patchset 10:This CL contains the necessary code to support the suggestion selection flow for the `MaximizeRewardsEntry` suggestion and the corresponding `AiCardRecommendationManager`. It routes suggestion selection to `OnUserDecisionToUseMaximizeRewards`, where it stops at triggering `TriggerCheckoutAmountExtractionWithAi`.
Fernando Ramirez . resolved

This CL doesn't trigger amount extraction though.

Haochen Feng

My bad, I seem to have mistakenly moved a commit from this CL to another branch when rebasing. I undid that and double-checked this new CL.

Fernando Ramirez

No worries, thanks!

File components/autofill/core/browser/payments/ai_card_recommendation_manager.h
Line 29, Patchset 15 (Latest): virtual void OnUserDecisionToUseMaximizeCreditCardBenefits();
Fernando Ramirez . unresolved

Let's add a code comment above this function to explain its purpose.

File components/autofill/core/browser/payments/ai_card_recommendation_manager.cc
Line 28, Patchset 15 (Latest): bool is_card_number_field_empty) {
Fernando Ramirez . unresolved

Can this ever be `false`?

`NotifyOfFieldState` is only called if `ShouldShowMaximizeCreditCardBenefitsSuggestion` evaluates to `true`. In order for `ShouldShowMaximizeCreditCardBenefitsSuggestion` to evaluate to `true`, the card number field should be empty:
```
// This ensures the credit card field is empty before we run AI amount
// extraction logic to avoid feeding any credit card numbers to Gemini.
if (!is_card_number_field_empty) {
return false;
}
```

Should we instead remove this parameter and rename this function to `NotifyOfCardNumberFieldEmpty` or something similar?

Line 30, Patchset 15 (Latest): if (!is_card_number_field_empty_) {
browser_autofill_manager_->GetAmountExtractionManager().Reset();
weak_ptr_factory_.InvalidateWeakPtrs();
}
Fernando Ramirez . unresolved

If `is_card_number_field_empty_` can currently never be `false`, then this logic is unreachable.

File components/autofill/core/browser/suggestions/payments/credit_card_suggestion_generator.cc
Line 201, Patchset 15 (Latest): ShouldShowMaximizeCreditCardBenefitsSuggestion(
Fernando Ramirez . unresolved

I left a comment here: https://chromium-review.git.corp.google.com/c/chromium/src/+/7920915/comment/9b4d075e_b45aa58d/.

Depending on what Vinny says, we may need to remove the `is_card_number_field_empty` param from this function. This way `NotifyOfFieldState` is also called when `is_card_number_field_empty` is `false`.

Open in Gerrit

Related details

Attention is currently required from:
  • Haochen Feng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9d00a358dc03e891d98a8e5fc4537282f1f198e9
Gerrit-Change-Number: 7945046
Gerrit-PatchSet: 15
Gerrit-Owner: Haochen Feng <haoc...@google.com>
Gerrit-Reviewer: Fernando Ramirez <fe...@google.com>
Gerrit-Reviewer: Haochen Feng <haoc...@google.com>
Gerrit-Attention: Haochen Feng <haoc...@google.com>
Gerrit-Comment-Date: Tue, 23 Jun 2026 01:39:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Haochen Feng <haoc...@google.com>
Comment-In-Reply-To: Fernando Ramirez <fe...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Haochen Feng (Gerrit)

unread,
3:41 PM (8 hours ago) 3:41 PM
to Chromium LUCI CQ, Fernando Ramirez, chromium...@chromium.org, armalhotra+a...@google.com, browser-comp...@chromium.org, osaul+aut...@google.com, shgar+aut...@google.com, siashah+au...@chromium.org, siyua+aut...@chromium.org, vinnypersky+...@google.com
Attention needed from Fernando Ramirez

Haochen Feng added 4 comments

File components/autofill/core/browser/payments/ai_card_recommendation_manager.h
Line 29, Patchset 15: virtual void OnUserDecisionToUseMaximizeCreditCardBenefits();
Fernando Ramirez . unresolved

Let's add a code comment above this function to explain its purpose.

Haochen Feng

done -- let me know if this works.

File components/autofill/core/browser/payments/ai_card_recommendation_manager.cc
Line 28, Patchset 15: bool is_card_number_field_empty) {
Fernando Ramirez . unresolved

Can this ever be `false`?

`NotifyOfFieldState` is only called if `ShouldShowMaximizeCreditCardBenefitsSuggestion` evaluates to `true`. In order for `ShouldShowMaximizeCreditCardBenefitsSuggestion` to evaluate to `true`, the card number field should be empty:
```
// This ensures the credit card field is empty before we run AI amount
// extraction logic to avoid feeding any credit card numbers to Gemini.
if (!is_card_number_field_empty) {
return false;
}
```

Should we instead remove this parameter and rename this function to `NotifyOfCardNumberFieldEmpty` or something similar?

Haochen Feng

I implemented the fix as we discussed, with the in-line check. Let me know if this works.

For the fix I removed the check for `is_card_number_field_empty` in `ShouldShowMaximizeCreditCardBenefitsSuggestion`, as well as the parameter, so it could successfully notify the manager.

Then, I added an in-line check in `credit_card_suggestion_generator.cc` to prevent suggestion Generation when `is_card_number_field_empty` is false, similar to BNPL

Line 30, Patchset 15: if (!is_card_number_field_empty_) {
browser_autofill_manager_->GetAmountExtractionManager().Reset();
weak_ptr_factory_.InvalidateWeakPtrs();
}
Fernando Ramirez . resolved

If `is_card_number_field_empty_` can currently never be `false`, then this logic is unreachable.

Haochen Feng

Resolved -- we discussed in meeting and ended up removing the param and the associated check, so the logic is reachable now.

File components/autofill/core/browser/suggestions/payments/credit_card_suggestion_generator.cc
Line 201, Patchset 15: ShouldShowMaximizeCreditCardBenefitsSuggestion(
Fernando Ramirez . resolved

I left a comment here: https://chromium-review.git.corp.google.com/c/chromium/src/+/7920915/comment/9b4d075e_b45aa58d/.

Depending on what Vinny says, we may need to remove the `is_card_number_field_empty` param from this function. This way `NotifyOfFieldState` is also called when `is_card_number_field_empty` is `false`.

Haochen Feng

Resolved -- we discussed in meeting and ended up removing the param and the associated check.

Open in Gerrit

Related details

Attention is currently required from:
  • Fernando Ramirez
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9d00a358dc03e891d98a8e5fc4537282f1f198e9
Gerrit-Change-Number: 7945046
Gerrit-PatchSet: 17
Gerrit-Owner: Haochen Feng <haoc...@google.com>
Gerrit-Reviewer: Fernando Ramirez <fe...@google.com>
Gerrit-Reviewer: Haochen Feng <haoc...@google.com>
Gerrit-Attention: Fernando Ramirez <fe...@google.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 19:41:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Fernando Ramirez <fe...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fernando Ramirez (Gerrit)

unread,
9:23 PM (2 hours ago) 9:23 PM
to Haochen Feng, Chromium LUCI CQ, chromium...@chromium.org, armalhotra+a...@google.com, browser-comp...@chromium.org, osaul+aut...@google.com, shgar+aut...@google.com, siashah+au...@chromium.org, siyua+aut...@chromium.org, vinnypersky+...@google.com
Attention needed from Haochen Feng

Fernando Ramirez voted and added 5 comments

Votes added by Fernando Ramirez

Code-Review+1

5 comments

Patchset-level comments
File-level comment, Patchset 18 (Latest):
Fernando Ramirez . resolved

LGTM % left a question and recommended unittest update.

File components/autofill/core/browser/payments/ai_card_recommendation_manager.h
Line 29, Patchset 15: virtual void OnUserDecisionToUseMaximizeCreditCardBenefits();
Fernando Ramirez . resolved

Let's add a code comment above this function to explain its purpose.

Haochen Feng

done -- let me know if this works.

Fernando Ramirez

Thanks!

File components/autofill/core/browser/payments/ai_card_recommendation_manager.cc
Line 28, Patchset 15: bool is_card_number_field_empty) {
Fernando Ramirez . resolved

Can this ever be `false`?

`NotifyOfFieldState` is only called if `ShouldShowMaximizeCreditCardBenefitsSuggestion` evaluates to `true`. In order for `ShouldShowMaximizeCreditCardBenefitsSuggestion` to evaluate to `true`, the card number field should be empty:
```
// This ensures the credit card field is empty before we run AI amount
// extraction logic to avoid feeding any credit card numbers to Gemini.
if (!is_card_number_field_empty) {
return false;
}
```

Should we instead remove this parameter and rename this function to `NotifyOfCardNumberFieldEmpty` or something similar?

Haochen Feng

I implemented the fix as we discussed, with the in-line check. Let me know if this works.

For the fix I removed the check for `is_card_number_field_empty` in `ShouldShowMaximizeCreditCardBenefitsSuggestion`, as well as the parameter, so it could successfully notify the manager.

Then, I added an in-line check in `credit_card_suggestion_generator.cc` to prevent suggestion Generation when `is_card_number_field_empty` is false, similar to BNPL

Fernando Ramirez

Thank you! This looks good.

Line 32, Patchset 18 (Latest): weak_ptr_factory_.InvalidateWeakPtrs();
Fernando Ramirez . unresolved

What is this needed for?

File components/autofill/core/browser/payments/ai_card_recommendation_manager_unittest.cc
Line 101, Patchset 18 (Latest):// Tests that NotifyOfFieldState(false) cancels ongoing amount extraction.
Fernando Ramirez . unresolved

Is amount extraction currently running given this test setup?

Calling `NotifyOfFieldState(true)` doesn't mean that it is.

I think this should instead test that calling `NotifyOfFieldState(false)` calls `Reset`. Similar to: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/autofill/payments/android_bnpl_ui_delegate_unittest.cc;l=104-111;drc=fbb0fa2da371a4a3baf7ba38ac12796ebf20ca52

Open in Gerrit

Related details

Attention is currently required from:
  • Haochen Feng
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I9d00a358dc03e891d98a8e5fc4537282f1f198e9
    Gerrit-Change-Number: 7945046
    Gerrit-PatchSet: 18
    Gerrit-Owner: Haochen Feng <haoc...@google.com>
    Gerrit-Reviewer: Fernando Ramirez <fe...@google.com>
    Gerrit-Reviewer: Haochen Feng <haoc...@google.com>
    Gerrit-Attention: Haochen Feng <haoc...@google.com>
    Gerrit-Comment-Date: Thu, 25 Jun 2026 01:22:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages