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

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

Issue 2815723002: [Web Payments] Add Spinners and timeout while waiting for UpdateWith (Closed)
Patch Set: Address 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_CONTENT_PAYMENT_REQUEST_SPEC_H_ 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_
6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_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 "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "components/payments/content/payment_request.mojom.h" 14 #include "components/payments/content/payment_request.mojom.h"
15 #include "components/payments/core/currency_formatter.h" 15 #include "components/payments/core/currency_formatter.h"
16 #include "components/payments/core/payment_options_provider.h" 16 #include "components/payments/core/payment_options_provider.h"
17 17
18 namespace payments { 18 namespace payments {
19 19
20 // Identifier for the basic card payment method in the PaymentMethodData. 20 // Identifier for the basic card payment method in the PaymentMethodData.
21 extern const char kBasicCardMethodName[]; 21 extern const char kBasicCardMethodName[];
22 22
23 // The spec contains all the options that the merchant has specified about this 23 // The spec contains all the options that the merchant has specified about this
24 // Payment Request. It's a (mostly) read-only view, which can be updated in 24 // Payment Request. It's a (mostly) read-only view, which can be updated in
25 // certain occasions by the merchant (see API). 25 // certain occasions by the merchant (see API).
26 class PaymentRequestSpec : public PaymentOptionsProvider { 26 class PaymentRequestSpec : public PaymentOptionsProvider {
27 public: 27 public:
28 // This enum represents which bit of information was changed to trigger an
29 // update roundtrip with the website.
30 enum class UpdateReason {
31 NONE,
32 SHIPPING_OPTION,
33 SHIPPING_ADDRESS,
34 };
35
28 // Any class call add itself as Observer via AddObserver() and receive 36 // Any class call add itself as Observer via AddObserver() and receive
29 // notification about spec events. 37 // notification about spec events.
30 class Observer { 38 class Observer {
31 public: 39 public:
32 // Called when the provided spec (details, options, method_data) is invalid. 40 // Called when the provided spec (details, options, method_data) is invalid.
33 virtual void OnInvalidSpecProvided() = 0; 41 virtual void OnInvalidSpecProvided() = 0;
34 42
43 // Called when the website is notified that the user selected shipping
44 // options or a shipping address. This will be followed by a call to
45 // OnSpecUpdated or the PaymentRequest being aborted due to a timeout.
46 virtual void OnStartUpdating(UpdateReason reason) {}
47
35 // Called when the provided spec has changed. 48 // Called when the provided spec has changed.
36 virtual void OnSpecUpdated() = 0; 49 virtual void OnSpecUpdated() = 0;
37 50
38 protected: 51 protected:
39 virtual ~Observer() {} 52 virtual ~Observer() {}
40 }; 53 };
41 54
42 PaymentRequestSpec(mojom::PaymentOptionsPtr options, 55 PaymentRequestSpec(mojom::PaymentOptionsPtr options,
43 mojom::PaymentDetailsPtr details, 56 mojom::PaymentDetailsPtr details,
44 std::vector<mojom::PaymentMethodDataPtr> method_data, 57 std::vector<mojom::PaymentMethodDataPtr> method_data,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // request's currency. Will use currency of the "total" display item, because 93 // request's currency. Will use currency of the "total" display item, because
81 // all items are supposed to have the same currency in a given request. 94 // all items are supposed to have the same currency in a given request.
82 std::string GetFormattedCurrencyCode(); 95 std::string GetFormattedCurrencyCode();
83 96
84 mojom::PaymentShippingOption* selected_shipping_option() const { 97 mojom::PaymentShippingOption* selected_shipping_option() const {
85 return selected_shipping_option_; 98 return selected_shipping_option_;
86 } 99 }
87 100
88 const mojom::PaymentDetails& details() const { return *details_.get(); } 101 const mojom::PaymentDetails& details() const { return *details_.get(); }
89 102
103 void StartWaitingForUpdateWith(UpdateReason reason);
104
90 private: 105 private:
91 friend class PaymentRequestDialogView; 106 friend class PaymentRequestDialogView;
92 void add_observer_for_testing(Observer* observer_for_testing) { 107 void add_observer_for_testing(Observer* observer_for_testing) {
93 observer_for_testing_ = observer_for_testing; 108 observer_for_testing_ = observer_for_testing;
94 } 109 }
95 110
96 // Validates the |method_data| and fills |supported_card_networks_|, 111 // Validates the |method_data| and fills |supported_card_networks_|,
97 // |supported_card_networks_set_| and |basic_card_specified_networks_|. 112 // |supported_card_networks_set_| and |basic_card_specified_networks_|.
98 void PopulateValidatedMethodData( 113 void PopulateValidatedMethodData(
99 const std::vector<mojom::PaymentMethodDataPtr>& method_data); 114 const std::vector<mojom::PaymentMethodDataPtr>& method_data);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // notified. 154 // notified.
140 base::ObserverList<Observer> observers_; 155 base::ObserverList<Observer> observers_;
141 Observer* observer_for_testing_; 156 Observer* observer_for_testing_;
142 157
143 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); 158 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec);
144 }; 159 };
145 160
146 } // namespace payments 161 } // namespace payments
147 162
148 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ 163 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_sheet_view_controller.cc ('k') | components/payments/content/payment_request_spec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698