| 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_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/string_search.h" | 10 #include "base/i18n/string_search.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 if (trimmed_values.size() == 12) { | 218 if (trimmed_values.size() == 12) { |
| 219 // The select presumable only contains the year's months. | 219 // The select presumable only contains the year's months. |
| 220 // If the first value of the select is 0, decrement the value of |month| so | 220 // If the first value of the select is 0, decrement the value of |month| so |
| 221 // January is associated with 0 instead of 1. | 221 // January is associated with 0 instead of 1. |
| 222 int first_value; | 222 int first_value; |
| 223 if (StringToInt(trimmed_values[0], &first_value) && first_value == 0) | 223 if (StringToInt(trimmed_values[0], &first_value) && first_value == 0) |
| 224 --month; | 224 --month; |
| 225 } else if (trimmed_values.size() == 13) { | 225 } else if (trimmed_values.size() == 13) { |
| 226 // The select presumably uses the first value as a placeholder. | 226 // The select presumably uses the first value as a placeholder. |
| 227 // If the first value of the select is 1, increment the value of |month| to | |
| 228 // skip the placeholder value (January = 2). | |
| 229 int first_value; | 227 int first_value; |
| 230 if (StringToInt(trimmed_values[0], &first_value) && first_value == 1) | 228 // If the first value is not a number. Check the second value and apply the |
| 229 // same logic as if there was no placeholder. |
| 230 if (!StringToInt(trimmed_values[0], &first_value)) { |
| 231 int second_value; |
| 232 if (StringToInt(trimmed_values[1], &second_value) && second_value == 0) |
| 233 --month; |
| 234 } else if (first_value == 1) { |
| 235 // If the first value of the select is 1, increment the value of |month| |
| 236 // to skip the placeholder value (January = 2). |
| 231 ++month; | 237 ++month; |
| 238 } |
| 232 } | 239 } |
| 233 | 240 |
| 234 // Attempt to match the user's |month| with the field's value attributes. | 241 // Attempt to match the user's |month| with the field's value attributes. |
| 235 for (size_t i = 0; i < trimmed_values.size(); ++i) { | 242 for (size_t i = 0; i < trimmed_values.size(); ++i) { |
| 236 int converted_value = 0; | 243 int converted_value = 0; |
| 237 // We use the trimmed value to match with |month|, but the original select | 244 // We use the trimmed value to match with |month|, but the original select |
| 238 // value to fill the field (otherwise filling wouldn't work). | 245 // value to fill the field (otherwise filling wouldn't work). |
| 239 if (CreditCard::ConvertMonth(trimmed_values[i], app_locale, | 246 if (CreditCard::ConvertMonth(trimmed_values[i], app_locale, |
| 240 &converted_value) && | 247 &converted_value) && |
| 241 month == converted_value) { | 248 month == converted_value) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 } | 643 } |
| 637 return false; | 644 return false; |
| 638 } | 645 } |
| 639 | 646 |
| 640 bool AutofillField::IsCreditCardPrediction() const { | 647 bool AutofillField::IsCreditCardPrediction() const { |
| 641 return AutofillType(server_type_).group() == CREDIT_CARD || | 648 return AutofillType(server_type_).group() == CREDIT_CARD || |
| 642 AutofillType(heuristic_type_).group() == CREDIT_CARD; | 649 AutofillType(heuristic_type_).group() == CREDIT_CARD; |
| 643 } | 650 } |
| 644 | 651 |
| 645 } // namespace autofill | 652 } // namespace autofill |
| OLD | NEW |