OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PaymentRequestProxy_h |
| 6 #define PaymentRequestProxy_h |
| 7 |
| 8 #include "components/payments/payment_request.mojom.h" |
| 9 #include "platform/PlatformExport.h" |
| 10 #include "wtf/Noncopyable.h" |
| 11 #include "wtf/Vector.h" |
| 12 #include "wtf/text/WTFString.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 struct PlatformPaymentDetails; |
| 17 struct PlatformPaymentOptions; |
| 18 struct PlatformPaymentResponse; |
| 19 struct PlatformShippingAddress; |
| 20 |
| 21 // This class connects a PaymentRequestProxy::Listener to the PaymentRequest |
| 22 // Mojo service. Note that currently the access to the Mojo service is limited |
| 23 // in platform/. In future, we'll let classes in core/ and modules/ directly |
| 24 // communicate with Mojo, and then, there will be no need to use this proxy |
| 25 // class. |
| 26 // |
| 27 // TODO(rouslan): Remove this directory once modules/ can use Mojo. |
| 28 class PLATFORM_EXPORT PaymentRequestProxy |
| 29 : public payments::mojom::PaymentRequestClient { |
| 30 WTF_MAKE_NONCOPYABLE(PaymentRequestProxy); |
| 31 |
| 32 public: |
| 33 class Listener { |
| 34 public: |
| 35 virtual ~Listener() = default; |
| 36 |
| 37 virtual void onShippingAddressChange(const PlatformShippingAddress&) = 0
; |
| 38 virtual void onShippingOptionChange(const String& shippingOptionId) = 0; |
| 39 virtual void onPaymentResponse(const PlatformPaymentResponse&) = 0; |
| 40 virtual void onError() = 0; |
| 41 virtual void onComplete() = 0; |
| 42 }; |
| 43 |
| 44 explicit PaymentRequestProxy(Listener*); |
| 45 ~PaymentRequestProxy() override; |
| 46 |
| 47 void show(const Vector<String>& supportedMethods, |
| 48 const PlatformPaymentDetails&, |
| 49 const PlatformPaymentOptions&, |
| 50 const String& stringifiedData); |
| 51 void abort(); |
| 52 void complete(bool success); |
| 53 |
| 54 private: |
| 55 // payments::mojom::PaymentRequestClient |
| 56 void OnShippingAddressChange(payments::mojom::ShippingAddressPtr) override; |
| 57 void OnShippingOptionChange(const mojo::String& shippingOptionId) override; |
| 58 void OnPaymentResponse(payments::mojom::PaymentResponsePtr) override; |
| 59 void OnError() override; |
| 60 void OnComplete() override; |
| 61 |
| 62 payments::mojom::PaymentRequestPtr m_provider; |
| 63 Listener* m_listener; |
| 64 }; |
| 65 |
| 66 } // namespace blink |
| 67 |
| 68 #endif // PaymentRequestProxy_h |
OLD | NEW |