| OLD | NEW |
| 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 <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace payments { | 25 namespace payments { |
| 26 class CurrencyFormatter; | 26 class CurrencyFormatter; |
| 27 } // namespace payments | 27 } // namespace payments |
| 28 | 28 |
| 29 // Has a copy of web::PaymentRequest as provided by the page invoking the | 29 // Has a copy of web::PaymentRequest as provided by the page invoking the |
| 30 // PaymentRequest API. Also caches credit cards and addresses provided by the | 30 // PaymentRequest API. Also caches credit cards and addresses provided by the |
| 31 // |personal_data_manager| and manages shared resources and user selections for | 31 // |personal_data_manager| and manages shared resources and user selections for |
| 32 // the current PaymentRequest flow. It must be initialized with a non-null | 32 // the current PaymentRequest flow. It must be initialized with a non-null |
| 33 // instance of |personal_data_manager| that outlives this class. | 33 // instance of |personal_data_manager| that outlives this class. |
| 34 class PaymentRequest : payments::PaymentOptionsProvider { | 34 class PaymentRequest : public payments::PaymentOptionsProvider { |
| 35 public: | 35 public: |
| 36 // |personal_data_manager| should not be null and should outlive this object. | 36 // |personal_data_manager| should not be null and should outlive this object. |
| 37 PaymentRequest(const web::PaymentRequest& web_payment_request, | 37 PaymentRequest(const web::PaymentRequest& web_payment_request, |
| 38 autofill::PersonalDataManager* personal_data_manager); | 38 autofill::PersonalDataManager* personal_data_manager); |
| 39 ~PaymentRequest() override; | 39 ~PaymentRequest() override; |
| 40 | 40 |
| 41 autofill::PersonalDataManager* GetPersonalDataManager() const { | 41 autofill::PersonalDataManager* GetPersonalDataManager() const { |
| 42 return personal_data_manager_; | 42 return personal_data_manager_; |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const std::vector<web::PaymentShippingOption*>& shipping_options() const { | 153 const std::vector<web::PaymentShippingOption*>& shipping_options() const { |
| 154 return shipping_options_; | 154 return shipping_options_; |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Returns the selected shipping option from |web_payment_request_| if there | 157 // Returns the selected shipping option from |web_payment_request_| if there |
| 158 // is one. Returns nullptr otherwise. | 158 // is one. Returns nullptr otherwise. |
| 159 web::PaymentShippingOption* selected_shipping_option() const { | 159 web::PaymentShippingOption* selected_shipping_option() const { |
| 160 return selected_shipping_option_; | 160 return selected_shipping_option_; |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual payments::PaymentsProfileComparator* profile_comparator(); |
| 164 |
| 163 // Returns whether the current PaymentRequest can be used to make a payment. | 165 // Returns whether the current PaymentRequest can be used to make a payment. |
| 164 bool CanMakePayment() const; | 166 bool CanMakePayment() const; |
| 165 | 167 |
| 166 protected: | 168 protected: |
| 167 // Fetches the autofill profiles for this user from the PersonalDataManager, | 169 // Fetches the autofill profiles for this user from the PersonalDataManager, |
| 168 // and stores copies of them, owned by this PaymentRequest, in profile_cache_. | 170 // and stores copies of them, owned by this PaymentRequest, in profile_cache_. |
| 169 void PopulateProfileCache(); | 171 void PopulateProfileCache(); |
| 170 | 172 |
| 171 // Sets the available shipping and contact profiles as references to the | 173 // Sets the available shipping and contact profiles as references to the |
| 172 // cached profiles ordered by completeness. | 174 // cached profiles ordered by completeness. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // A vector of pointers to the shipping options in |web_payment_request_|. | 232 // A vector of pointers to the shipping options in |web_payment_request_|. |
| 231 std::vector<web::PaymentShippingOption*> shipping_options_; | 233 std::vector<web::PaymentShippingOption*> shipping_options_; |
| 232 web::PaymentShippingOption* selected_shipping_option_; | 234 web::PaymentShippingOption* selected_shipping_option_; |
| 233 | 235 |
| 234 payments::PaymentsProfileComparator profile_comparator_; | 236 payments::PaymentsProfileComparator profile_comparator_; |
| 235 | 237 |
| 236 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 238 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
| 237 }; | 239 }; |
| 238 | 240 |
| 239 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ | 241 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ |
| OLD | NEW |