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

Unified Diff: components/autofill/content/browser/wallet/wallet_client.cc

Issue 100743006: Fix DCHECK() when updating instruments with no phone number. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dcheck Created 7 years 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/content/browser/wallet/wallet_client.cc
diff --git a/components/autofill/content/browser/wallet/wallet_client.cc b/components/autofill/content/browser/wallet/wallet_client.cc
index 30fd6186abc7d722691239ed852b332db559d0f7..cc5c23aca5a4a12717102bc2811d723993d07040 100644
--- a/components/autofill/content/browser/wallet/wallet_client.cc
+++ b/components/autofill/content/browser/wallet/wallet_client.cc
@@ -372,14 +372,19 @@ void WalletClient::GetFullWallet(const FullWalletRequest& full_wallet_request) {
kFormEncodedMimeType);
}
-void WalletClient::SaveToWallet(scoped_ptr<Instrument> instrument,
- scoped_ptr<Address> address) {
+void WalletClient::SaveToWallet(
+ scoped_ptr<Instrument> instrument,
+ scoped_ptr<Address> address,
+ const WalletItems::MaskedInstrument* server_instrument,
+ const Address* server_address) {
DCHECK(instrument || address);
if (HasRequestInProgress()) {
pending_requests_.push(base::Bind(&WalletClient::SaveToWallet,
base::Unretained(this),
base::Passed(&instrument),
- base::Passed(&address)));
+ base::Passed(&address),
+ base::Unretained(server_instrument),
Evan Stade 2013/12/12 02:33:57 this is no bueno... you need to make a copy (add a
Dan Beam 2013/12/13 04:06:24 did option 2 and updated all the other methods
+ base::Unretained(server_address)));
return;
}
@@ -402,17 +407,23 @@ void WalletClient::SaveToWallet(scoped_ptr<Instrument> instrument,
card_verification_number = net::EscapeUrlEncodedData(
UTF16ToUTF8(instrument->card_verification_number()), true);
- if (instrument->object_id().empty()) {
+ if (!server_instrument) {
request_dict.Set(kInstrumentKey, instrument->ToDictionary().release());
request_dict.SetString(kInstrumentPhoneNumberKey,
instrument->address()->phone_number());
} else {
- DCHECK(instrument->address() ||
- (instrument->expiration_month() > 0 &&
- instrument->expiration_year() > 0));
+ DCHECK(!server_instrument->object_id().empty());
+
+ int new_month = instrument->expiration_month();
+ int new_year = instrument->expiration_year();
+ bool expiration_differs_from_server =
Evan Stade 2013/12/12 02:33:57 nit: expiration_date_changed
Dan Beam 2013/12/13 04:06:24 Done.
+ new_month != server_instrument->expiration_month() ||
+ new_year != server_instrument->expiration_year();
+
+ DCHECK(instrument->address() || expiration_differs_from_server);
request_dict.SetString(kUpgradedInstrumentIdKey,
- instrument->object_id());
+ server_instrument->object_id());
if (instrument->address()) {
request_dict.SetString(kInstrumentPhoneNumberKey,
@@ -422,8 +433,8 @@ void WalletClient::SaveToWallet(scoped_ptr<Instrument> instrument,
instrument->address()->ToDictionaryWithoutID().release());
}
- if (instrument->expiration_month() > 0 &&
- instrument->expiration_year() > 0) {
+ if (expiration_differs_from_server) {
+ // Updating expiration date requires a CVC.
DCHECK(!instrument->card_verification_number().empty());
request_dict.SetInteger(kInstrumentExpMonthKey,
instrument->expiration_month());
@@ -436,6 +447,10 @@ void WalletClient::SaveToWallet(scoped_ptr<Instrument> instrument,
}
}
if (address) {
+ if (server_address) {
+ address->set_object_id(server_address->object_id());
+ DCHECK(!address->object_id().empty());
+ }
request_dict.Set(kShippingAddressKey,
address->ToDictionaryWithID().release());
}

Powered by Google App Engine
This is Rietveld 408576698