| Index: third_party/WebKit/Source/platform/payments/PaymentRequestProxy.cpp
|
| diff --git a/third_party/WebKit/Source/platform/payments/PaymentRequestProxy.cpp b/third_party/WebKit/Source/platform/payments/PaymentRequestProxy.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dafe85ecc054f52590354b74549c9703496e9c3f
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/payments/PaymentRequestProxy.cpp
|
| @@ -0,0 +1,82 @@
|
| +// 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.
|
| +
|
| +#include "platform/payments/PaymentRequestProxy.h"
|
| +
|
| +#include "mojo/public/cpp/bindings/array.h"
|
| +#include "mojo/public/cpp/bindings/string.h"
|
| +#include "platform/payments/BlinkTypeConverters.h"
|
| +#include "platform/payments/PlatformPaymentDetails.h"
|
| +#include "platform/payments/PlatformPaymentOptions.h"
|
| +#include "platform/payments/PlatformPaymentResponse.h"
|
| +#include "platform/payments/PlatformShippingAddress.h"
|
| +#include "public/platform/Platform.h"
|
| +#include "wtf/Assertions.h"
|
| +
|
| +namespace blink {
|
| +
|
| +PaymentRequestProxy::PaymentRequestProxy(Listener* listener)
|
| + : m_listener(listener)
|
| +{
|
| + ASSERT(m_listener);
|
| +}
|
| +
|
| +PaymentRequestProxy::~PaymentRequestProxy() {}
|
| +
|
| +void PaymentRequestProxy::show(const Vector<String>& supportedMethods,
|
| + const PlatformPaymentDetails& paymentDetails,
|
| + const PlatformPaymentOptions& paymentOptions,
|
| + const String& stringifiedData)
|
| +{
|
| + ASSERT(!m_provider.is_bound());
|
| + blink::Platform::current()->connectToRemoteService(mojo::GetProxy(&m_provider));
|
| +
|
| + if (!m_provider)
|
| + return;
|
| +
|
| + m_provider->Show(mojo::Array<mojo::String>::From(supportedMethods),
|
| + payments::mojom::PaymentDetails::From(paymentDetails),
|
| + payments::mojom::PaymentOptions::From(paymentOptions),
|
| + mojo::String::From(stringifiedData));
|
| +}
|
| +
|
| +void PaymentRequestProxy::abort()
|
| +{
|
| + m_provider->Abort();
|
| + m_provider.reset();
|
| +}
|
| +
|
| +void PaymentRequestProxy::complete(bool success)
|
| +{
|
| + m_provider->Complete(success);
|
| +}
|
| +
|
| +void PaymentRequestProxy::OnShippingAddressChange(payments::mojom::ShippingAddressPtr shippingAddress)
|
| +{
|
| + m_listener->onShippingAddressChange(shippingAddress->To<PlatformShippingAddress>());
|
| +}
|
| +
|
| +void PaymentRequestProxy::OnShippingOptionChange(const mojo::String& shippingOptionId)
|
| +{
|
| + m_listener->onShippingOptionChange(shippingOptionId.To<String>());
|
| +}
|
| +
|
| +void PaymentRequestProxy::OnPaymentResponse(payments::mojom::PaymentResponsePtr paymentResponse)
|
| +{
|
| + m_listener->onPaymentResponse(paymentResponse->To<PlatformPaymentResponse>());
|
| +}
|
| +
|
| +void PaymentRequestProxy::OnError()
|
| +{
|
| + m_provider.reset();
|
| + m_listener->onError();
|
| +}
|
| +
|
| +void PaymentRequestProxy::OnComplete()
|
| +{
|
| + m_provider.reset();
|
| + m_listener->onComplete();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|