| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 #include <stdint.h> | 8 #include <stdint.h> | 
| 9 | 9 | 
| 10 #include <algorithm> | 10 #include <algorithm> | 
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1171   return IsAutofillEnabled() && !driver_->IsIncognito() && | 1171   return IsAutofillEnabled() && !driver_->IsIncognito() && | 
| 1172          form.ShouldBeParsed() && | 1172          form.ShouldBeParsed() && | 
| 1173          (form.active_field_count() >= kRequiredFieldsForUpload || | 1173          (form.active_field_count() >= kRequiredFieldsForUpload || | 
| 1174           (form.all_fields_are_passwords() && | 1174           (form.all_fields_are_passwords() && | 
| 1175            form.active_field_count() >= | 1175            form.active_field_count() >= | 
| 1176                kRequiredFieldsForFormsWithOnlyPasswordFields)); | 1176                kRequiredFieldsForFormsWithOnlyPasswordFields)); | 
| 1177 } | 1177 } | 
| 1178 | 1178 | 
| 1179 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { | 1179 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { | 
| 1180   std::unique_ptr<CreditCard> imported_credit_card; | 1180   std::unique_ptr<CreditCard> imported_credit_card; | 
|  | 1181   bool imported_credit_card_matches_masked_server_credit_card; | 
| 1181   if (!personal_data_->ImportFormData( | 1182   if (!personal_data_->ImportFormData( | 
| 1182           submitted_form, IsCreditCardUploadEnabled(), &imported_credit_card)) { | 1183           submitted_form, IsCreditCardUploadEnabled(), &imported_credit_card, | 
|  | 1184           &imported_credit_card_matches_masked_server_credit_card)) | 
| 1183     return; | 1185     return; | 
| 1184   } |  | 
| 1185 | 1186 | 
| 1186 #ifdef ENABLE_FORM_DEBUG_DUMP | 1187 #ifdef ENABLE_FORM_DEBUG_DUMP | 
| 1187   // Debug code for research on what autofill Chrome extracts from the last few | 1188   // Debug code for research on what autofill Chrome extracts from the last few | 
| 1188   // forms when submitting credit card data. See DumpAutofillData(). | 1189   // forms when submitting credit card data. See DumpAutofillData(). | 
| 1189   bool dump_data = base::CommandLine::ForCurrentProcess()->HasSwitch( | 1190   bool dump_data = base::CommandLine::ForCurrentProcess()->HasSwitch( | 
| 1190       "dump-autofill-data"); | 1191       "dump-autofill-data"); | 
| 1191 | 1192 | 
| 1192   // Save the form data for future dumping. | 1193   // Save the form data for future dumping. | 
| 1193   if (dump_data) { | 1194   if (dump_data) { | 
| 1194     if (recently_autofilled_forms_.size() > 5) | 1195     if (recently_autofilled_forms_.size() > 5) | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 1210     } | 1211     } | 
| 1211 | 1212 | 
| 1212     DumpAutofillData(!!imported_credit_card); | 1213     DumpAutofillData(!!imported_credit_card); | 
| 1213   } | 1214   } | 
| 1214 #endif  // ENABLE_FORM_DEBUG_DUMP | 1215 #endif  // ENABLE_FORM_DEBUG_DUMP | 
| 1215 | 1216 | 
| 1216   // No card available to offer save or upload. | 1217   // No card available to offer save or upload. | 
| 1217   if (!imported_credit_card) | 1218   if (!imported_credit_card) | 
| 1218     return; | 1219     return; | 
| 1219 | 1220 | 
| 1220   if (!IsCreditCardUploadEnabled()) { | 1221   if (!IsCreditCardUploadEnabled() || | 
| 1221     // This block will only be reached if we have observed a new card. In this | 1222       imported_credit_card_matches_masked_server_credit_card) { | 
| 1222     // case, ImportFormData will return false if the card matches one already | 1223     // This block will only be reached if we have observed a new card or a card | 
| 1223     // stored. | 1224     // whose |TypeAndLastFourDigits|  matches a masked server card. | 
|  | 1225     // |ImportFormData| will return false if the card matches a full card that | 
|  | 1226     // we have already stored. | 
| 1224     client_->ConfirmSaveCreditCardLocally( | 1227     client_->ConfirmSaveCreditCardLocally( | 
| 1225         *imported_credit_card, | 1228         *imported_credit_card, | 
| 1226         base::Bind( | 1229         base::Bind( | 
| 1227             base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), | 1230             base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), | 
| 1228             base::Unretained(personal_data_), *imported_credit_card)); | 1231             base::Unretained(personal_data_), *imported_credit_card)); | 
| 1229   } else { | 1232   } else { | 
| 1230     // Whereas, because we pass IsCreditCardUploadEnabled() to ImportFormData, | 1233     // Whereas, because we pass IsCreditCardUploadEnabled() to ImportFormData, | 
| 1231     // this block can be reached on observing either a new card or one already | 1234     // this block can be reached on observing either a new card or one already | 
| 1232     // stored locally. We will offer to upload either kind. | 1235     // stored locally and whose |TypeAndLastFourDigits| do not match a masked | 
|  | 1236     // server card. We will offer to upload either kind. | 
| 1233     upload_request_ = payments::PaymentsClient::UploadRequestDetails(); | 1237     upload_request_ = payments::PaymentsClient::UploadRequestDetails(); | 
| 1234     upload_request_.card = *imported_credit_card; | 1238     upload_request_.card = *imported_credit_card; | 
| 1235 | 1239 | 
| 1236     // In order to prompt the user to upload their card, we must have both: | 1240     // In order to prompt the user to upload their card, we must have both: | 
| 1237     //  1) Card with CVC | 1241     //  1) Card with CVC | 
| 1238     //  2) 1+ recently-used or modified addresses that meet the client-side | 1242     //  2) 1+ recently-used or modified addresses that meet the client-side | 
| 1239     //     validation rules | 1243     //     validation rules | 
| 1240     // Here we perform both checks before returning or logging anything, | 1244     // Here we perform both checks before returning or logging anything, | 
| 1241     // because if only one of the two is missing, it may be fixable. | 1245     // because if only one of the two is missing, it may be fixable. | 
| 1242 | 1246 | 
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2262 } | 2266 } | 
| 2263 #endif  // ENABLE_FORM_DEBUG_DUMP | 2267 #endif  // ENABLE_FORM_DEBUG_DUMP | 
| 2264 | 2268 | 
| 2265 void AutofillManager::LogCardUploadDecisionUkm( | 2269 void AutofillManager::LogCardUploadDecisionUkm( | 
| 2266     AutofillMetrics::CardUploadDecisionMetric upload_decision) { | 2270     AutofillMetrics::CardUploadDecisionMetric upload_decision) { | 
| 2267   AutofillMetrics::LogCardUploadDecisionUkm( | 2271   AutofillMetrics::LogCardUploadDecisionUkm( | 
| 2268       client_->GetUkmService(), pending_upload_request_url_, upload_decision); | 2272       client_->GetUkmService(), pending_upload_request_url_, upload_decision); | 
| 2269 } | 2273 } | 
| 2270 | 2274 | 
| 2271 }  // namespace autofill | 2275 }  // namespace autofill | 
| OLD | NEW | 
|---|