Index: third_party/WebKit/Source/platform/payments/PaymentRequestProxy.h |
diff --git a/third_party/WebKit/Source/platform/payments/PaymentRequestProxy.h b/third_party/WebKit/Source/platform/payments/PaymentRequestProxy.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c6e1edb655df528d01d89ad7e2ab8dd54b1f0cc8 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/payments/PaymentRequestProxy.h |
@@ -0,0 +1,68 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef PaymentRequestProxy_h |
+#define PaymentRequestProxy_h |
+ |
+#include "components/payments/payment_request.mojom.h" |
+#include "platform/PlatformExport.h" |
+#include "wtf/Noncopyable.h" |
+#include "wtf/Vector.h" |
+#include "wtf/text/WTFString.h" |
+ |
+namespace blink { |
+ |
+struct PlatformPaymentDetails; |
+struct PlatformPaymentOptions; |
+struct PlatformPaymentResponse; |
+struct PlatformShippingAddress; |
+ |
+// This class connects a PaymentRequestProxy::Listener to the PaymentRequest |
+// Mojo service. Note that currently the access to the Mojo service is limited |
+// in platform/. In future, we'll let classes in core/ and modules/ directly |
+// communicate with Mojo, and then, there will be no need to use this proxy |
+// class. |
+// |
+// TODO(rouslan): Remove this directory once modules/ can use Mojo. |
+class PLATFORM_EXPORT PaymentRequestProxy |
+ : public payments::mojom::PaymentRequestClient { |
+ WTF_MAKE_NONCOPYABLE(PaymentRequestProxy); |
+ |
+public: |
+ class Listener { |
+ public: |
+ virtual ~Listener() = default; |
+ |
+ virtual void onShippingAddressChange(const PlatformShippingAddress&) = 0; |
+ virtual void onShippingOptionChange(const String& shippingOptionId) = 0; |
+ virtual void onPaymentResponse(const PlatformPaymentResponse&) = 0; |
+ virtual void onError() = 0; |
+ virtual void onComplete() = 0; |
+ }; |
+ |
+ explicit PaymentRequestProxy(Listener*); |
+ ~PaymentRequestProxy() override; |
+ |
+ void show(const Vector<String>& supportedMethods, |
+ const PlatformPaymentDetails&, |
+ const PlatformPaymentOptions&, |
+ const String& stringifiedData); |
+ void abort(); |
+ void complete(bool success); |
+ |
+private: |
+ // payments::mojom::PaymentRequestClient |
+ void OnShippingAddressChange(payments::mojom::ShippingAddressPtr) override; |
+ void OnShippingOptionChange(const mojo::String& shippingOptionId) override; |
+ void OnPaymentResponse(payments::mojom::PaymentResponsePtr) override; |
+ void OnError() override; |
+ void OnComplete() override; |
+ |
+ payments::mojom::PaymentRequestPtr m_provider; |
+ Listener* m_listener; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // PaymentRequestProxy_h |