| OLD | NEW |
| 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/content/browser/wallet/wallet_client.h" | 5 #include "components/autofill/content/browser/wallet/wallet_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const char kFeatureKey[] = "feature"; | 224 const char kFeatureKey[] = "feature"; |
| 225 const char kGoogleTransactionIdKey[] = "google_transaction_id"; | 225 const char kGoogleTransactionIdKey[] = "google_transaction_id"; |
| 226 const char kInstrumentIdKey[] = "instrument_id"; | 226 const char kInstrumentIdKey[] = "instrument_id"; |
| 227 const char kInstrumentKey[] = "instrument"; | 227 const char kInstrumentKey[] = "instrument"; |
| 228 const char kInstrumentEscrowHandleKey[] = "instrument_escrow_handle"; | 228 const char kInstrumentEscrowHandleKey[] = "instrument_escrow_handle"; |
| 229 const char kInstrumentExpMonthKey[] = "instrument.credit_card.exp_month"; | 229 const char kInstrumentExpMonthKey[] = "instrument.credit_card.exp_month"; |
| 230 const char kInstrumentExpYearKey[] = "instrument.credit_card.exp_year"; | 230 const char kInstrumentExpYearKey[] = "instrument.credit_card.exp_year"; |
| 231 const char kInstrumentType[] = "instrument.type"; | 231 const char kInstrumentType[] = "instrument.type"; |
| 232 const char kInstrumentPhoneNumberKey[] = "instrument_phone_number"; | 232 const char kInstrumentPhoneNumberKey[] = "instrument_phone_number"; |
| 233 const char kMerchantDomainKey[] = "merchant_domain"; | 233 const char kMerchantDomainKey[] = "merchant_domain"; |
| 234 const char kPhoneNumberRequired[] = "phone_number_required"; |
| 234 const char kReasonKey[] = "reason"; | 235 const char kReasonKey[] = "reason"; |
| 235 const char kRiskCapabilitiesKey[] = "supported_risk_challenge"; | 236 const char kRiskCapabilitiesKey[] = "supported_risk_challenge"; |
| 236 const char kRiskParamsKey[] = "risk_params"; | 237 const char kRiskParamsKey[] = "risk_params"; |
| 237 const char kSelectedAddressIdKey[] = "selected_address_id"; | 238 const char kSelectedAddressIdKey[] = "selected_address_id"; |
| 238 const char kSelectedInstrumentIdKey[] = "selected_instrument_id"; | 239 const char kSelectedInstrumentIdKey[] = "selected_instrument_id"; |
| 239 const char kSessionMaterialKey[] = "session_material"; | 240 const char kSessionMaterialKey[] = "session_material"; |
| 240 const char kShippingAddressIdKey[] = "shipping_address_id"; | 241 const char kShippingAddressIdKey[] = "shipping_address_id"; |
| 241 const char kShippingAddressKey[] = "shipping_address"; | 242 const char kShippingAddressKey[] = "shipping_address"; |
| 243 const char kShippingAddressRequired[] = "shipping_address_required"; |
| 242 const char kAutocheckoutStepsKey[] = "steps"; | 244 const char kAutocheckoutStepsKey[] = "steps"; |
| 243 const char kSuccessKey[] = "success"; | 245 const char kSuccessKey[] = "success"; |
| 244 const char kUpgradedBillingAddressKey[] = "upgraded_billing_address"; | 246 const char kUpgradedBillingAddressKey[] = "upgraded_billing_address"; |
| 245 const char kUpgradedInstrumentIdKey[] = "upgraded_instrument_id"; | 247 const char kUpgradedInstrumentIdKey[] = "upgraded_instrument_id"; |
| 248 const char kUseMinimalAddresses[] = "use_minimal_addresses"; |
| 246 | 249 |
| 247 } // namespace | 250 } // namespace |
| 248 | 251 |
| 249 WalletClient::FullWalletRequest::FullWalletRequest( | 252 WalletClient::FullWalletRequest::FullWalletRequest( |
| 250 const std::string& instrument_id, | 253 const std::string& instrument_id, |
| 251 const std::string& address_id, | 254 const std::string& address_id, |
| 252 const GURL& source_url, | 255 const GURL& source_url, |
| 253 const std::string& google_transaction_id, | 256 const std::string& google_transaction_id, |
| 254 const std::vector<RiskCapability> risk_capabilities) | 257 const std::vector<RiskCapability> risk_capabilities) |
| 255 : instrument_id(instrument_id), | 258 : instrument_id(instrument_id), |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 full_wallet_request)); | 331 full_wallet_request)); |
| 329 return; | 332 return; |
| 330 } | 333 } |
| 331 | 334 |
| 332 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 335 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 333 request_type_ = GET_FULL_WALLET; | 336 request_type_ = GET_FULL_WALLET; |
| 334 | 337 |
| 335 base::DictionaryValue request_dict; | 338 base::DictionaryValue request_dict; |
| 336 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); | 339 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); |
| 337 request_dict.SetString(kRiskParamsKey, delegate_->GetRiskData()); | 340 request_dict.SetString(kRiskParamsKey, delegate_->GetRiskData()); |
| 341 request_dict.SetBoolean(kUseMinimalAddresses, false); |
| 342 request_dict.SetBoolean(kPhoneNumberRequired, true); |
| 343 |
| 338 request_dict.SetString(kSelectedInstrumentIdKey, | 344 request_dict.SetString(kSelectedInstrumentIdKey, |
| 339 full_wallet_request.instrument_id); | 345 full_wallet_request.instrument_id); |
| 340 request_dict.SetString(kSelectedAddressIdKey, full_wallet_request.address_id); | 346 request_dict.SetString(kSelectedAddressIdKey, full_wallet_request.address_id); |
| 341 request_dict.SetString( | 347 request_dict.SetString( |
| 342 kMerchantDomainKey, | 348 kMerchantDomainKey, |
| 343 full_wallet_request.source_url.GetWithEmptyPath().spec()); | 349 full_wallet_request.source_url.GetWithEmptyPath().spec()); |
| 344 request_dict.SetString(kGoogleTransactionIdKey, | 350 request_dict.SetString(kGoogleTransactionIdKey, |
| 345 full_wallet_request.google_transaction_id); | 351 full_wallet_request.google_transaction_id); |
| 346 request_dict.SetString(kFeatureKey, | 352 request_dict.SetString(kFeatureKey, |
| 347 DialogTypeToFeatureString(delegate_->GetDialogType())); | 353 DialogTypeToFeatureString(delegate_->GetDialogType())); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } | 393 } |
| 388 | 394 |
| 389 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 395 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 390 request_type_ = SAVE_TO_WALLET; | 396 request_type_ = SAVE_TO_WALLET; |
| 391 | 397 |
| 392 base::DictionaryValue request_dict; | 398 base::DictionaryValue request_dict; |
| 393 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); | 399 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); |
| 394 request_dict.SetString(kRiskParamsKey, delegate_->GetRiskData()); | 400 request_dict.SetString(kRiskParamsKey, delegate_->GetRiskData()); |
| 395 request_dict.SetString(kMerchantDomainKey, | 401 request_dict.SetString(kMerchantDomainKey, |
| 396 source_url.GetWithEmptyPath().spec()); | 402 source_url.GetWithEmptyPath().spec()); |
| 403 request_dict.SetBoolean(kUseMinimalAddresses, false); |
| 404 request_dict.SetBoolean(kPhoneNumberRequired, true); |
| 397 | 405 |
| 398 std::string primary_account_number; | 406 std::string primary_account_number; |
| 399 std::string card_verification_number; | 407 std::string card_verification_number; |
| 400 if (instrument) { | 408 if (instrument) { |
| 401 primary_account_number = net::EscapeUrlEncodedData( | 409 primary_account_number = net::EscapeUrlEncodedData( |
| 402 UTF16ToUTF8(instrument->primary_account_number()), true); | 410 UTF16ToUTF8(instrument->primary_account_number()), true); |
| 403 card_verification_number = net::EscapeUrlEncodedData( | 411 card_verification_number = net::EscapeUrlEncodedData( |
| 404 UTF16ToUTF8(instrument->card_verification_number()), true); | 412 UTF16ToUTF8(instrument->card_verification_number()), true); |
| 405 | 413 |
| 406 if (instrument->object_id().empty()) { | 414 if (instrument->object_id().empty()) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 return; | 482 return; |
| 475 } | 483 } |
| 476 | 484 |
| 477 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 485 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 478 request_type_ = GET_WALLET_ITEMS; | 486 request_type_ = GET_WALLET_ITEMS; |
| 479 | 487 |
| 480 base::DictionaryValue request_dict; | 488 base::DictionaryValue request_dict; |
| 481 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); | 489 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); |
| 482 request_dict.SetString(kMerchantDomainKey, | 490 request_dict.SetString(kMerchantDomainKey, |
| 483 source_url.GetWithEmptyPath().spec()); | 491 source_url.GetWithEmptyPath().spec()); |
| 492 request_dict.SetBoolean(kShippingAddressRequired, |
| 493 delegate_->IsShippingAddressRequired()); |
| 494 request_dict.SetBoolean(kUseMinimalAddresses, false); |
| 495 request_dict.SetBoolean(kPhoneNumberRequired, true); |
| 484 | 496 |
| 485 std::string post_body; | 497 std::string post_body; |
| 486 base::JSONWriter::Write(&request_dict, &post_body); | 498 base::JSONWriter::Write(&request_dict, &post_body); |
| 487 | 499 |
| 488 MakeWalletRequest(GetGetWalletItemsUrl(), post_body, kJsonMimeType); | 500 MakeWalletRequest(GetGetWalletItemsUrl(), post_body, kJsonMimeType); |
| 489 } | 501 } |
| 490 | 502 |
| 491 void WalletClient::SendAutocheckoutStatus( | 503 void WalletClient::SendAutocheckoutStatus( |
| 492 AutocheckoutStatus status, | 504 AutocheckoutStatus status, |
| 493 const GURL& source_url, | 505 const GURL& source_url, |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 NOTREACHED(); | 845 NOTREACHED(); |
| 834 return AutofillMetrics::UNKNOWN_API_CALL; | 846 return AutofillMetrics::UNKNOWN_API_CALL; |
| 835 } | 847 } |
| 836 | 848 |
| 837 NOTREACHED(); | 849 NOTREACHED(); |
| 838 return AutofillMetrics::UNKNOWN_API_CALL; | 850 return AutofillMetrics::UNKNOWN_API_CALL; |
| 839 } | 851 } |
| 840 | 852 |
| 841 } // namespace wallet | 853 } // namespace wallet |
| 842 } // namespace autofill | 854 } // namespace autofill |
| OLD | NEW |