diff options
author | ahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 20:24:10 +0000 |
---|---|---|
committer | ahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 20:24:10 +0000 |
commit | ffc0659d3e0c3674c3738630557c6c4545ace370 (patch) | |
tree | 0682687bf4ad7c83157fdb94a1ded067fab3837a /components/autofill/browser/wallet/wallet_client.cc | |
parent | 4ccf5c3cd566b0a313e60320fd87e61f1899f4c8 (diff) | |
download | chromium_src-ffc0659d3e0c3674c3738630557c6c4545ace370.zip chromium_src-ffc0659d3e0c3674c3738630557c6c4545ace370.tar.gz chromium_src-ffc0659d3e0c3674c3738630557c6c4545ace370.tar.bz2 |
Implement UpdateAddress API call for Online Wallet.
BUG=180148
Review URL: https://chromiumcodereview.appspot.com/12869004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/autofill/browser/wallet/wallet_client.cc')
-rw-r--r-- | components/autofill/browser/wallet/wallet_client.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/components/autofill/browser/wallet/wallet_client.cc b/components/autofill/browser/wallet/wallet_client.cc index 5df8ab4..787c051 100644 --- a/components/autofill/browser/wallet/wallet_client.cc +++ b/components/autofill/browser/wallet/wallet_client.cc @@ -497,6 +497,34 @@ void WalletClient::SendAutocheckoutStatus( MakeWalletRequest(GetSendStatusUrl(), post_body); } +void WalletClient::UpdateAddress(const Address& address, + const GURL& source_url) { + if (HasRequestInProgress()) { + pending_requests_.push(base::Bind(&WalletClient::UpdateAddress, + base::Unretained(this), + address, + source_url)); + return; + } + + DCHECK_EQ(NO_PENDING_REQUEST, request_type_); + request_type_ = UPDATE_ADDRESS; + + base::DictionaryValue request_dict; + request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); + request_dict.SetString(kRiskParamsKey, GetRiskParams()); + request_dict.SetString(kMerchantDomainKey, + source_url.GetWithEmptyPath().spec()); + + request_dict.Set(kShippingAddressKey, + address.ToDictionaryWithID().release()); + + std::string post_body; + base::JSONWriter::Write(&request_dict, &post_body); + + MakeWalletRequest(GetSaveToWalletUrl(), post_body); +} + void WalletClient::UpdateInstrument( const std::string& instrument_id, const Address& billing_address, @@ -719,6 +747,20 @@ void WalletClient::OnURLFetchComplete( break; } + case UPDATE_ADDRESS: { + std::string address_id; + std::vector<RequiredAction> required_actions; + GetRequiredActionsForSaveToWallet(*response_dict, &required_actions); + if (response_dict->GetString(kShippingAddressIdKey, &address_id) || + !required_actions.empty()) { + LogRequiredActions(required_actions); + delegate_->OnDidUpdateAddress(address_id, required_actions); + } else { + HandleMalformedResponse(); + } + break; + } + case UPDATE_INSTRUMENT: { std::string instrument_id; std::vector<RequiredAction> required_actions; |