PaymentRequestService.h (1852B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_PaymentRequestService_h 8 #define mozilla_dom_PaymentRequestService_h 9 10 #include "PaymentRequestData.h" 11 #include "nsCOMPtr.h" 12 #include "nsIPaymentRequestService.h" 13 #include "nsInterfaceHashtable.h" 14 #include "nsTArray.h" 15 16 namespace mozilla::dom { 17 18 // The implmentation of nsIPaymentRequestService 19 20 class PaymentRequestService final : public nsIPaymentRequestService { 21 public: 22 NS_DECL_ISUPPORTS 23 NS_DECL_NSIPAYMENTREQUESTSERVICE 24 25 PaymentRequestService() = default; 26 27 static already_AddRefed<PaymentRequestService> GetSingleton(); 28 29 already_AddRefed<payments::PaymentRequest> GetPaymentRequestByIndex( 30 const uint32_t index); 31 32 uint32_t NumPayments() const; 33 34 nsresult RequestPayment(const nsAString& aRequestId, 35 const IPCPaymentActionRequest& aAction, 36 PaymentRequestParent* aCallback); 37 38 private: 39 ~PaymentRequestService() = default; 40 41 nsresult GetPaymentRequestById(const nsAString& aRequestId, 42 payments::PaymentRequest** aRequest); 43 44 nsresult LaunchUIAction(const nsAString& aRequestId, uint32_t aActionType); 45 46 bool CanMakePayment(const nsAString& aRequestId); 47 48 nsresult ShowPayment(const nsAString& aRequestId, bool aIsUpdating); 49 50 bool IsBasicCardPayment(const nsAString& aRequestId); 51 52 FallibleTArray<RefPtr<payments::PaymentRequest>> mRequestQueue; 53 54 nsCOMPtr<nsIPaymentUIService> mTestingUIService; 55 56 RefPtr<payments::PaymentRequest> mShowingRequest; 57 }; 58 59 } // namespace mozilla::dom 60 61 #endif