Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: components/autofill/core/browser/autofill_field.cc

Issue 1839763008: [Autofill] Correctly fill month selects where the first value is negative. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_field_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698