Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/chrome/browser/payments/payment_request_coordinator.h" | 5 #import "ios/chrome/browser/payments/payment_request_coordinator.h" |
| 6 | 6 |
| 7 #include <unordered_set> | 7 #include <unordered_set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "components/autofill/core/browser/autofill_client.h" | 14 #include "components/autofill/core/browser/autofill_client.h" |
| 15 #include "components/autofill/core/browser/autofill_data_util.h" | 15 #include "components/autofill/core/browser/autofill_data_util.h" |
| 16 #include "components/autofill/core/browser/autofill_profile.h" | 16 #include "components/autofill/core/browser/autofill_profile.h" |
| 17 #include "components/autofill/core/browser/credit_card.h" | 17 #include "components/autofill/core/browser/credit_card.h" |
| 18 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
| 19 #include "components/autofill/core/browser/payments/full_card_request.h" | 19 #include "components/autofill/core/browser/payments/full_card_request.h" |
| 20 #include "components/autofill/core/browser/personal_data_manager.h" | 20 #include "components/autofill/core/browser/personal_data_manager.h" |
| 21 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h" | 21 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h" |
| 22 #include "components/payments/core/payment_request_data_util.h" | |
| 22 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 23 #include "ios/chrome/browser/application_context.h" | 24 #include "ios/chrome/browser/application_context.h" |
| 24 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 25 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 25 #include "ios/chrome/browser/payments/payment_request.h" | 26 #include "ios/chrome/browser/payments/payment_request.h" |
| 26 #include "ios/chrome/browser/payments/payment_request_util.h" | 27 #include "ios/chrome/browser/payments/payment_request_util.h" |
| 27 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" | 28 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 29 | 30 |
| 30 #if !defined(__has_feature) || !__has_feature(objc_arc) | 31 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 31 #error "This file requires ARC support." | 32 #error "This file requires ARC support." |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 using ::payment_request_util::GetBasicCardResponseFromAutofillCreditCard; | 36 using payments::data_util::GetBasicCardResponseFromAutofillCreditCard; |
| 36 using ::payment_request_util::GetPaymentAddressFromAutofillProfile; | 37 using payments::data_util::GetPaymentAddressFromAutofillProfile; |
|
please use gerrit instead
2017/03/08 14:46:10
It's recommended to prepend top-level namespaces w
Mathieu
2017/03/08 18:04:26
Done.
| |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 // The unmask prompt UI for Payment Request. | 40 // The unmask prompt UI for Payment Request. |
| 40 class PRCardUnmaskPromptViewBridge | 41 class PRCardUnmaskPromptViewBridge |
| 41 : public autofill::CardUnmaskPromptViewBridge { | 42 : public autofill::CardUnmaskPromptViewBridge { |
| 42 public: | 43 public: |
| 43 explicit PRCardUnmaskPromptViewBridge( | 44 explicit PRCardUnmaskPromptViewBridge( |
| 44 autofill::CardUnmaskPromptController* controller, | 45 autofill::CardUnmaskPromptController* controller, |
| 45 UIViewController* base_view_controller) | 46 UIViewController* base_view_controller) |
| 46 : autofill::CardUnmaskPromptViewBridge(controller), | 47 : autofill::CardUnmaskPromptViewBridge(controller), |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 } | 189 } |
| 189 | 190 |
| 190 - (void)fullCardRequestDidSucceedWithCard:(const autofill::CreditCard&)card | 191 - (void)fullCardRequestDidSucceedWithCard:(const autofill::CreditCard&)card |
| 191 CVC:(const base::string16&)cvc { | 192 CVC:(const base::string16&)cvc { |
| 192 web::PaymentResponse paymentResponse; | 193 web::PaymentResponse paymentResponse; |
| 193 | 194 |
| 194 paymentResponse.method_name = | 195 paymentResponse.method_name = |
| 195 base::ASCIIToUTF16(autofill::data_util::GetPaymentRequestData(card.type()) | 196 base::ASCIIToUTF16(autofill::data_util::GetPaymentRequestData(card.type()) |
| 196 .basic_card_payment_type); | 197 .basic_card_payment_type); |
| 197 | 198 |
| 198 paymentResponse.details = | 199 paymentResponse.details = GetBasicCardResponseFromAutofillCreditCard( |
| 199 GetBasicCardResponseFromAutofillCreditCard(*_paymentRequest, card, cvc); | 200 card, cvc, _paymentRequest->billing_profiles(), |
| 201 GetApplicationContext()->GetApplicationLocale()); | |
| 200 | 202 |
| 201 if (_paymentRequest->payment_options().request_shipping) { | 203 if (_paymentRequest->payment_options().request_shipping) { |
| 202 autofill::AutofillProfile* shippingAddress = | 204 autofill::AutofillProfile* shippingAddress = |
| 203 _paymentRequest->selected_shipping_profile(); | 205 _paymentRequest->selected_shipping_profile(); |
| 204 // TODO(crbug.com/602666): User should get here only if they have selected | 206 // TODO(crbug.com/602666): User should get here only if they have selected |
| 205 // a shipping address. | 207 // a shipping address. |
| 206 DCHECK(shippingAddress); | 208 DCHECK(shippingAddress); |
| 207 paymentResponse.shipping_address = | 209 paymentResponse.shipping_address = GetPaymentAddressFromAutofillProfile( |
| 208 GetPaymentAddressFromAutofillProfile(*shippingAddress); | 210 *shippingAddress, GetApplicationContext()->GetApplicationLocale()); |
| 209 | 211 |
| 210 web::PaymentShippingOption* shippingOption = | 212 web::PaymentShippingOption* shippingOption = |
| 211 _paymentRequest->selected_shipping_option(); | 213 _paymentRequest->selected_shipping_option(); |
| 212 DCHECK(shippingOption); | 214 DCHECK(shippingOption); |
| 213 paymentResponse.shipping_option = shippingOption->id; | 215 paymentResponse.shipping_option = shippingOption->id; |
| 214 } | 216 } |
| 215 | 217 |
| 216 if (_paymentRequest->payment_options().request_payer_name) { | 218 if (_paymentRequest->payment_options().request_payer_name) { |
| 217 autofill::AutofillProfile* contactInfo = | 219 autofill::AutofillProfile* contactInfo = |
| 218 _paymentRequest->selected_contact_profile(); | 220 _paymentRequest->selected_contact_profile(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 - (void)paymentMethodSelectionCoordinatorDidReturn: | 450 - (void)paymentMethodSelectionCoordinatorDidReturn: |
| 449 (PaymentMethodSelectionCoordinator*)coordinator { | 451 (PaymentMethodSelectionCoordinator*)coordinator { |
| 450 // Clear the 'Updated' label on the payment summary item, if there is one. | 452 // Clear the 'Updated' label on the payment summary item, if there is one. |
| 451 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 453 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
| 452 | 454 |
| 453 [_methodSelectionCoordinator stop]; | 455 [_methodSelectionCoordinator stop]; |
| 454 _methodSelectionCoordinator = nil; | 456 _methodSelectionCoordinator = nil; |
| 455 } | 457 } |
| 456 | 458 |
| 457 @end | 459 @end |
| OLD | NEW |