| 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/credit_card_field.h" | 5 #include "components/autofill/core/browser/credit_card_field.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Note: Some sites use type="tel" or type="number" for numerical inputs. | 129 // Note: Some sites use type="tel" or type="number" for numerical inputs. |
| 130 const int kMatchNumAndTel = MATCH_DEFAULT | MATCH_NUMBER | MATCH_TELEPHONE; | 130 const int kMatchNumAndTel = MATCH_DEFAULT | MATCH_NUMBER | MATCH_TELEPHONE; |
| 131 if (!credit_card_field->verification_ && | 131 if (!credit_card_field->verification_ && |
| 132 ParseFieldSpecifics(scanner, | 132 ParseFieldSpecifics(scanner, |
| 133 base::UTF8ToUTF16(kCardCvcRe), | 133 base::UTF8ToUTF16(kCardCvcRe), |
| 134 kMatchNumAndTel | MATCH_PASSWORD, | 134 kMatchNumAndTel | MATCH_PASSWORD, |
| 135 &credit_card_field->verification_)) { | 135 &credit_card_field->verification_)) { |
| 136 continue; | 136 continue; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // TODO(crbug.com/591816): Make sure parsing cc-numbers of type password |
| 140 // doesn't have bad side effects. |
| 139 AutofillField* current_number_field; | 141 AutofillField* current_number_field; |
| 140 if (ParseFieldSpecifics(scanner, | 142 if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kCardNumberRe), |
| 141 base::UTF8ToUTF16(kCardNumberRe), | 143 kMatchNumAndTel | MATCH_PASSWORD, |
| 142 kMatchNumAndTel, | |
| 143 ¤t_number_field)) { | 144 ¤t_number_field)) { |
| 144 // Avoid autofilling any credit card number field having very low or high | 145 // Avoid autofilling any credit card number field having very low or high |
| 145 // |start_index| on the HTML form. | 146 // |start_index| on the HTML form. |
| 146 size_t start_index = 0; | 147 size_t start_index = 0; |
| 147 if (!credit_card_field->numbers_.empty()) { | 148 if (!credit_card_field->numbers_.empty()) { |
| 148 size_t last_number_field_size = | 149 size_t last_number_field_size = |
| 149 credit_card_field->numbers_.back()->credit_card_number_offset() + | 150 credit_card_field->numbers_.back()->credit_card_number_offset() + |
| 150 credit_card_field->numbers_.back()->max_length; | 151 credit_card_field->numbers_.back()->max_length; |
| 151 | 152 |
| 152 // Distinguish between | 153 // Distinguish between |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 456 |
| 456 ServerFieldType CreditCardField::GetExpirationYearType() const { | 457 ServerFieldType CreditCardField::GetExpirationYearType() const { |
| 457 return (expiration_date_ | 458 return (expiration_date_ |
| 458 ? exp_year_type_ | 459 ? exp_year_type_ |
| 459 : ((expiration_year_ && expiration_year_->max_length == 2) | 460 : ((expiration_year_ && expiration_year_->max_length == 2) |
| 460 ? CREDIT_CARD_EXP_2_DIGIT_YEAR | 461 ? CREDIT_CARD_EXP_2_DIGIT_YEAR |
| 461 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 462 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 462 } | 463 } |
| 463 | 464 |
| 464 } // namespace autofill | 465 } // namespace autofill |
| OLD | NEW |