2017-10-27 01:08:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-05-25 20:50:32 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_PaymentRequestService_h
|
|
|
|
#define mozilla_dom_PaymentRequestService_h
|
|
|
|
|
2018-02-01 07:04:04 +03:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2017-05-25 20:50:32 +03:00
|
|
|
#include "nsIPaymentRequestService.h"
|
|
|
|
#include "nsISimpleEnumerator.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsTArray.h"
|
2018-09-13 16:40:18 +03:00
|
|
|
#include "PaymentRequestData.h"
|
2017-05-25 20:50:32 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
// The implmentation of nsIPaymentRequestService
|
|
|
|
|
|
|
|
class PaymentRequestService final : public nsIPaymentRequestService
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIPAYMENTREQUESTSERVICE
|
|
|
|
|
|
|
|
PaymentRequestService() = default;
|
|
|
|
|
|
|
|
static already_AddRefed<PaymentRequestService> GetSingleton();
|
|
|
|
|
2018-09-13 16:40:18 +03:00
|
|
|
already_AddRefed<payments::PaymentRequest>
|
2017-05-25 20:50:32 +03:00
|
|
|
GetPaymentRequestByIndex(const uint32_t index);
|
|
|
|
|
|
|
|
uint32_t NumPayments() const;
|
|
|
|
|
2018-08-30 15:13:33 +03:00
|
|
|
nsresult RequestPayment(const nsAString& aRequestId,
|
|
|
|
const IPCPaymentActionRequest& aAction,
|
|
|
|
PaymentRequestParent* aCallback);
|
2017-05-25 20:50:32 +03:00
|
|
|
private:
|
|
|
|
~PaymentRequestService() = default;
|
|
|
|
|
2018-09-13 16:40:18 +03:00
|
|
|
nsresult GetPaymentRequestById(const nsAString& aRequestId,
|
|
|
|
payments::PaymentRequest** aRequest);
|
|
|
|
|
2017-06-14 10:59:00 +03:00
|
|
|
nsresult
|
2017-08-04 12:24:59 +03:00
|
|
|
LaunchUIAction(const nsAString& aRequestId, uint32_t aActionType);
|
2017-06-14 10:59:00 +03:00
|
|
|
|
2017-08-28 06:55:59 +03:00
|
|
|
bool
|
|
|
|
CanMakePayment(const nsAString& aRequestId);
|
|
|
|
|
2018-09-20 15:03:19 +03:00
|
|
|
nsresult
|
|
|
|
ShowPayment(const nsAString& aRequestId);
|
|
|
|
|
2017-07-26 11:07:07 +03:00
|
|
|
bool
|
|
|
|
IsBasicCardPayment(const nsAString& aRequestId);
|
|
|
|
|
2018-09-13 16:40:18 +03:00
|
|
|
FallibleTArray<RefPtr<payments::PaymentRequest>> mRequestQueue;
|
2017-06-14 10:59:00 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPaymentUIService> mTestingUIService;
|
2017-07-25 10:39:39 +03:00
|
|
|
|
2018-09-13 16:40:18 +03:00
|
|
|
RefPtr<payments::PaymentRequest> mShowingRequest;
|
2017-05-25 20:50:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace dom
|
|
|
|
} // end of namespace mozilla
|
|
|
|
|
|
|
|
#endif
|