| 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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 "dump-autofill-data"); | 1116 "dump-autofill-data"); |
| 1117 | 1117 |
| 1118 // Save the form data for future dumping. | 1118 // Save the form data for future dumping. |
| 1119 if (dump_data) { | 1119 if (dump_data) { |
| 1120 if (recently_autofilled_forms_.size() > 5) | 1120 if (recently_autofilled_forms_.size() > 5) |
| 1121 recently_autofilled_forms_.erase(recently_autofilled_forms_.begin()); | 1121 recently_autofilled_forms_.erase(recently_autofilled_forms_.begin()); |
| 1122 | 1122 |
| 1123 recently_autofilled_forms_.push_back( | 1123 recently_autofilled_forms_.push_back( |
| 1124 std::map<std::string, base::string16>()); | 1124 std::map<std::string, base::string16>()); |
| 1125 auto& map = recently_autofilled_forms_.back(); | 1125 auto& map = recently_autofilled_forms_.back(); |
| 1126 for (const auto* field : submitted_form) { | 1126 for (const auto& field : submitted_form) { |
| 1127 AutofillType type = field->Type(); | 1127 AutofillType type = field->Type(); |
| 1128 // Even though this is for development only, mask full credit card #'s. | 1128 // Even though this is for development only, mask full credit card #'s. |
| 1129 if (type.GetStorableType() == CREDIT_CARD_NUMBER && | 1129 if (type.GetStorableType() == CREDIT_CARD_NUMBER && |
| 1130 field->value.size() > 4) { | 1130 field->value.size() > 4) { |
| 1131 map[type.ToString()] = base::ASCIIToUTF16("...(omitted)...") + | 1131 map[type.ToString()] = base::ASCIIToUTF16("...(omitted)...") + |
| 1132 field->value.substr(field->value.size() - 4, 4); | 1132 field->value.substr(field->value.size() - 4, 4); |
| 1133 } else { | 1133 } else { |
| 1134 map[type.ToString()] = field->value; | 1134 map[type.ToString()] = field->value; |
| 1135 } | 1135 } |
| 1136 } | 1136 } |
| (...skipping 20 matching lines...) Expand all 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 for (const AutofillField* field : submitted_form) { | 1167 for (const auto& field : submitted_form) { |
| 1168 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && | 1168 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && |
| 1169 base::StringToInt(field->value, &cvc)) { | 1169 base::StringToInt(field->value, &cvc)) { |
| 1170 upload_request_.cvc = field->value; | 1170 upload_request_.cvc = field->value; |
| 1171 break; | 1171 break; |
| 1172 } | 1172 } |
| 1173 } | 1173 } |
| 1174 if (upload_request_.cvc.empty()) { | 1174 if (upload_request_.cvc.empty()) { |
| 1175 AutofillMetrics::LogCardUploadDecisionMetric( | 1175 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1176 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1176 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1177 CollectRapportSample(submitted_form.source_url(), | 1177 CollectRapportSample(submitted_form.source_url(), |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 // necessary. | 1673 // necessary. |
| 1674 if (!UpdateCachedForm(form, *form_structure, form_structure)) | 1674 if (!UpdateCachedForm(form, *form_structure, form_structure)) |
| 1675 return false; | 1675 return false; |
| 1676 | 1676 |
| 1677 // No data to return if there are no auto-fillable fields. | 1677 // No data to return if there are no auto-fillable fields. |
| 1678 if (!(*form_structure)->autofill_count()) | 1678 if (!(*form_structure)->autofill_count()) |
| 1679 return false; | 1679 return false; |
| 1680 | 1680 |
| 1681 // Find the AutofillField that corresponds to |field|. | 1681 // Find the AutofillField that corresponds to |field|. |
| 1682 *autofill_field = NULL; | 1682 *autofill_field = NULL; |
| 1683 for (AutofillField* current : **form_structure) { | 1683 for (const auto& current : **form_structure) { |
| 1684 if (current->SameFieldAs(field)) { | 1684 if (current->SameFieldAs(field)) { |
| 1685 *autofill_field = current; | 1685 *autofill_field = current.get(); |
| 1686 break; | 1686 break; |
| 1687 } | 1687 } |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 // Even though we always update the cache, the field might not exist if the | 1690 // Even though we always update the cache, the field might not exist if the |
| 1691 // website disables autocomplete while the user is interacting with the form. | 1691 // website disables autocomplete while the user is interacting with the form. |
| 1692 // See http://crbug.com/160476 | 1692 // See http://crbug.com/160476 |
| 1693 return *autofill_field != NULL; | 1693 return *autofill_field != NULL; |
| 1694 } | 1694 } |
| 1695 | 1695 |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 if (i > 0) | 2137 if (i > 0) |
| 2138 fputs("Next oldest form:\n", file); | 2138 fputs("Next oldest form:\n", file); |
| 2139 } | 2139 } |
| 2140 fputs("\n", file); | 2140 fputs("\n", file); |
| 2141 | 2141 |
| 2142 fclose(file); | 2142 fclose(file); |
| 2143 } | 2143 } |
| 2144 #endif // ENABLE_FORM_DEBUG_DUMP | 2144 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2145 | 2145 |
| 2146 } // namespace autofill | 2146 } // namespace autofill |
| OLD | NEW |