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> |
11 | 11 |
| 12 #include "components/autofill/core/browser/personal_data_manager.h" |
12 #include "components/payments/currency_formatter.h" | 13 #include "components/payments/currency_formatter.h" |
13 #include "components/payments/payment_request.mojom.h" | 14 #include "components/payments/payment_request.mojom.h" |
| 15 #include "components/payments/payment_request_delegate.h" |
14 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
15 | 17 |
16 namespace autofill { | 18 namespace autofill { |
17 class AutofillProfile; | 19 class AutofillProfile; |
18 class CreditCard; | 20 class CreditCard; |
19 } | 21 } |
20 | 22 |
21 namespace content { | 23 namespace content { |
22 class WebContents; | 24 class WebContents; |
23 } | 25 } |
24 | 26 |
25 namespace payments { | 27 namespace payments { |
26 | 28 |
27 class PaymentRequestDelegate; | |
28 class PaymentRequestWebContentsManager; | 29 class PaymentRequestWebContentsManager; |
29 | 30 |
30 class PaymentRequest : payments::mojom::PaymentRequest { | 31 class PaymentRequest : payments::mojom::PaymentRequest { |
31 public: | 32 public: |
32 PaymentRequest( | 33 PaymentRequest( |
33 content::WebContents* web_contents, | 34 content::WebContents* web_contents, |
34 std::unique_ptr<PaymentRequestDelegate> delegate, | 35 std::unique_ptr<PaymentRequestDelegate> delegate, |
35 PaymentRequestWebContentsManager* manager, | 36 PaymentRequestWebContentsManager* manager, |
36 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); | 37 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); |
37 ~PaymentRequest() override; | 38 ~PaymentRequest() override; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 89 } |
89 void set_selected_contact_profile(autofill::AutofillProfile* profile) { | 90 void set_selected_contact_profile(autofill::AutofillProfile* profile) { |
90 selected_contact_profile_ = profile; | 91 selected_contact_profile_ = profile; |
91 } | 92 } |
92 | 93 |
93 // Returns the currently selected credit card for this PaymentRequest flow. | 94 // 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 | 95 // It's not guaranteed to be complete. Returns nullptr if there is no selected |
95 // card. | 96 // card. |
96 autofill::CreditCard* GetCurrentlySelectedCreditCard(); | 97 autofill::CreditCard* GetCurrentlySelectedCreditCard(); |
97 | 98 |
| 99 autofill::PersonalDataManager* personal_data_manager() { |
| 100 return delegate_->GetPersonalDataManager(); |
| 101 } |
| 102 |
98 payments::mojom::PaymentDetails* details() { return details_.get(); } | 103 payments::mojom::PaymentDetails* details() { return details_.get(); } |
99 content::WebContents* web_contents() { return web_contents_; } | 104 content::WebContents* web_contents() { return web_contents_; } |
100 | 105 |
101 private: | 106 private: |
102 // Fetches the Autofill Profiles for this user from the PersonalDataManager, | 107 // Fetches the Autofill Profiles for this user from the PersonalDataManager, |
103 // and stores copies of them, owned by this Request, in profile_cache_. | 108 // and stores copies of them, owned by this Request, in profile_cache_. |
104 void PopulateProfileCache(); | 109 void PopulateProfileCache(); |
105 | 110 |
106 // Sets the default values for the selected Shipping and Contact profiles. | 111 // Sets the default values for the selected Shipping and Contact profiles. |
107 void SetDefaultProfileSelections(); | 112 void SetDefaultProfileSelections(); |
(...skipping 15 matching lines...) Expand all Loading... |
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_; |
126 | 131 |
127 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 132 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
128 }; | 133 }; |
129 | 134 |
130 } // namespace payments | 135 } // namespace payments |
131 | 136 |
132 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ | 137 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ |
OLD | NEW |