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

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

Issue 1885773002: [Autofill] Don't fill expiration date of expired credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit 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
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_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (is_credit_card) { 167 if (is_credit_card) {
168 new_types->insert(CREDIT_CARD_NAME_FULL); 168 new_types->insert(CREDIT_CARD_NAME_FULL);
169 } else { 169 } else {
170 new_types->insert(NAME_FULL); 170 new_types->insert(NAME_FULL);
171 } 171 }
172 } else { 172 } else {
173 *new_types = old_types; 173 *new_types = old_types;
174 } 174 }
175 } 175 }
176 176
177 bool IsCreditCardExpirationType(ServerFieldType type) {
178 return type == CREDIT_CARD_EXP_MONTH ||
179 type == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
180 type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
181 type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR ||
182 type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR;
183 }
184
177 } // namespace 185 } // namespace
178 186
179 AutofillManager::AutofillManager( 187 AutofillManager::AutofillManager(
180 AutofillDriver* driver, 188 AutofillDriver* driver,
181 AutofillClient* client, 189 AutofillClient* client,
182 const std::string& app_locale, 190 const std::string& app_locale,
183 AutofillDownloadManagerState enable_download_manager) 191 AutofillDownloadManagerState enable_download_manager)
184 : driver_(driver), 192 : driver_(driver),
185 client_(client), 193 client_(client),
186 payments_client_( 194 payments_client_(
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1451
1444 base::string16 value = 1452 base::string16 value =
1445 data_model.GetInfo(cached_field->Type(), app_locale_); 1453 data_model.GetInfo(cached_field->Type(), app_locale_);
1446 if (is_credit_card && 1454 if (is_credit_card &&
1447 cached_field->Type().GetStorableType() == 1455 cached_field->Type().GetStorableType() ==
1448 CREDIT_CARD_VERIFICATION_CODE) { 1456 CREDIT_CARD_VERIFICATION_CODE) {
1449 // If this is |unmask_request_.card|, |unmask_request_.user_response.cvc| 1457 // If this is |unmask_request_.card|, |unmask_request_.user_response.cvc|
1450 // should be non-empty and vice versa. 1458 // should be non-empty and vice versa.
1451 value = unmask_request_.user_response.cvc; 1459 value = unmask_request_.user_response.cvc;
1452 DCHECK_EQ(&unmask_request_.card == &data_model, !value.empty()); 1460 DCHECK_EQ(&unmask_request_.card == &data_model, !value.empty());
1461 } else if (is_credit_card && IsCreditCardExpirationType(
1462 cached_field->Type().GetStorableType()) &&
1463 static_cast<const CreditCard*>(&data_model)
1464 ->IsExpired(base::Time::Now())) {
1465 // Don't fill expired cards expiration date.
1466 value = base::string16();
1453 } 1467 }
1454 1468
1455 // Must match ForEachMatchingFormField() in form_autofill_util.cc. 1469 // Must match ForEachMatchingFormField() in form_autofill_util.cc.
1456 // Only notify autofilling of empty fields and the field that initiated 1470 // Only notify autofilling of empty fields and the field that initiated
1457 // the filling (note that "select-one" controls may not be empty but will 1471 // the filling (note that "select-one" controls may not be empty but will
1458 // still be autofilled). 1472 // still be autofilled).
1459 bool should_notify = 1473 bool should_notify =
1460 !is_credit_card && 1474 !is_credit_card &&
1461 !value.empty() && 1475 !value.empty() &&
1462 (result.fields[i].SameFieldAs(field) || 1476 (result.fields[i].SameFieldAs(field) ||
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 if (i > 0) 2012 if (i > 0)
1999 fputs("Next oldest form:\n", file); 2013 fputs("Next oldest form:\n", file);
2000 } 2014 }
2001 fputs("\n", file); 2015 fputs("\n", file);
2002 2016
2003 fclose(file); 2017 fclose(file);
2004 } 2018 }
2005 #endif // ENABLE_FORM_DEBUG_DUMP 2019 #endif // ENABLE_FORM_DEBUG_DUMP
2006 2020
2007 } // namespace autofill 2021 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698