| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void set_payment_details(const web::PaymentDetails& details); | 50 void set_payment_details(const web::PaymentDetails& details); |
| 51 | 51 |
| 52 // Returns the payments::CurrencyFormatter instance for this PaymentRequest. | 52 // Returns the payments::CurrencyFormatter instance for this PaymentRequest. |
| 53 // Note: Having multiple currencies per PaymentRequest flow is not supported; | 53 // Note: Having multiple currencies per PaymentRequest flow is not supported; |
| 54 // hence the CurrencyFormatter is cached here. | 54 // hence the CurrencyFormatter is cached here. |
| 55 payments::CurrencyFormatter* GetOrCreateCurrencyFormatter(); | 55 payments::CurrencyFormatter* GetOrCreateCurrencyFormatter(); |
| 56 | 56 |
| 57 // Returns the available autofill profiles for this user to be used as | 57 // Returns the available autofill profiles for this user to be used as |
| 58 // shipping profiles. | 58 // shipping profiles. |
| 59 const std::vector<autofill::AutofillProfile*>& shipping_profiles() const { | 59 const std::vector<autofill::AutofillProfile*>& shipping_profiles() const { |
| 60 return profiles_; | 60 return shipping_profiles_; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Returns the currently selected shipping profile for this PaymentRequest | 63 // Returns the currently selected shipping profile for this PaymentRequest |
| 64 // flow if there is one. Returns nullptr if there is no selected profile. | 64 // flow if there is one. Returns nullptr if there is no selected profile. |
| 65 autofill::AutofillProfile* selected_shipping_profile() const { | 65 autofill::AutofillProfile* selected_shipping_profile() const { |
| 66 return selected_shipping_profile_; | 66 return selected_shipping_profile_; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Sets the currently selected shipping profile for this PaymentRequest flow. | 69 // Sets the currently selected shipping profile for this PaymentRequest flow. |
| 70 void set_selected_shipping_profile(autofill::AutofillProfile* profile) { | 70 void set_selected_shipping_profile(autofill::AutofillProfile* profile) { |
| 71 selected_shipping_profile_ = profile; | 71 selected_shipping_profile_ = profile; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Returns the available autofill profiles for this user to be used as | 74 // Returns the available autofill profiles for this user to be used as |
| 75 // contact profiles. |
| 76 const std::vector<autofill::AutofillProfile*>& contact_profiles() const { |
| 77 return contact_profiles_; |
| 78 } |
| 79 |
| 80 // Returns the currently selected contact profile for this PaymentRequest |
| 81 // flow if there is one. Returns nullptr if there is no selected profile. |
| 82 autofill::AutofillProfile* selected_contact_profile() const { |
| 83 return selected_contact_profile_; |
| 84 } |
| 85 |
| 86 // Sets the currently selected contact profile for this PaymentRequest flow. |
| 87 void set_selected_contact_profile(autofill::AutofillProfile* profile) { |
| 88 selected_contact_profile_ = profile; |
| 89 } |
| 90 |
| 91 // Returns the available autofill profiles for this user to be used as |
| 75 // billing profiles. | 92 // billing profiles. |
| 76 const std::vector<autofill::AutofillProfile*>& billing_profiles() const { | 93 const std::vector<autofill::AutofillProfile*>& billing_profiles() const { |
| 77 return profiles_; | 94 return shipping_profiles_; |
| 78 } | 95 } |
| 79 | 96 |
| 80 // Returns the available autofill credit cards for this user that match a | 97 // Returns the available autofill credit cards for this user that match a |
| 81 // supported type specified in |web_payment_request_|. | 98 // supported type specified in |web_payment_request_|. |
| 82 const std::vector<autofill::CreditCard*>& credit_cards() const { | 99 const std::vector<autofill::CreditCard*>& credit_cards() const { |
| 83 return credit_cards_; | 100 return credit_cards_; |
| 84 } | 101 } |
| 85 | 102 |
| 86 // Returns the currently selected credit card for this PaymentRequest flow if | 103 // Returns the currently selected credit card for this PaymentRequest flow if |
| 87 // there is one. Returns nullptr if there is no selected credit card. | 104 // there is one. Returns nullptr if there is no selected credit card. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 autofill::PersonalDataManager* personal_data_manager_; | 144 autofill::PersonalDataManager* personal_data_manager_; |
| 128 | 145 |
| 129 // The currency formatter instance for this PaymentRequest flow. | 146 // The currency formatter instance for this PaymentRequest flow. |
| 130 std::unique_ptr<payments::CurrencyFormatter> currency_formatter_; | 147 std::unique_ptr<payments::CurrencyFormatter> currency_formatter_; |
| 131 | 148 |
| 132 // Profiles returned by the Data Manager may change due to (e.g.) sync events, | 149 // Profiles returned by the Data Manager may change due to (e.g.) sync events, |
| 133 // meaning PaymentRequest may outlive them. Therefore, profiles are fetched | 150 // meaning PaymentRequest may outlive them. Therefore, profiles are fetched |
| 134 // once and owned here. Whenever profiles are requested a vector of pointers | 151 // once and owned here. Whenever profiles are requested a vector of pointers |
| 135 // to these copies are returned. | 152 // to these copies are returned. |
| 136 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; | 153 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; |
| 137 std::vector<autofill::AutofillProfile*> profiles_; | 154 |
| 155 std::vector<autofill::AutofillProfile*> shipping_profiles_; |
| 138 autofill::AutofillProfile* selected_shipping_profile_; | 156 autofill::AutofillProfile* selected_shipping_profile_; |
| 139 | 157 |
| 158 std::vector<autofill::AutofillProfile*> contact_profiles_; |
| 159 autofill::AutofillProfile* selected_contact_profile_; |
| 160 |
| 140 // Credit cards returnd by the Data Manager may change due to (e.g.) | 161 // Credit cards returnd by the Data Manager may change due to (e.g.) |
| 141 // sync events, meaning PaymentRequest may outlive them. Therefore, credit | 162 // sync events, meaning PaymentRequest may outlive them. Therefore, credit |
| 142 // cards are fetched once and owned here. Whenever credit cards are requested | 163 // cards are fetched once and owned here. Whenever credit cards are requested |
| 143 // a vector of pointers to these copies are returned. | 164 // a vector of pointers to these copies are returned. |
| 144 std::vector<std::unique_ptr<autofill::CreditCard>> credit_card_cache_; | 165 std::vector<std::unique_ptr<autofill::CreditCard>> credit_card_cache_; |
| 166 |
| 145 std::vector<autofill::CreditCard*> credit_cards_; | 167 std::vector<autofill::CreditCard*> credit_cards_; |
| 146 autofill::CreditCard* selected_credit_card_; | 168 autofill::CreditCard* selected_credit_card_; |
| 147 | 169 |
| 148 // A vector of pointers to the shipping options in |web_payment_request_|. | 170 // A vector of pointers to the shipping options in |web_payment_request_|. |
| 149 std::vector<web::PaymentShippingOption*> shipping_options_; | 171 std::vector<web::PaymentShippingOption*> shipping_options_; |
| 150 web::PaymentShippingOption* selected_shipping_option_; | 172 web::PaymentShippingOption* selected_shipping_option_; |
| 151 | 173 |
| 152 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 174 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
| 153 }; | 175 }; |
| 154 | 176 |
| 155 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ | 177 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_H_ |
| OLD | NEW |