| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (trimmed_values.size() == 12) { | 207 if (trimmed_values.size() == 12) { |
| 208 // The select presumable only contains the year's months. | 208 // The select presumable only contains the year's months. |
| 209 // If the first value of the select is 0, decrement the value of |month| so | 209 // If the first value of the select is 0, decrement the value of |month| so |
| 210 // January is associated with 0 instead of 1. | 210 // January is associated with 0 instead of 1. |
| 211 int first_value; | 211 int first_value; |
| 212 if (StringToInt(trimmed_values[0], &first_value) && first_value == 0) | 212 if (StringToInt(trimmed_values[0], &first_value) && first_value == 0) |
| 213 --month; | 213 --month; |
| 214 } else if (trimmed_values.size() == 13) { | 214 } else if (trimmed_values.size() == 13) { |
| 215 // The select presumably uses the first value as a placeholder. | 215 // The select presumably uses the first value as a placeholder. |
| 216 int first_value; | 216 int first_value; |
| 217 // If the first value is not a number. Check the second value and apply the | 217 // If the first value is not a number or is a negative one, check the second |
| 218 // same logic as if there was no placeholder. | 218 // value and apply the same logic as if there was no placeholder. |
| 219 if (!StringToInt(trimmed_values[0], &first_value)) { | 219 if (!StringToInt(trimmed_values[0], &first_value) || first_value < 0) { |
| 220 int second_value; | 220 int second_value; |
| 221 if (StringToInt(trimmed_values[1], &second_value) && second_value == 0) | 221 if (StringToInt(trimmed_values[1], &second_value) && second_value == 0) |
| 222 --month; | 222 --month; |
| 223 } else if (first_value == 1) { | 223 } else if (first_value == 1) { |
| 224 // If the first value of the select is 1, increment the value of |month| | 224 // If the first value of the select is 1, increment the value of |month| |
| 225 // to skip the placeholder value (January = 2). | 225 // to skip the placeholder value (January = 2). |
| 226 ++month; | 226 ++month; |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 } | 645 } |
| 646 return best_match; | 646 return best_match; |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool AutofillField::IsCreditCardPrediction() const { | 649 bool AutofillField::IsCreditCardPrediction() const { |
| 650 return AutofillType(server_type_).group() == CREDIT_CARD || | 650 return AutofillType(server_type_).group() == CREDIT_CARD || |
| 651 AutofillType(heuristic_type_).group() == CREDIT_CARD; | 651 AutofillType(heuristic_type_).group() == CREDIT_CARD; |
| 652 } | 652 } |
| 653 | 653 |
| 654 } // namespace autofill | 654 } // namespace autofill |
| OLD | NEW |