Chromium Code Reviews| Index: components/payments/content/payment_response_helper.h |
| diff --git a/components/payments/content/payment_response_helper.h b/components/payments/content/payment_response_helper.h |
| index 0912302ac5c2cfd3c0499bbb6750bae0e6b866a4..8ea1cf9852a9c2f3a7511175e0f7684aa456589a 100644 |
| --- a/components/payments/content/payment_response_helper.h |
| +++ b/components/payments/content/payment_response_helper.h |
| @@ -7,6 +7,7 @@ |
| #include "base/macros.h" |
| #include "components/payments/content/payment_request.mojom.h" |
| +#include "components/payments/core/payment_instrument.h" |
| namespace autofill { |
| class AutofillProfile; |
| @@ -14,21 +15,56 @@ class AutofillProfile; |
| namespace payments { |
| -// TODO(sebsg): Accept PaymentInstrument and handle generating the payment |
| -// aspect of the PaymentResponse in this class. |
| +class PaymentRequestSpec; |
| + |
| // TODO(sebsg): Asynchronously normalize the billing and shipping addresses |
| // before adding them to the PaymentResponse. |
| // A helper class to facilitate the creation of the PaymentResponse. |
| -class PaymentResponseHelper { |
| +class PaymentResponseHelper : public PaymentInstrument::Delegate { |
| public: |
| - PaymentResponseHelper(); |
| - ~PaymentResponseHelper(); |
| + class Delegate { |
| + public: |
| + virtual ~Delegate() {} |
| + |
| + virtual void OnPaymentResponseReady( |
| + mojom::PaymentResponsePtr payment_response) = 0; |
| + }; |
| + // The spec, selected_instrument and delegate cannot be null. |
| + PaymentResponseHelper(const std::string& app_locale, |
| + PaymentRequestSpec* spec, |
| + PaymentInstrument* selected_instrument, |
| + autofill::AutofillProfile* selected_shipping_profile, |
| + autofill::AutofillProfile* selected_contact_profile, |
| + Delegate* delegate); |
| + ~PaymentResponseHelper() override; |
| + |
| + // Returns a new mojo PaymentAddress based on the specified |
| + // |profile| and |app_locale|. |
| static mojom::PaymentAddressPtr GetMojomPaymentAddressFromAutofillProfile( |
| const autofill::AutofillProfile* const profile, |
| const std::string& app_locale); |
| + // PaymentInstrument::Delegate |
| + void OnInstrumentDetailsReady( |
| + const std::string& method_name, |
| + const std::string& stringified_details) override; |
| + void OnInstrumentDetailsError() override {} |
| + |
| private: |
| + const std::string& app_locale_; |
| + |
| + // Not owned, cannot be null. |
| + PaymentRequestSpec* spec_; |
| + PaymentInstrument* selected_instrument_; |
| + |
| + // Not owned, can be null (dependent on the spec). |
| + autofill::AutofillProfile* selected_shipping_profile_; |
| + autofill::AutofillProfile* selected_contact_profile_; |
| + |
| + // Not owned, cannot be null. |
| + Delegate* delegate_; |
|
Mathieu
2017/04/10 20:55:58
nit: can bring this up with the other non-nulls
sebsg
2017/04/11 14:21:49
Done.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(PaymentResponseHelper); |
| }; |