| 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" |
| 11 #include "components/payments/currency_formatter.h" |
| 10 #include "components/payments/payment_request.mojom.h" | 12 #include "components/payments/payment_request.mojom.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 class WebContents; | 16 class WebContents; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace payments { | 19 namespace payments { |
| 18 | 20 |
| 19 class PaymentRequestDelegate; | 21 class PaymentRequestDelegate; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 payments::mojom::PaymentDetailsPtr details, | 36 payments::mojom::PaymentDetailsPtr details, |
| 35 payments::mojom::PaymentOptionsPtr options) override; | 37 payments::mojom::PaymentOptionsPtr options) override; |
| 36 void Show() override; | 38 void Show() override; |
| 37 void UpdateWith(payments::mojom::PaymentDetailsPtr details) override {} | 39 void UpdateWith(payments::mojom::PaymentDetailsPtr details) override {} |
| 38 void Abort() override {} | 40 void Abort() override {} |
| 39 void Complete(payments::mojom::PaymentComplete result) override {} | 41 void Complete(payments::mojom::PaymentComplete result) override {} |
| 40 void CanMakePayment() override {} | 42 void CanMakePayment() override {} |
| 41 | 43 |
| 42 void Cancel(); | 44 void Cancel(); |
| 43 void OnError(); | 45 void OnError(); |
| 46 |
| 47 // Returns the CurrencyFormatter instance for this PaymentRequest. |
| 48 // |locale_name| should be the result of the browser's GetApplicationLocale(). |
| 49 // Note: Having multiple currencies per PaymentRequest is not supported; hence |
| 50 // the CurrencyFormatter is cached here. |
| 51 CurrencyFormatter* GetOrCreateCurrencyFormatter( |
| 52 const std::string& currency_code, |
| 53 const base::Optional<std::string> currency_system, |
| 54 const std::string& locale_name); |
| 55 |
| 44 payments::mojom::PaymentDetails* details() { return details_.get(); } | 56 payments::mojom::PaymentDetails* details() { return details_.get(); } |
| 45 | 57 |
| 46 content::WebContents* web_contents() { return web_contents_; } | 58 content::WebContents* web_contents() { return web_contents_; } |
| 47 | 59 |
| 48 private: | 60 private: |
| 49 content::WebContents* web_contents_; | 61 content::WebContents* web_contents_; |
| 50 std::unique_ptr<PaymentRequestDelegate> delegate_; | 62 std::unique_ptr<PaymentRequestDelegate> delegate_; |
| 51 // |manager_| owns this PaymentRequest. | 63 // |manager_| owns this PaymentRequest. |
| 52 PaymentRequestWebContentsManager* manager_; | 64 PaymentRequestWebContentsManager* manager_; |
| 53 mojo::Binding<payments::mojom::PaymentRequest> binding_; | 65 mojo::Binding<payments::mojom::PaymentRequest> binding_; |
| 54 payments::mojom::PaymentRequestClientPtr client_; | 66 payments::mojom::PaymentRequestClientPtr client_; |
| 55 payments::mojom::PaymentDetailsPtr details_; | 67 payments::mojom::PaymentDetailsPtr details_; |
| 68 std::unique_ptr<CurrencyFormatter> currency_formatter_; |
| 56 | 69 |
| 57 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); | 70 DISALLOW_COPY_AND_ASSIGN(PaymentRequest); |
| 58 }; | 71 }; |
| 59 | 72 |
| 60 } // namespace payments | 73 } // namespace payments |
| 61 | 74 |
| 62 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ | 75 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_H_ |
| OLD | NEW |