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

Unified Diff: components/autofill/core/browser/payments/full_card_request.cc

Issue 2454453002: [Payments] Update expired card expiration after unmask. (Closed)
Patch Set: Created 4 years, 2 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/payments/full_card_request.cc
diff --git a/components/autofill/core/browser/payments/full_card_request.cc b/components/autofill/core/browser/payments/full_card_request.cc
index 63ee15457240b3616f503594a3c31d2bcbe1f7dd..bd685ff70b9d8d982e3ec852c60ba34e9893923b 100644
--- a/components/autofill/core/browser/payments/full_card_request.cc
+++ b/components/autofill/core/browser/payments/full_card_request.cc
@@ -70,16 +70,34 @@ bool FullCardRequest::IsGettingFullCard() const {
// TODO(crbug.com/656981): Update the credit card expiration on file.
please use gerrit instead 2016/10/26 15:23:04 Remove the todo
sebsg 2016/10/26 17:17:32 Done.
void FullCardRequest::OnUnmaskResponse(const UnmaskResponse& response) {
- if (!response.exp_month.empty())
- request_->card.SetRawInfo(CREDIT_CARD_EXP_MONTH, response.exp_month);
+ if (request_->card.record_type() == CreditCard::LOCAL_CARD) {
+ // It's a local card. Update the cached version and update the database.
+ // Then update the response.
+ CreditCard* credit_card =
+ personal_data_manager_->GetCreditCardByGUID(request_->card.guid());
- if (!response.exp_year.empty())
- request_->card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, response.exp_year);
+ if (!response.exp_month.empty())
+ credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, response.exp_month);
- if (request_->card.record_type() == CreditCard::LOCAL_CARD &&
- !request_->card.guid().empty() &&
- (!response.exp_month.empty() || !response.exp_year.empty())) {
- personal_data_manager_->UpdateCreditCard(request_->card);
+ if (!response.exp_year.empty())
+ credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, response.exp_year);
+
+ // Update the cached card here so the new data is availble before the
+ // database update and refresh of the cache is completed.
+ if (!response.exp_month.empty() || !response.exp_year.empty()) {
+ personal_data_manager_->UpdateCreditCard(*credit_card);
please use gerrit instead 2016/10/26 15:23:04 Can we update the cache inside of UpdateCreditCard
sebsg 2016/10/26 17:17:32 Done.
+
+ request_->card = *credit_card;
+ }
+ } else {
+ // It's not a local card, update the response.
+ if (!response.exp_month.empty())
+ request_->card.SetRawInfo(CREDIT_CARD_EXP_MONTH, response.exp_month);
+
+ if (!response.exp_year.empty()) {
+ request_->card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR,
+ response.exp_year);
+ }
}
if (!should_unmask_card_) {

Powered by Google App Engine
This is Rietveld 408576698