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

Unified Diff: components/autofill/core/browser/validation.cc

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Components Unittests fix Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/validation.cc
diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc
index cbab098922462f26923b3cfa2230f9f614014696..a177b28b36d7b33c51e7c4bcc0854a39b9311147 100644
--- a/components/autofill/core/browser/validation.cc
+++ b/components/autofill/core/browser/validation.cc
@@ -15,6 +15,7 @@
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/autofill_regex_constants.h"
#include "components/autofill/core/browser/credit_card.h"
+#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/state_names.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_regexes.h"
@@ -127,7 +128,8 @@ bool IsValidCreditCardNumberForBasicCardNetworks(
CreditCardCompletionStatus GetCompletionStatusForCard(
const CreditCard& card,
- const std::string& app_locale) {
+ const std::string& app_locale,
+ const std::vector<AutofillProfile*> billing_addresses) {
CreditCardCompletionStatus status = CREDIT_CARD_COMPLETE;
if (card.IsExpired(autofill::AutofillClock::Now()))
status |= CREDIT_CARD_EXPIRED;
@@ -141,6 +143,12 @@ CreditCardCompletionStatus GetCompletionStatusForCard(
status |= CREDIT_CARD_NO_CARDHOLDER;
}
+ if (card.billing_address_id().empty() ||
+ !autofill::PersonalDataManager::GetProfileFromProfilesByGUID(
+ card.billing_address_id(), billing_addresses)) {
+ status |= CREDIT_CARD_NO_BILLING_ADDRESS;
+ }
+
return status;
}
@@ -156,6 +164,9 @@ base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status) {
case CREDIT_CARD_NO_NUMBER:
return l10n_util::GetStringUTF16(
IDS_PAYMENTS_CARD_NUMBER_INVALID_VALIDATION_MESSAGE);
+ case CREDIT_CARD_NO_BILLING_ADDRESS:
+ return l10n_util::GetStringUTF16(
+ IDS_PAYMENTS_CARD_BILLING_ADDRESS_REQUIRED);
default:
// Multiple things are missing
return l10n_util::GetStringUTF16(IDS_PAYMENTS_MORE_INFORMATION_REQUIRED);

Powered by Google App Engine
This is Rietveld 408576698