Chromium Code Reviews| 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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |