Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Unified Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2855943002: Offer to save card locally if user manually enters same card number as (Closed)
Patch Set: Creates separate tests for duplicating masked server card and not duplicating full server card. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 2f0c2308b0921eab7ff7abee8ce64a0420aee271..f5f2d49352c8297e0dc9b9c2880b62216f380edf 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -1178,10 +1178,11 @@ bool AutofillManager::ShouldUploadForm(const FormStructure& form) {
void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
std::unique_ptr<CreditCard> imported_credit_card;
+ bool imported_credit_card_matches_masked_server_credit_card;
if (!personal_data_->ImportFormData(
- submitted_form, IsCreditCardUploadEnabled(), &imported_credit_card)) {
+ submitted_form, IsCreditCardUploadEnabled(), &imported_credit_card,
+ &imported_credit_card_matches_masked_server_credit_card))
return;
- }
#ifdef ENABLE_FORM_DEBUG_DUMP
// Debug code for research on what autofill Chrome extracts from the last few
@@ -1217,10 +1218,12 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
if (!imported_credit_card)
return;
- if (!IsCreditCardUploadEnabled()) {
- // This block will only be reached if we have observed a new card. In this
- // case, ImportFormData will return false if the card matches one already
- // stored.
+ if (!IsCreditCardUploadEnabled() ||
+ imported_credit_card_matches_masked_server_credit_card) {
+ // This block will only be reached if we have observed a new card or a card
+ // whose |TypeAndLastFourDigits| matches a masked server card.
+ // |ImportFormData| will return false if the card matches a full card that
+ // we have already stored.
client_->ConfirmSaveCreditCardLocally(
*imported_credit_card,
base::Bind(
@@ -1229,7 +1232,8 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
} else {
// Whereas, because we pass IsCreditCardUploadEnabled() to ImportFormData,
// this block can be reached on observing either a new card or one already
- // stored locally. We will offer to upload either kind.
+ // stored locally and whose |TypeAndLastFourDigits| do not match a masked
+ // server card. We will offer to upload either kind.
upload_request_ = payments::PaymentsClient::UploadRequestDetails();
upload_request_.card = *imported_credit_card;
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698