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

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

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Added DCHECK Created 3 years, 10 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
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/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 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/autofill/core/browser/autofill_field.h" 18 #include "components/autofill/core/browser/autofill_field.h"
19 #include "components/autofill/core/browser/autofill_regex_constants.h" 19 #include "components/autofill/core/browser/autofill_regex_constants.h"
20 #include "components/autofill/core/browser/autofill_scanner.h" 20 #include "components/autofill/core/browser/autofill_scanner.h"
21 #include "components/autofill/core/browser/field_types.h" 21 #include "components/autofill/core/browser/field_types.h"
22 #include "components/autofill/core/common/autofill_clock.h"
22 #include "components/autofill/core/common/autofill_regexes.h" 23 #include "components/autofill/core/common/autofill_regexes.h"
23 #include "grit/components_strings.h" 24 #include "grit/components_strings.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 26
26 namespace autofill { 27 namespace autofill {
27 28
28 namespace { 29 namespace {
29 30
30 // Credit card numbers are at most 19 digits in length. 31 // Credit card numbers are at most 19 digits in length.
31 // [Ref: http://en.wikipedia.org/wiki/Bank_card_number] 32 // [Ref: http://en.wikipedia.org/wiki/Bank_card_number]
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 279
279 // static 280 // static
280 bool CreditCardField::LikelyCardYearSelectField(AutofillScanner* scanner) { 281 bool CreditCardField::LikelyCardYearSelectField(AutofillScanner* scanner) {
281 if (scanner->IsEnd()) 282 if (scanner->IsEnd())
282 return false; 283 return false;
283 284
284 AutofillField* field = scanner->Cursor(); 285 AutofillField* field = scanner->Cursor();
285 if (!MatchesFormControlType(field->form_control_type, MATCH_SELECT)) 286 if (!MatchesFormControlType(field->form_control_type, MATCH_SELECT))
286 return false; 287 return false;
287 288
288 const base::Time time_now = base::Time::Now(); 289 const base::Time time_now = AutofillClock::Now();
289 base::Time::Exploded time_exploded; 290 base::Time::Exploded time_exploded;
290 time_now.UTCExplode(&time_exploded); 291 time_now.UTCExplode(&time_exploded);
291 292
292 const int kYearsToMatch = 3; 293 const int kYearsToMatch = 3;
293 std::vector<base::string16> years_to_check; 294 std::vector<base::string16> years_to_check;
294 for (int year = time_exploded.year; 295 for (int year = time_exploded.year;
295 year < time_exploded.year + kYearsToMatch; 296 year < time_exploded.year + kYearsToMatch;
296 ++year) { 297 ++year) {
297 years_to_check.push_back(base::IntToString16(year)); 298 years_to_check.push_back(base::IntToString16(year));
298 } 299 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 : ((expiration_year_ && expiration_year_->max_length == 2) 507 : ((expiration_year_ && expiration_year_->max_length == 2)
507 ? CREDIT_CARD_EXP_2_DIGIT_YEAR 508 ? CREDIT_CARD_EXP_2_DIGIT_YEAR
508 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); 509 : CREDIT_CARD_EXP_4_DIGIT_YEAR));
509 } 510 }
510 511
511 bool CreditCardField::HasExpiration() const { 512 bool CreditCardField::HasExpiration() const {
512 return expiration_date_ || (expiration_month_ && expiration_year_); 513 return expiration_date_ || (expiration_month_ && expiration_year_);
513 } 514 }
514 515
515 } // namespace autofill 516 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | components/autofill/core/browser/payments/full_card_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698