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

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

Issue 2779283002: [Web Payments] Implement the CVC Unmask dialog. (Closed)
Patch Set: Rebase + add browser test 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_REQUEST_STATE_H_ 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_
6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "components/payments/content/payment_request.mojom.h" 13 #include "components/payments/content/payment_request.mojom.h"
14 #include "components/payments/core/payment_instrument.h" 14 #include "components/payments/core/payment_instrument.h"
15 15
16 namespace autofill { 16 namespace autofill {
17 class AutofillProfile; 17 class AutofillProfile;
18 class PersonalDataManager; 18 class PersonalDataManager;
19 } // namespace autofill 19 } // namespace autofill
20 20
21 namespace payments { 21 namespace payments {
22 22
23 class PaymentRequestSpec; 23 class PaymentRequestSpec;
24 class PaymentRequestDelegate;
24 25
25 // Keeps track of the information currently selected by the user and whether the 26 // Keeps track of the information currently selected by the user and whether the
26 // user is ready to pay. Uses information from the PaymentRequestSpec, which is 27 // user is ready to pay. Uses information from the PaymentRequestSpec, which is
27 // what the merchant has specified, as input into the "is ready to pay" 28 // what the merchant has specified, as input into the "is ready to pay"
28 // computation. 29 // computation.
29 class PaymentRequestState : public PaymentInstrument::Delegate { 30 class PaymentRequestState : public PaymentInstrument::Delegate {
30 public: 31 public:
31 // Any class call add itself as Observer via AddObserver() and receive 32 // Any class call add itself as Observer via AddObserver() and receive
32 // notification about the state changing. 33 // notification about the state changing.
33 class Observer { 34 class Observer {
34 public: 35 public:
35 // Called when the information (payment method, address/contact info, 36 // Called when the information (payment method, address/contact info,
36 // shipping option) changes. 37 // shipping option) changes.
37 virtual void OnSelectedInformationChanged() = 0; 38 virtual void OnSelectedInformationChanged() = 0;
38 39
39 protected: 40 protected:
40 virtual ~Observer() {} 41 virtual ~Observer() {}
41 }; 42 };
42 43
43 class Delegate { 44 class Delegate {
44 public: 45 public:
45 // Called when the PaymentResponse is available. 46 // Called when the PaymentResponse is available.
46 virtual void OnPaymentResponseAvailable( 47 virtual void OnPaymentResponseAvailable(
47 mojom::PaymentResponsePtr response) = 0; 48 mojom::PaymentResponsePtr response) = 0;
49 virtual PaymentRequestDelegate* GetPaymentRequestDelegate() = 0;
48 50
49 // Called when the shipping option has changed to |shipping_option_id|. 51 // Called when the shipping option has changed to |shipping_option_id|.
50 virtual void OnShippingOptionIdSelected(std::string shipping_option_id) = 0; 52 virtual void OnShippingOptionIdSelected(std::string shipping_option_id) = 0;
51 53
52 // Called when the shipping address has changed to |address|. 54 // Called when the shipping address has changed to |address|.
53 virtual void OnShippingAddressSelected( 55 virtual void OnShippingAddressSelected(
54 mojom::PaymentAddressPtr address) = 0; 56 mojom::PaymentAddressPtr address) = 0;
55 57
56 protected: 58 protected:
57 virtual ~Delegate() {} 59 virtual ~Delegate() {}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void SetSelectedShippingOption(const std::string& shipping_option_id); 115 void SetSelectedShippingOption(const std::string& shipping_option_id);
114 void SetSelectedShippingProfile(autofill::AutofillProfile* profile); 116 void SetSelectedShippingProfile(autofill::AutofillProfile* profile);
115 void SetSelectedContactProfile(autofill::AutofillProfile* profile); 117 void SetSelectedContactProfile(autofill::AutofillProfile* profile);
116 void SetSelectedInstrument(PaymentInstrument* instrument); 118 void SetSelectedInstrument(PaymentInstrument* instrument);
117 119
118 bool is_ready_to_pay() { return is_ready_to_pay_; } 120 bool is_ready_to_pay() { return is_ready_to_pay_; }
119 121
120 const std::string& GetApplicationLocale(); 122 const std::string& GetApplicationLocale();
121 autofill::PersonalDataManager* GetPersonalDataManager(); 123 autofill::PersonalDataManager* GetPersonalDataManager();
122 124
125 Delegate* delegate() { return delegate_; }
126
123 private: 127 private:
124 // Fetches the Autofill Profiles for this user from the PersonalDataManager, 128 // Fetches the Autofill Profiles for this user from the PersonalDataManager,
125 // and stores copies of them, owned by this PaymentRequestState, in 129 // and stores copies of them, owned by this PaymentRequestState, in
126 // profile_cache_. 130 // profile_cache_.
127 void PopulateProfileCache(); 131 void PopulateProfileCache();
128 132
129 // Sets the initial selections for instruments and profiles, and notifies 133 // Sets the initial selections for instruments and profiles, and notifies
130 // observers. 134 // observers.
131 void SetDefaultProfileSelections(); 135 void SetDefaultProfileSelections();
132 136
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 std::vector<std::unique_ptr<PaymentInstrument>> available_instruments_; 172 std::vector<std::unique_ptr<PaymentInstrument>> available_instruments_;
169 173
170 base::ObserverList<Observer> observers_; 174 base::ObserverList<Observer> observers_;
171 175
172 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); 176 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState);
173 }; 177 };
174 178
175 } // namespace payments 179 } // namespace payments
176 180
177 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ 181 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698