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

Side by Side Diff: components/payments/core/autofill_payment_instrument.h

Issue 2842463002: [Payments] Normalize billing address for response on Desktop. (Closed)
Patch Set: Addressed moe'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_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ 5 #ifndef COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_
6 #define COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ 6 #define COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/autofill/core/browser/autofill_profile.h"
13 #include "components/autofill/core/browser/credit_card.h" 14 #include "components/autofill/core/browser/credit_card.h"
14 #include "components/autofill/core/browser/payments/full_card_request.h" 15 #include "components/autofill/core/browser/payments/full_card_request.h"
16 #include "components/payments/core/address_normalizer.h"
15 #include "components/payments/core/payment_instrument.h" 17 #include "components/payments/core/payment_instrument.h"
16 18
17 namespace autofill {
18 class AutofillProfile;
19 }
20
21 namespace payments { 19 namespace payments {
22 20
23 class PaymentRequestDelegate; 21 class PaymentRequestDelegate;
24 22
25 // Represents an Autofill/Payments credit card form of payment in Payment 23 // Represents an Autofill/Payments credit card form of payment in Payment
26 // Request. 24 // Request.
27 class AutofillPaymentInstrument 25 class AutofillPaymentInstrument
28 : public PaymentInstrument, 26 : public PaymentInstrument,
29 public autofill::payments::FullCardRequest::ResultDelegate { 27 public autofill::payments::FullCardRequest::ResultDelegate,
28 public AddressNormalizer::Delegate {
30 public: 29 public:
31 // |billing_profiles| is owned by the caller and should outlive this object. 30 // |billing_profiles| is owned by the caller and should outlive this object.
32 // |payment_request_delegate| must outlive this object. 31 // |payment_request_delegate| must outlive this object.
33 AutofillPaymentInstrument( 32 AutofillPaymentInstrument(
34 const std::string& method_name, 33 const std::string& method_name,
35 const autofill::CreditCard& card, 34 const autofill::CreditCard& card,
36 const std::vector<autofill::AutofillProfile*>& billing_profiles, 35 const std::vector<autofill::AutofillProfile*>& billing_profiles,
37 const std::string& app_locale, 36 const std::string& app_locale,
38 PaymentRequestDelegate* payment_request_delegate); 37 PaymentRequestDelegate* payment_request_delegate);
39 ~AutofillPaymentInstrument() override; 38 ~AutofillPaymentInstrument() override;
40 39
41 // PaymentInstrument: 40 // PaymentInstrument:
42 void InvokePaymentApp(PaymentInstrument::Delegate* delegate) override; 41 void InvokePaymentApp(PaymentInstrument::Delegate* delegate) override;
43 bool IsCompleteForPayment() override; 42 bool IsCompleteForPayment() override;
44 base::string16 GetMissingInfoLabel() override; 43 base::string16 GetMissingInfoLabel() override;
45 bool IsValidForCanMakePayment() override; 44 bool IsValidForCanMakePayment() override;
46 45
47 // autofill::payments::FullCardRequest::ResultDelegate: 46 // autofill::payments::FullCardRequest::ResultDelegate:
48 void OnFullCardRequestSucceeded(const autofill::CreditCard& card, 47 void OnFullCardRequestSucceeded(const autofill::CreditCard& card,
49 const base::string16& cvc) override; 48 const base::string16& cvc) override;
50 void OnFullCardRequestFailed() override; 49 void OnFullCardRequestFailed() override;
51 50
51 // AddressNormalizer::Delegate:
52 void OnAddressNormalized(
53 const autofill::AutofillProfile& normalized_profile) override;
54 void OnCouldNotNormalize(const autofill::AutofillProfile& profile) override;
55
52 autofill::CreditCard* credit_card() { return &credit_card_; } 56 autofill::CreditCard* credit_card() { return &credit_card_; }
53 57
54 private: 58 private:
59 // Generates the basic card response and sends it to the delegate.
60 void GenerateBasicCardResponse();
61
55 // A copy of the card is owned by this object. 62 // A copy of the card is owned by this object.
56 autofill::CreditCard credit_card_; 63 autofill::CreditCard credit_card_;
57 // Not owned by this object, should outlive this. 64 // Not owned by this object, should outlive this.
58 const std::vector<autofill::AutofillProfile*>& billing_profiles_; 65 const std::vector<autofill::AutofillProfile*>& billing_profiles_;
59 66
60 const std::string app_locale_; 67 const std::string app_locale_;
61 68
62 PaymentInstrument::Delegate* delegate_; 69 PaymentInstrument::Delegate* delegate_;
63 PaymentRequestDelegate* payment_request_delegate_; 70 PaymentRequestDelegate* payment_request_delegate_;
71 autofill::AutofillProfile billing_address_;
72
73 base::string16 cvc_;
74
75 bool is_waiting_for_card_unmask_;
76 bool is_waiting_for_billing_address_normalization_;
64 77
65 base::WeakPtrFactory<AutofillPaymentInstrument> weak_ptr_factory_; 78 base::WeakPtrFactory<AutofillPaymentInstrument> weak_ptr_factory_;
66 79
67 DISALLOW_COPY_AND_ASSIGN(AutofillPaymentInstrument); 80 DISALLOW_COPY_AND_ASSIGN(AutofillPaymentInstrument);
68 }; 81 };
69 82
70 } // namespace payments 83 } // namespace payments
71 84
72 #endif // COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ 85 #endif // COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698