| 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, |
| 342 delegate_->IsMinimalAddressAccepted()); |
| 343 request_dict.SetBoolean(kPhoneNumberRequired, |
| 344 delegate_->IsPhoneNumberRequired()); |
| 345 |
| 338 request_dict.SetString(kSelectedInstrumentIdKey, | 346 request_dict.SetString(kSelectedInstrumentIdKey, |
| 339 full_wallet_request.instrument_id); | 347 full_wallet_request.instrument_id); |
| 340 request_dict.SetString(kSelectedAddressIdKey, full_wallet_request.address_id); | 348 request_dict.SetString(kSelectedAddressIdKey, full_wallet_request.address_id); |
| 341 request_dict.SetString( | 349 request_dict.SetString( |
| 342 kMerchantDomainKey, | 350 kMerchantDomainKey, |
| 343 full_wallet_request.source_url.GetWithEmptyPath().spec()); | 351 full_wallet_request.source_url.GetWithEmptyPath().spec()); |
| 344 request_dict.SetString(kGoogleTransactionIdKey, | 352 request_dict.SetString(kGoogleTransactionIdKey, |
| 345 full_wallet_request.google_transaction_id); | 353 full_wallet_request.google_transaction_id); |
| 346 request_dict.SetString(kFeatureKey, | 354 request_dict.SetString(kFeatureKey, |
| 347 DialogTypeToFeatureString(delegate_->GetDialogType())); | 355 DialogTypeToFeatureString(delegate_->GetDialogType())); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } | 395 } |
| 388 | 396 |
| 389 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 397 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 390 request_type_ = SAVE_TO_WALLET; | 398 request_type_ = SAVE_TO_WALLET; |
| 391 | 399 |
| 392 base::DictionaryValue request_dict; | 400 base::DictionaryValue request_dict; |
| 393 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); | 401 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); |
| 394 request_dict.SetString(kRiskParamsKey, delegate_->GetRiskData()); | 402 request_dict.SetString(kRiskParamsKey, delegate_->GetRiskData()); |
| 395 request_dict.SetString(kMerchantDomainKey, | 403 request_dict.SetString(kMerchantDomainKey, |
| 396 source_url.GetWithEmptyPath().spec()); | 404 source_url.GetWithEmptyPath().spec()); |
| 405 request_dict.SetBoolean(kUseMinimalAddresses, |
| 406 delegate_->IsMinimalAddressAccepted()); |
| 407 request_dict.SetBoolean(kPhoneNumberRequired, |
| 408 delegate_->IsPhoneNumberRequired()); |
| 397 | 409 |
| 398 std::string primary_account_number; | 410 std::string primary_account_number; |
| 399 std::string card_verification_number; | 411 std::string card_verification_number; |
| 400 if (instrument) { | 412 if (instrument) { |
| 401 primary_account_number = net::EscapeUrlEncodedData( | 413 primary_account_number = net::EscapeUrlEncodedData( |
| 402 UTF16ToUTF8(instrument->primary_account_number()), true); | 414 UTF16ToUTF8(instrument->primary_account_number()), true); |
| 403 card_verification_number = net::EscapeUrlEncodedData( | 415 card_verification_number = net::EscapeUrlEncodedData( |
| 404 UTF16ToUTF8(instrument->card_verification_number()), true); | 416 UTF16ToUTF8(instrument->card_verification_number()), true); |
| 405 | 417 |
| 406 if (instrument->object_id().empty()) { | 418 if (instrument->object_id().empty()) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 return; | 486 return; |
| 475 } | 487 } |
| 476 | 488 |
| 477 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 489 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 478 request_type_ = GET_WALLET_ITEMS; | 490 request_type_ = GET_WALLET_ITEMS; |
| 479 | 491 |
| 480 base::DictionaryValue request_dict; | 492 base::DictionaryValue request_dict; |
| 481 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); | 493 request_dict.SetString(kApiKeyKey, google_apis::GetAPIKey()); |
| 482 request_dict.SetString(kMerchantDomainKey, | 494 request_dict.SetString(kMerchantDomainKey, |
| 483 source_url.GetWithEmptyPath().spec()); | 495 source_url.GetWithEmptyPath().spec()); |
| 496 request_dict.SetBoolean(kShippingAddressRequired, |
| 497 delegate_->IsShippingAddressRequired()); |
| 498 request_dict.SetBoolean(kUseMinimalAddresses, |
| 499 delegate_->IsMinimalAddressAccepted()); |
| 500 request_dict.SetBoolean(kPhoneNumberRequired, |
| 501 delegate_->IsPhoneNumberRequired()); |
| 484 | 502 |
| 485 std::string post_body; | 503 std::string post_body; |
| 486 base::JSONWriter::Write(&request_dict, &post_body); | 504 base::JSONWriter::Write(&request_dict, &post_body); |
| 487 | 505 |
| 488 MakeWalletRequest(GetGetWalletItemsUrl(), post_body, kJsonMimeType); | 506 MakeWalletRequest(GetGetWalletItemsUrl(), post_body, kJsonMimeType); |
| 489 } | 507 } |
| 490 | 508 |
| 491 void WalletClient::SendAutocheckoutStatus( | 509 void WalletClient::SendAutocheckoutStatus( |
| 492 AutocheckoutStatus status, | 510 AutocheckoutStatus status, |
| 493 const GURL& source_url, | 511 const GURL& source_url, |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 NOTREACHED(); | 851 NOTREACHED(); |
| 834 return AutofillMetrics::UNKNOWN_API_CALL; | 852 return AutofillMetrics::UNKNOWN_API_CALL; |
| 835 } | 853 } |
| 836 | 854 |
| 837 NOTREACHED(); | 855 NOTREACHED(); |
| 838 return AutofillMetrics::UNKNOWN_API_CALL; | 856 return AutofillMetrics::UNKNOWN_API_CALL; |
| 839 } | 857 } |
| 840 | 858 |
| 841 } // namespace wallet | 859 } // namespace wallet |
| 842 } // namespace autofill | 860 } // namespace autofill |
| OLD | NEW |