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

Side by Side Diff: ios/chrome/browser/payments/payment_request.h

Issue 2968503002: [Payment Request] CanMakePayment (Closed)
Patch Set: Created 3 years, 5 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 IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ 5 #ifndef IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_
6 #define IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ 6 #define IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_
7 7
8 #include <map>
8 #include <memory> 9 #include <memory>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "components/payments/core/payment_options_provider.h" 15 #include "components/payments/core/payment_options_provider.h"
15 #include "components/payments/core/payment_request_base_delegate.h" 16 #include "components/payments/core/payment_request_base_delegate.h"
16 #include "components/payments/core/payments_profile_comparator.h" 17 #include "components/payments/core/payments_profile_comparator.h"
17 #include "ios/web/public/payments/payment_request.h" 18 #include "ios/web/public/payments/payment_request.h"
18 19
19 namespace autofill { 20 namespace autofill {
20 class AutofillProfile; 21 class AutofillProfile;
21 class CreditCard; 22 class CreditCard;
22 class PersonalDataManager; 23 class PersonalDataManager;
23 class RegionDataLoader; 24 class RegionDataLoader;
24 } // namespace autofill 25 } // namespace autofill
25 26
26 namespace payments { 27 namespace payments {
27 class AddressNormalizer; 28 class AddressNormalizer;
28 class AddressNormalizerImpl; 29 class AddressNormalizerImpl;
29 class CurrencyFormatter; 30 class CurrencyFormatter;
30 } // namespace payments 31 } // namespace payments
31 32
33 namespace ios {
34 class ChromeBrowserState;
35 } // namepsace ios
36
32 // A protocol implementd by any UI classes that the PaymentRequest object 37 // A protocol implementd by any UI classes that the PaymentRequest object
33 // needs to communicate with in order to perform certain actions such as 38 // needs to communicate with in order to perform certain actions such as
34 // initiating UI to request full card details for payment. 39 // initiating UI to request full card details for payment.
35 @protocol PaymentRequestUIDelegate<NSObject> 40 @protocol PaymentRequestUIDelegate<NSObject>
36 41
37 - (void)openFullCardRequestUI; 42 - (void)openFullCardRequestUI;
38 43
39 @end 44 @end
40 45
41 // Has a copy of web::PaymentRequest as provided by the page invoking the 46 // Has a copy of web::PaymentRequest as provided by the page invoking the
42 // PaymentRequest API. Also caches credit cards and addresses provided by the 47 // PaymentRequest API. Also caches credit cards and addresses provided by the
43 // |personal_data_manager| and manages shared resources and user selections for 48 // |personal_data_manager| and manages shared resources and user selections for
44 // the current PaymentRequest flow. It must be initialized with a non-null 49 // the current PaymentRequest flow. It must be initialized with a non-null
45 // instance of |personal_data_manager| that outlives this class. 50 // instance of |personal_data_manager| that outlives this class.
46 class PaymentRequest : public payments::PaymentOptionsProvider, 51 class PaymentRequest : public payments::PaymentOptionsProvider,
47 public payments::PaymentRequestBaseDelegate { 52 public payments::PaymentRequestBaseDelegate {
48 public: 53 public:
49 // |personal_data_manager| should not be null and should outlive this object. 54 // |personal_data_manager| should not be null and should outlive this object.
50 PaymentRequest(const web::PaymentRequest& web_payment_request, 55 PaymentRequest(const web::PaymentRequest& web_payment_request,
56 ios::ChromeBrowserState* browser_state_,
51 autofill::PersonalDataManager* personal_data_manager, 57 autofill::PersonalDataManager* personal_data_manager,
52 id<PaymentRequestUIDelegate> payment_request_ui_delegate); 58 id<PaymentRequestUIDelegate> payment_request_ui_delegate);
53 ~PaymentRequest() override; 59 ~PaymentRequest() override;
54 60
55 // PaymentRequestBaseDelegate: 61 // PaymentRequestBaseDelegate:
56 autofill::PersonalDataManager* GetPersonalDataManager() override; 62 autofill::PersonalDataManager* GetPersonalDataManager() override;
57 const std::string& GetApplicationLocale() const override; 63 const std::string& GetApplicationLocale() const override;
58 bool IsIncognito() const override; 64 bool IsIncognito() const override;
59 bool IsSslCertificateValid() override; 65 bool IsSslCertificateValid() override;
60 const GURL& GetLastCommittedURL() const override; 66 const GURL& GetLastCommittedURL() const override;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 148 }
143 149
144 const std::vector<std::string>& supported_card_networks() const { 150 const std::vector<std::string>& supported_card_networks() const {
145 return supported_card_networks_; 151 return supported_card_networks_;
146 } 152 }
147 153
148 const std::set<std::string>& basic_card_specified_networks() const { 154 const std::set<std::string>& basic_card_specified_networks() const {
149 return basic_card_specified_networks_; 155 return basic_card_specified_networks_;
150 } 156 }
151 157
158 const std::map<std::string, std::set<std::string>>& stringified_method_data()
159 const {
160 return stringified_method_data_;
161 }
162
152 // Adds |credit_card| to the list of cached credit cards, updates the list of 163 // Adds |credit_card| to the list of cached credit cards, updates the list of
153 // available credit cards, and returns a reference to the cached copy of 164 // available credit cards, and returns a reference to the cached copy of
154 // |credit_card|. 165 // |credit_card|.
155 virtual autofill::CreditCard* AddCreditCard( 166 virtual autofill::CreditCard* AddCreditCard(
156 const autofill::CreditCard& credit_card); 167 const autofill::CreditCard& credit_card);
157 168
158 // Returns the available autofill credit cards for this user that match a 169 // Returns the available autofill credit cards for this user that match a
159 // supported type specified in |web_payment_request_|. 170 // supported type specified in |web_payment_request_|.
160 const std::vector<autofill::CreditCard*>& credit_cards() const { 171 const std::vector<autofill::CreditCard*>& credit_cards() const {
161 return credit_cards_; 172 return credit_cards_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 void PopulateAvailableShippingOptions(); 222 void PopulateAvailableShippingOptions();
212 223
213 // Sets the selected shipping option, if any. 224 // Sets the selected shipping option, if any.
214 void SetSelectedShippingOption(); 225 void SetSelectedShippingOption();
215 226
216 // The web::PaymentRequest object as provided by the page invoking the Payment 227 // The web::PaymentRequest object as provided by the page invoking the Payment
217 // Request API, owned by this object. 228 // Request API, owned by this object.
218 web::PaymentRequest web_payment_request_; 229 web::PaymentRequest web_payment_request_;
219 230
220 // Never null and outlives this object. 231 // Never null and outlives this object.
232 ios::ChromeBrowserState* browser_state_;
233
234 // Never null and outlives this object.
221 autofill::PersonalDataManager* personal_data_manager_; 235 autofill::PersonalDataManager* personal_data_manager_;
222 236
223 // The PaymentRequestUIDelegate as provided by the UI object that originally 237 // The PaymentRequestUIDelegate as provided by the UI object that originally
224 // created this PaymentRequest object. 238 // created this PaymentRequest object.
225 __weak id<PaymentRequestUIDelegate> payment_request_ui_delegate_; 239 __weak id<PaymentRequestUIDelegate> payment_request_ui_delegate_;
226 240
227 // The address normalizer to use for the duration of the Payment Request. 241 // The address normalizer to use for the duration of the Payment Request.
228 payments::AddressNormalizerImpl* address_normalizer_; 242 payments::AddressNormalizerImpl* address_normalizer_;
229 243
230 // The currency formatter instance for this PaymentRequest flow. 244 // The currency formatter instance for this PaymentRequest flow.
(...skipping 21 matching lines...) Expand all
252 autofill::CreditCard* selected_credit_card_; 266 autofill::CreditCard* selected_credit_card_;
253 267
254 // A vector of supported basic card networks. This encompasses everything that 268 // A vector of supported basic card networks. This encompasses everything that
255 // the merchant supports and should be used for support checks. 269 // the merchant supports and should be used for support checks.
256 std::vector<std::string> supported_card_networks_; 270 std::vector<std::string> supported_card_networks_;
257 // A subset of |supported_card_networks_| which is only the networks that have 271 // A subset of |supported_card_networks_| which is only the networks that have
258 // been specified as part of the "basic-card" supported method. Callers should 272 // been specified as part of the "basic-card" supported method. Callers should
259 // use |supported_card_networks_| for merchant support checks. 273 // use |supported_card_networks_| for merchant support checks.
260 std::set<std::string> basic_card_specified_networks_; 274 std::set<std::string> basic_card_specified_networks_;
261 275
276 // A mapping of the payment method names to the corresponding JSON-stringified
277 // payment method specific data.
278 std::map<std::string, std::set<std::string>> stringified_method_data_;
279
262 // A vector of pointers to the shipping options in |web_payment_request_|. 280 // A vector of pointers to the shipping options in |web_payment_request_|.
263 std::vector<web::PaymentShippingOption*> shipping_options_; 281 std::vector<web::PaymentShippingOption*> shipping_options_;
264 web::PaymentShippingOption* selected_shipping_option_; 282 web::PaymentShippingOption* selected_shipping_option_;
265 283
266 payments::PaymentsProfileComparator profile_comparator_; 284 payments::PaymentsProfileComparator profile_comparator_;
267 285
268 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); 286 DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
269 }; 287 };
270 288
271 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ 289 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/payments/ios_can_make_payment_query_factory.cc ('k') | ios/chrome/browser/payments/payment_request.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698