Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PAYMENT_REQUEST_H_ | 5 #ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ |
| 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ | 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 void set_selected_shipping_profile(autofill::AutofillProfile* profile) { | 83 void set_selected_shipping_profile(autofill::AutofillProfile* profile) { |
| 84 selected_shipping_profile_ = profile; | 84 selected_shipping_profile_ = profile; |
| 85 } | 85 } |
| 86 autofill::AutofillProfile* selected_contact_profile() const { | 86 autofill::AutofillProfile* selected_contact_profile() const { |
| 87 return selected_contact_profile_; | 87 return selected_contact_profile_; |
| 88 } | 88 } |
| 89 void set_selected_contact_profile(autofill::AutofillProfile* profile) { | 89 void set_selected_contact_profile(autofill::AutofillProfile* profile) { |
| 90 selected_contact_profile_ = profile; | 90 selected_contact_profile_ = profile; |
| 91 } | 91 } |
| 92 | 92 |
| 93 const std::vector<autofill::CreditCard*> credit_cards(); | |
|
please use gerrit instead
2017/02/14 00:29:14
Please add a "&" (ref) to avoid copying the vector
anthonyvd
2017/02/22 20:15:21
Done.
| |
| 94 | |
| 93 // Returns the currently selected credit card for this PaymentRequest flow. | 95 // Returns the currently selected credit card for this PaymentRequest flow. |
| 94 // It's not guaranteed to be complete. Returns nullptr if there is no selected | 96 // It's not guaranteed to be complete. Returns nullptr if there is no selected |
| 95 // card. | 97 // card. |
| 96 autofill::CreditCard* GetCurrentlySelectedCreditCard(); | 98 autofill::CreditCard* selected_credit_card() { |
| 99 return selected_credit_card_; | |
| 100 } | |
| 97 | 101 |
| 98 payments::mojom::PaymentDetails* details() { return details_.get(); } | 102 payments::mojom::PaymentDetails* details() { return details_.get(); } |
| 99 content::WebContents* web_contents() { return web_contents_; } | 103 content::WebContents* web_contents() { return web_contents_; } |
| 100 | 104 |
| 101 private: | 105 private: |
| 102 // Fetches the Autofill Profiles for this user from the PersonalDataManager, | 106 // Fetches the Autofill Profiles for this user from the PersonalDataManager, |
| 103 // and stores copies of them, owned by this Request, in profile_cache_. | 107 // and stores copies of them, owned by this Request, in profile_cache_. |
| 104 void PopulateProfileCache(); | 108 void PopulateProfileCache(); |
| 105 | 109 |
| 106 // Sets the default values for the selected Shipping and Contact profiles. | 110 // Sets the default values for the selected Shipping and Contact profiles, as |
| 111 // well as the selected Credit Card. | |
| 107 void SetDefaultProfileSelections(); | 112 void SetDefaultProfileSelections(); |
| 108 | 113 |
| 109 content::WebContents* web_contents_; | 114 content::WebContents* web_contents_; |
| 110 std::unique_ptr<PaymentRequestDelegate> delegate_; | 115 std::unique_ptr<PaymentRequestDelegate> delegate_; |
| 111 // |manager_| owns this PaymentRequest. | 116 // |manager_| owns this PaymentRequest. |
| 112 PaymentRequestWebContentsManager* manager_; | 117 PaymentRequestWebContentsManager* manager_; |
| 113 mojo::Binding<payments::mojom::PaymentRequest> binding_; | 118 mojo::Binding<payments::mojom::PaymentRequest> binding_; |
| 114 payments::mojom::PaymentRequestClientPtr client_; | 119 payments::mojom::PaymentRequestClientPtr client_; |
| 115 payments::mojom::PaymentDetailsPtr details_; | 120 payments::mojom::PaymentDetailsPtr details_; |
| 116 std::unique_ptr<CurrencyFormatter> currency_formatter_; | 121 std::unique_ptr<CurrencyFormatter> currency_formatter_; |
| 117 | 122 |
| 118 // Profiles may change due to (e.g.) sync events, so profiles are cached after | 123 // Profiles may change due to (e.g.) sync events, so profiles are cached after |
| 119 // loading and owned here. They are populated once only, and ordered by | 124 // loading and owned here. They are populated once only, and ordered by |
| 120 // frecency. | 125 // frecency. |
| 121 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; | 126 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; |
| 122 std::vector<autofill::AutofillProfile*> shipping_profiles_; | 127 std::vector<autofill::AutofillProfile*> shipping_profiles_; |
| 123 std::vector<autofill::AutofillProfile*> contact_profiles_; | 128 std::vector<autofill::AutofillProfile*> contact_profiles_; |
| 124 autofill::AutofillProfile* selected_shipping_profile_; | 129 autofill::AutofillProfile* selected_shipping_profile_; |
| 125 autofill::AutofillProfile* selected_contact_profile_; | 130 autofill::AutofillProfile* selected_contact_profile_; |
| 131 autofill::CreditCard* selected_credit_card_; | |
| 126 | 132 |
| 127 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 133 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
| 128 }; | 134 }; |
| 129 | 135 |
| 130 } // namespace payments | 136 } // namespace payments |
| 131 | 137 |
| 132 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ | 138 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ |
| OLD | NEW |