Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Unified Diff: components/payments/content/payment_response_helper.h

Issue 2808633002: [Payments] Move PaymentResponse logic to PaymentResponseHelper. (Closed)
Patch Set: Nit Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c8903e22b92dd8ae2c8f0ba7ee490db7f7e4eeeb 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,54 @@ 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_;
+ Delegate* delegate_;
+ PaymentInstrument* selected_instrument_;
+
+ // Not owned, can be null (dependent on the spec).
+ autofill::AutofillProfile* selected_shipping_profile_;
+ autofill::AutofillProfile* selected_contact_profile_;
+
DISALLOW_COPY_AND_ASSIGN(PaymentResponseHelper);
};
« no previous file with comments | « components/payments/content/payment_request_state_unittest.cc ('k') | components/payments/content/payment_response_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698