2017-10-26 22:08:41 +00: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 17:50:32 +00: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 04:04:04 +00:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2017-05-25 17:50:32 +00:00
|
|
|
#include "nsIPaymentRequestService.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsTArray.h"
|
2018-09-13 13:40:18 +00:00
|
|
|
#include "PaymentRequestData.h"
|
2017-05-25 17:50:32 +00:00
|
|
|
|
2022-05-09 20:41:12 +00:00
|
|
|
namespace mozilla::dom {
|
2017-05-25 17:50:32 +00:00
|
|
|
|
|
|
|
// 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 13:40:18 +00:00
|
|
|
already_AddRefed<payments::PaymentRequest> GetPaymentRequestByIndex(
|
2017-05-25 17:50:32 +00:00
|
|
|
const uint32_t index);
|
|
|
|
|
|
|
|
uint32_t NumPayments() const;
|
|
|
|
|
2018-08-30 12:13:33 +00:00
|
|
|
nsresult RequestPayment(const nsAString& aRequestId,
|
|
|
|
const IPCPaymentActionRequest& aAction,
|
|
|
|
PaymentRequestParent* aCallback);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-05-25 17:50:32 +00:00
|
|
|
private:
|
|
|
|
~PaymentRequestService() = default;
|
|
|
|
|
2018-09-13 13:40:18 +00:00
|
|
|
nsresult GetPaymentRequestById(const nsAString& aRequestId,
|
|
|
|
payments::PaymentRequest** aRequest);
|
|
|
|
|
2017-08-04 09:24:59 +00:00
|
|
|
nsresult LaunchUIAction(const nsAString& aRequestId, uint32_t aActionType);
|
2017-06-14 07:59:00 +00:00
|
|
|
|
2017-08-28 03:55:59 +00:00
|
|
|
bool CanMakePayment(const nsAString& aRequestId);
|
|
|
|
|
2018-11-21 10:03:21 +00:00
|
|
|
nsresult ShowPayment(const nsAString& aRequestId, bool aIsUpdating);
|
2018-09-20 12:03:19 +00:00
|
|
|
|
2017-07-26 08:07:07 +00:00
|
|
|
bool IsBasicCardPayment(const nsAString& aRequestId);
|
|
|
|
|
2018-09-13 13:40:18 +00:00
|
|
|
FallibleTArray<RefPtr<payments::PaymentRequest>> mRequestQueue;
|
2017-06-14 07:59:00 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPaymentUIService> mTestingUIService;
|
2017-07-25 07:39:39 +00:00
|
|
|
|
2018-09-13 13:40:18 +00:00
|
|
|
RefPtr<payments::PaymentRequest> mShowingRequest;
|
2017-05-25 17:50:32 +00:00
|
|
|
};
|
|
|
|
|
2022-05-09 20:41:12 +00:00
|
|
|
} // namespace mozilla::dom
|
2017-05-25 17:50:32 +00:00
|
|
|
|
|
|
|
#endif
|