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

Unified Diff: components/payments/content/payment_request_spec.h

Issue 2789093002: [Payments] Desktop: implement shipping address/option change (Closed)
Patch Set: compile fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/payments/content/payment_request.cc ('k') | components/payments/content/payment_request_spec.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/content/payment_request_spec.h
diff --git a/components/payments/content/payment_request_spec.h b/components/payments/content/payment_request_spec.h
index 4de3dcd9de487e3ac55ace3d79f0dd1e70b1fca7..093476dba3185638c70aac3d937a56cf4b36120f 100644
--- a/components/payments/content/payment_request_spec.h
+++ b/components/payments/content/payment_request_spec.h
@@ -32,6 +32,9 @@ class PaymentRequestSpec : public PaymentOptionsProvider {
// Called when the provided spec (details, options, method_data) is invalid.
virtual void OnInvalidSpecProvided() = 0;
+ // Called when the provided spec has changed.
+ virtual void OnSpecUpdated() = 0;
+
protected:
virtual ~Observer() {}
};
@@ -43,6 +46,10 @@ class PaymentRequestSpec : public PaymentOptionsProvider {
const std::string& app_locale);
~PaymentRequestSpec() override;
+ // Called when the merchant has new PaymentDetails. Will recompute every spec
+ // state that depends on |details|.
+ void UpdateWith(mojom::PaymentDetailsPtr details);
+
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -74,15 +81,31 @@ class PaymentRequestSpec : public PaymentOptionsProvider {
// all items are supposed to have the same currency in a given request.
std::string GetFormattedCurrencyCode();
+ mojom::PaymentShippingOption* selected_shipping_option() const {
+ return selected_shipping_option_;
+ }
+
const mojom::PaymentDetails& details() const { return *details_.get(); }
private:
+ friend class PaymentRequestDialogView;
+ void add_observer_for_testing(Observer* observer_for_testing) {
+ observer_for_testing_ = observer_for_testing;
+ }
+
// Validates the |method_data| and fills |supported_card_networks_|.
void PopulateValidatedMethodData(
const std::vector<mojom::PaymentMethodDataPtr>& method_data);
+ // Updates the selected_shipping_option based on the data passed to this
+ // payment request by the website. This will set selected_shipping_option_ to
+ // the last option marked selected in the options array.
+ void UpdateSelectedShippingOption();
+
// Will notify all observers that the spec is invalid.
void NotifyOnInvalidSpecProvided();
+ // Will notify all observers that the spec has changed.
+ void NotifyOnSpecUpdated();
// Returns the CurrencyFormatter instance for this PaymentRequest.
// |locale_name| should be the result of the browser's GetApplicationLocale().
@@ -96,6 +119,9 @@ class PaymentRequestSpec : public PaymentOptionsProvider {
mojom::PaymentOptionsPtr options_;
mojom::PaymentDetailsPtr details_;
const std::string app_locale_;
+ // The currently shipping option as specified by the merchant.
+ mojom::PaymentShippingOption* selected_shipping_option_;
+
std::unique_ptr<CurrencyFormatter> currency_formatter_;
// A list/set of supported basic card networks. The list is used to keep the
@@ -108,7 +134,10 @@ class PaymentRequestSpec : public PaymentOptionsProvider {
// |supported_card_networks_set_| to check merchant support.
std::set<std::string> basic_card_specified_networks_;
+ // The |observer_for_testing_| will fire after all the |observers_| have been
+ // notified.
base::ObserverList<Observer> observers_;
+ Observer* observer_for_testing_;
DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec);
};
« no previous file with comments | « components/payments/content/payment_request.cc ('k') | components/payments/content/payment_request_spec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698