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

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

Issue 2715213005: [Payments] Add the pay button, and control its enabled state (Closed)
Patch Set: tweak Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_H_ 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_
6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // to the renderer which will indirectly destroy this object (through 53 // to the renderer which will indirectly destroy this object (through
54 // OnConnectionTerminated). 54 // OnConnectionTerminated).
55 void UserCancelled(); 55 void UserCancelled();
56 56
57 // As a result of a browser-side error or renderer-initiated mojo channel 57 // As a result of a browser-side error or renderer-initiated mojo channel
58 // closure (e.g. there was an error on the renderer side, or payment was 58 // closure (e.g. there was an error on the renderer side, or payment was
59 // successful), this method is called. It is responsible for cleaning up, 59 // successful), this method is called. It is responsible for cleaning up,
60 // such as possibly closing the dialog. 60 // such as possibly closing the dialog.
61 void OnConnectionTerminated(); 61 void OnConnectionTerminated();
62 62
63 // Called when the user clicks on the "Pay" button.
64 void Pay();
65
66 bool is_ready_to_pay() { return is_ready_to_pay_; }
67
63 // Returns the CurrencyFormatter instance for this PaymentRequest. 68 // Returns the CurrencyFormatter instance for this PaymentRequest.
64 // |locale_name| should be the result of the browser's GetApplicationLocale(). 69 // |locale_name| should be the result of the browser's GetApplicationLocale().
65 // Note: Having multiple currencies per PaymentRequest is not supported; hence 70 // Note: Having multiple currencies per PaymentRequest is not supported; hence
66 // the CurrencyFormatter is cached here. 71 // the CurrencyFormatter is cached here.
67 CurrencyFormatter* GetOrCreateCurrencyFormatter( 72 CurrencyFormatter* GetOrCreateCurrencyFormatter(
68 const std::string& currency_code, 73 const std::string& currency_code,
69 const std::string& currency_system, 74 const std::string& currency_system,
70 const std::string& locale_name); 75 const std::string& locale_name);
71 76
72 // Returns the appropriate Autofill Profiles for this user. On the first 77 // Returns the appropriate Autofill Profiles for this user. On the first
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 void PopulateProfileCache(); 126 void PopulateProfileCache();
122 127
123 // Sets the default values for the selected Shipping and Contact profiles, as 128 // Sets the default values for the selected Shipping and Contact profiles, as
124 // well as the selected Credit Card. 129 // well as the selected Credit Card.
125 void SetDefaultProfileSelections(); 130 void SetDefaultProfileSelections();
126 131
127 // Validates the |method_data| and fills |supported_card_networks_|. 132 // Validates the |method_data| and fills |supported_card_networks_|.
128 void PopulateValidatedMethodData( 133 void PopulateValidatedMethodData(
129 const std::vector<payments::mojom::PaymentMethodDataPtr>& method_data); 134 const std::vector<payments::mojom::PaymentMethodDataPtr>& method_data);
130 135
136 // Updates |is_ready_to_pay_| with the current state, by validating that all
137 // the required information is available.
138 void UpdateIsReadyToPay();
139
140 // Returns whether the selected data satisfies the PaymentDetails requirements
141 // (payment methods).
142 bool ArePaymentDetailsSatisfied();
143 // Returns whether the selected data satisfies the PaymentOptions requirements
144 // (contact info, shipping address).
145 bool ArePaymentOptionsSatisfied();
146
131 content::WebContents* web_contents_; 147 content::WebContents* web_contents_;
132 std::unique_ptr<PaymentRequestDelegate> delegate_; 148 std::unique_ptr<PaymentRequestDelegate> delegate_;
133 // |manager_| owns this PaymentRequest. 149 // |manager_| owns this PaymentRequest.
134 PaymentRequestWebContentsManager* manager_; 150 PaymentRequestWebContentsManager* manager_;
135 mojo::Binding<payments::mojom::PaymentRequest> binding_; 151 mojo::Binding<payments::mojom::PaymentRequest> binding_;
136 payments::mojom::PaymentRequestClientPtr client_; 152 payments::mojom::PaymentRequestClientPtr client_;
137 payments::mojom::PaymentDetailsPtr details_; 153 payments::mojom::PaymentDetailsPtr details_;
154 payments::mojom::PaymentOptionsPtr options_;
138 std::unique_ptr<CurrencyFormatter> currency_formatter_; 155 std::unique_ptr<CurrencyFormatter> currency_formatter_;
139 // A set of supported basic card networks. 156 // A set of supported basic card networks.
140 std::vector<std::string> supported_card_networks_; 157 std::vector<std::string> supported_card_networks_;
158 bool is_ready_to_pay_;
141 159
142 // Profiles may change due to (e.g.) sync events, so profiles are cached after 160 // Profiles may change due to (e.g.) sync events, so profiles are cached after
143 // loading and owned here. They are populated once only, and ordered by 161 // loading and owned here. They are populated once only, and ordered by
144 // frecency. 162 // frecency.
145 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; 163 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_;
146 std::vector<autofill::AutofillProfile*> shipping_profiles_; 164 std::vector<autofill::AutofillProfile*> shipping_profiles_;
147 std::vector<autofill::AutofillProfile*> contact_profiles_; 165 std::vector<autofill::AutofillProfile*> contact_profiles_;
148 autofill::AutofillProfile* selected_shipping_profile_; 166 autofill::AutofillProfile* selected_shipping_profile_;
149 autofill::AutofillProfile* selected_contact_profile_; 167 autofill::AutofillProfile* selected_contact_profile_;
150 std::vector<std::unique_ptr<autofill::CreditCard>> card_cache_; 168 std::vector<std::unique_ptr<autofill::CreditCard>> card_cache_;
151 std::vector<autofill::CreditCard*> credit_cards_; 169 std::vector<autofill::CreditCard*> credit_cards_;
152 autofill::CreditCard* selected_credit_card_; 170 autofill::CreditCard* selected_credit_card_;
153 171
154 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); 172 DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
155 }; 173 };
156 174
157 } // namespace payments 175 } // namespace payments
158 176
159 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_ 177 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698