| 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 | 9 |
| 10 #include "base/optional.h" | 10 #include "base/optional.h" |
| 11 #include "components/payments/currency_formatter.h" | 11 #include "components/payments/currency_formatter.h" |
| 12 #include "components/payments/payment_request.mojom.h" | 12 #include "components/payments/payment_request.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 14 | 14 |
| 15 namespace autofill { |
| 16 class CreditCard; |
| 17 } |
| 18 |
| 15 namespace content { | 19 namespace content { |
| 16 class WebContents; | 20 class WebContents; |
| 17 } | 21 } |
| 18 | 22 |
| 19 namespace payments { | 23 namespace payments { |
| 20 | 24 |
| 21 class PaymentRequestDelegate; | 25 class PaymentRequestDelegate; |
| 22 class PaymentRequestWebContentsManager; | 26 class PaymentRequestWebContentsManager; |
| 23 | 27 |
| 24 class PaymentRequest : payments::mojom::PaymentRequest { | 28 class PaymentRequest : payments::mojom::PaymentRequest { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 | 50 |
| 47 // Returns the CurrencyFormatter instance for this PaymentRequest. | 51 // Returns the CurrencyFormatter instance for this PaymentRequest. |
| 48 // |locale_name| should be the result of the browser's GetApplicationLocale(). | 52 // |locale_name| should be the result of the browser's GetApplicationLocale(). |
| 49 // Note: Having multiple currencies per PaymentRequest is not supported; hence | 53 // Note: Having multiple currencies per PaymentRequest is not supported; hence |
| 50 // the CurrencyFormatter is cached here. | 54 // the CurrencyFormatter is cached here. |
| 51 CurrencyFormatter* GetOrCreateCurrencyFormatter( | 55 CurrencyFormatter* GetOrCreateCurrencyFormatter( |
| 52 const std::string& currency_code, | 56 const std::string& currency_code, |
| 53 const base::Optional<std::string> currency_system, | 57 const base::Optional<std::string> currency_system, |
| 54 const std::string& locale_name); | 58 const std::string& locale_name); |
| 55 | 59 |
| 60 // Returns the currently selected credit card for this PaymentRequest flow. |
| 61 // It's not guaranteed to be complete. Returns nullptr if there is no selected |
| 62 // card. |
| 63 autofill::CreditCard* GetCurrentlySelectedCreditCard(); |
| 64 |
| 56 payments::mojom::PaymentDetails* details() { return details_.get(); } | 65 payments::mojom::PaymentDetails* details() { return details_.get(); } |
| 57 | |
| 58 content::WebContents* web_contents() { return web_contents_; } | 66 content::WebContents* web_contents() { return web_contents_; } |
| 59 | 67 |
| 60 private: | 68 private: |
| 61 content::WebContents* web_contents_; | 69 content::WebContents* web_contents_; |
| 62 std::unique_ptr<PaymentRequestDelegate> delegate_; | 70 std::unique_ptr<PaymentRequestDelegate> delegate_; |
| 63 // |manager_| owns this PaymentRequest. | 71 // |manager_| owns this PaymentRequest. |
| 64 PaymentRequestWebContentsManager* manager_; | 72 PaymentRequestWebContentsManager* manager_; |
| 65 mojo::Binding<payments::mojom::PaymentRequest> binding_; | 73 mojo::Binding<payments::mojom::PaymentRequest> binding_; |
| 66 payments::mojom::PaymentRequestClientPtr client_; | 74 payments::mojom::PaymentRequestClientPtr client_; |
| 67 payments::mojom::PaymentDetailsPtr details_; | 75 payments::mojom::PaymentDetailsPtr details_; |
| 68 std::unique_ptr<CurrencyFormatter> currency_formatter_; | 76 std::unique_ptr<CurrencyFormatter> currency_formatter_; |
| 69 | 77 |
| 70 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 78 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
| 71 }; | 79 }; |
| 72 | 80 |
| 73 } // namespace payments | 81 } // namespace payments |
| 74 | 82 |
| 75 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ | 83 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ |
| OLD | NEW |