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

Unified 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, 10 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_request.h
diff --git a/components/payments/content/payment_request.h b/components/payments/content/payment_request.h
index cdecff311a4898320709b775872568c7ce238ec7..b2174ca2b23afc14b056914ac877638b8a945d23 100644
--- a/components/payments/content/payment_request.h
+++ b/components/payments/content/payment_request.h
@@ -60,6 +60,11 @@ class PaymentRequest : payments::mojom::PaymentRequest {
// such as possibly closing the dialog.
void OnConnectionTerminated();
+ // Called when the user clicks on the "Pay" button.
+ void Pay();
+
+ bool is_ready_to_pay() { return is_ready_to_pay_; }
+
// Returns the CurrencyFormatter instance for this PaymentRequest.
// |locale_name| should be the result of the browser's GetApplicationLocale().
// Note: Having multiple currencies per PaymentRequest is not supported; hence
@@ -128,6 +133,17 @@ class PaymentRequest : payments::mojom::PaymentRequest {
void PopulateValidatedMethodData(
const std::vector<payments::mojom::PaymentMethodDataPtr>& method_data);
+ // Updates |is_ready_to_pay_| with the current state, by validating that all
+ // the required information is available.
+ void UpdateIsReadyToPay();
+
+ // Returns whether the selected data satisfies the PaymentDetails requirements
+ // (payment methods).
+ bool ArePaymentDetailsSatisfied();
+ // Returns whether the selected data satisfies the PaymentOptions requirements
+ // (contact info, shipping address).
+ bool ArePaymentOptionsSatisfied();
+
content::WebContents* web_contents_;
std::unique_ptr<PaymentRequestDelegate> delegate_;
// |manager_| owns this PaymentRequest.
@@ -135,9 +151,11 @@ class PaymentRequest : payments::mojom::PaymentRequest {
mojo::Binding<payments::mojom::PaymentRequest> binding_;
payments::mojom::PaymentRequestClientPtr client_;
payments::mojom::PaymentDetailsPtr details_;
+ payments::mojom::PaymentOptionsPtr options_;
std::unique_ptr<CurrencyFormatter> currency_formatter_;
// A set of supported basic card networks.
std::vector<std::string> supported_card_networks_;
+ bool is_ready_to_pay_;
// Profiles may change due to (e.g.) sync events, so profiles are cached after
// loading and owned here. They are populated once only, and ordered by

Powered by Google App Engine
This is Rietveld 408576698