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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2611863002: Refactors cvc and expiration date validation in CC upload logic as well as unmask prompt. (Closed)
Patch Set: Initial Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 // this block can be reached on observing either a new card or one already 1157 // this block can be reached on observing either a new card or one already
1158 // stored locally. We will offer to upload either kind. 1158 // stored locally. We will offer to upload either kind.
1159 upload_request_ = payments::PaymentsClient::UploadRequestDetails(); 1159 upload_request_ = payments::PaymentsClient::UploadRequestDetails();
1160 upload_request_.card = *imported_credit_card; 1160 upload_request_.card = *imported_credit_card;
1161 1161
1162 // Check for a CVC to determine whether we can prompt the user to upload 1162 // Check for a CVC to determine whether we can prompt the user to upload
1163 // their card. If no CVC is present, do nothing. We could fall back to a 1163 // their card. If no CVC is present, do nothing. We could fall back to a
1164 // local save but we believe that sometimes offering upload and sometimes 1164 // local save but we believe that sometimes offering upload and sometimes
1165 // offering local save is a confusing user experience. 1165 // offering local save is a confusing user experience.
1166 int cvc; 1166 int cvc;
1167 size_t cvc_size =
1168 upload_request_.card.type() == kAmericanExpressCard ? 4 : 3;
Mathieu 2017/01/04 16:37:22 Could you use (or extend) this code? https://cs.c
Moe 2017/01/04 18:07:31 Done.
1167 for (const auto& field : submitted_form) { 1169 for (const auto& field : submitted_form) {
1168 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && 1170 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE &&
1169 base::StringToInt(field->value, &cvc)) { 1171 base::StringToInt(field->value, &cvc) &&
1172 field->value.size() == cvc_size) {
1170 upload_request_.cvc = field->value; 1173 upload_request_.cvc = field->value;
1171 break; 1174 break;
1172 } 1175 }
1173 } 1176 }
1174 if (upload_request_.cvc.empty()) { 1177 if (upload_request_.cvc.empty()) {
1175 AutofillMetrics::LogCardUploadDecisionMetric( 1178 AutofillMetrics::LogCardUploadDecisionMetric(
1176 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 1179 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
1177 CollectRapportSample(submitted_form.source_url(), 1180 CollectRapportSample(submitted_form.source_url(),
1178 "Autofill.CardUploadNotOfferedNoCvc"); 1181 "Autofill.CardUploadNotOfferedNoCvc");
1179 return; 1182 return;
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 if (i > 0) 2140 if (i > 0)
2138 fputs("Next oldest form:\n", file); 2141 fputs("Next oldest form:\n", file);
2139 } 2142 }
2140 fputs("\n", file); 2143 fputs("\n", file);
2141 2144
2142 fclose(file); 2145 fclose(file);
2143 } 2146 }
2144 #endif // ENABLE_FORM_DEBUG_DUMP 2147 #endif // ENABLE_FORM_DEBUG_DUMP
2145 2148
2146 } // namespace autofill 2149 } // namespace autofill
OLDNEW
« 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