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

Side by Side Diff: components/payments/content/payment_response_helper.h

Issue 2808633002: [Payments] Move PaymentResponse logic to PaymentResponseHelper. (Closed)
Patch Set: Addressed Mathp's comments 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 unified diff | Download patch
OLDNEW
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/payment_instrument.h"
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() {}
26 28
29 virtual void OnPaymentResponseReady(
30 mojom::PaymentResponsePtr payment_response) = 0;
31 };
32
33 // The spec, selected_instrument and delegate cannot be null.
34 PaymentResponseHelper(const std::string& app_locale,
35 PaymentRequestSpec* spec,
36 PaymentInstrument* selected_instrument,
37 autofill::AutofillProfile* selected_shipping_profile,
38 autofill::AutofillProfile* selected_contact_profile,
39 Delegate* delegate);
40 ~PaymentResponseHelper() override;
41
42 // Returns a new mojo PaymentAddress based on the specified
43 // |profile| and |app_locale|.
27 static mojom::PaymentAddressPtr GetMojomPaymentAddressFromAutofillProfile( 44 static mojom::PaymentAddressPtr GetMojomPaymentAddressFromAutofillProfile(
28 const autofill::AutofillProfile* const profile, 45 const autofill::AutofillProfile* const profile,
29 const std::string& app_locale); 46 const std::string& app_locale);
30 47
48 // PaymentInstrument::Delegate
49 void OnInstrumentDetailsReady(
50 const std::string& method_name,
51 const std::string& stringified_details) override;
52 void OnInstrumentDetailsError() override {}
53
31 private: 54 private:
55 const std::string& app_locale_;
56
57 // Not owned, cannot be null.
58 PaymentRequestSpec* spec_;
59 PaymentInstrument* selected_instrument_;
60
61 // Not owned, can be null (dependent on the spec).
62 autofill::AutofillProfile* selected_shipping_profile_;
63 autofill::AutofillProfile* selected_contact_profile_;
64
65 // Not owned, cannot be null.
66 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.
67
32 DISALLOW_COPY_AND_ASSIGN(PaymentResponseHelper); 68 DISALLOW_COPY_AND_ASSIGN(PaymentResponseHelper);
33 }; 69 };
34 70
35 } // namespace payments 71 } // namespace payments
36 72
37 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_ 73 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_RESPONSE_HELPER_H_
OLDNEW
« 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