Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/payments/content/payment_request.mojom.h" | 9 #include "components/payments/content/payment_request.mojom.h" |
| 10 #include "components/payments/core/autofill_payment_instrument.h" | |
|
Mathieu
2017/04/10 00:03:22
payment_instrument.h ?
sebsg
2017/04/10 20:48:24
Done.
| |
| 10 | 11 |
| 11 namespace autofill { | 12 namespace autofill { |
| 12 class AutofillProfile; | 13 class AutofillProfile; |
| 13 } // namespace autofill | 14 } // namespace autofill |
| 14 | 15 |
| 15 namespace payments { | 16 namespace payments { |
| 16 | 17 |
| 17 // TODO(sebsg): Accept PaymentInstrument and handle generating the payment | 18 class PaymentRequestSpec; |
| 18 // aspect of the PaymentResponse in this class. | 19 |
| 19 // TODO(sebsg): Asynchronously normalize the billing and shipping addresses | 20 // TODO(sebsg): Asynchronously normalize the billing and shipping addresses |
| 20 // before adding them to the PaymentResponse. | 21 // before adding them to the PaymentResponse. |
| 21 // A helper class to facilitate the creation of the PaymentResponse. | 22 // A helper class to facilitate the creation of the PaymentResponse. |
| 22 class PaymentResponseHelper { | 23 class PaymentResponseHelper : public PaymentInstrument::Delegate { |
| 23 public: | 24 public: |
| 24 PaymentResponseHelper(); | 25 class Delegate { |
| 25 ~PaymentResponseHelper(); | 26 public: |
| 27 virtual ~Delegate() {} | |
| 28 | |
| 29 virtual void OnPaymentResponseReady( | |
| 30 mojom::PaymentResponsePtr payment_response) = 0; | |
| 31 }; | |
| 32 | |
| 33 PaymentResponseHelper(const std::string& app_locale, | |
|
Mathieu
2017/04/10 00:03:22
Mention that |delegate| can't be nullptr, but sele
sebsg
2017/04/10 20:48:25
Done.
| |
| 34 PaymentRequestSpec* spec, | |
| 35 autofill::AutofillProfile* selected_shipping_profile, | |
| 36 autofill::AutofillProfile* selected_contact_profile, | |
| 37 Delegate* delegate); | |
| 38 ~PaymentResponseHelper() override; | |
| 26 | 39 |
| 27 static mojom::PaymentAddressPtr GetMojomPaymentAddressFromAutofillProfile( | 40 static mojom::PaymentAddressPtr GetMojomPaymentAddressFromAutofillProfile( |
|
Mathieu
2017/04/10 00:03:22
Let's add a function comment
sebsg
2017/04/10 20:48:25
Done.
| |
| 28 const autofill::AutofillProfile* const profile, | 41 const autofill::AutofillProfile* const profile, |
| 29 const std::string& app_locale); | 42 const std::string& app_locale); |
| 30 | 43 |
| 44 // PaymentInstrument::Delegate | |
| 45 void OnInstrumentDetailsReady( | |
| 46 const std::string& method_name, | |
| 47 const std::string& stringified_details) override; | |
| 48 void OnInstrumentDetailsError() override {} | |
| 49 | |
| 31 private: | 50 private: |
| 51 const std::string app_locale_; | |
|
Mathieu
2017/04/10 00:03:22
nit: could keep as a const std::string&
sebsg
2017/04/10 20:48:25
Done.
| |
| 52 | |
| 53 // Not owned. Never null. All outlive this object. | |
|
Mathieu
2017/04/10 00:03:22
actually the profiles can be null?
sebsg
2017/04/10 20:48:25
Done.
| |
| 54 PaymentRequestSpec* spec_; | |
| 55 autofill::AutofillProfile* selected_shipping_profile_; | |
| 56 autofill::AutofillProfile* selected_contact_profile_; | |
| 57 Delegate* delegate_; | |
| 58 | |
| 32 DISALLOW_COPY_AND_ASSIGN(PaymentResponseHelper); | 59 DISALLOW_COPY_AND_ASSIGN(PaymentResponseHelper); |
| 33 }; | 60 }; |
| 34 | 61 |
| 35 } // namespace payments | 62 } // namespace payments |
| 36 | 63 |
| 37 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ | 64 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ |
| OLD | NEW |