Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 "nsIPaymentRequest.h"
11 : #include "nsIPaymentRequestService.h"
12 : #include "nsISimpleEnumerator.h"
13 : #include "nsCOMPtr.h"
14 : #include "nsTArray.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : // The implmentation of nsIPaymentRequestService
20 :
21 : class PaymentRequestService final : public nsIPaymentRequestService
22 : {
23 : public:
24 : NS_DECL_ISUPPORTS
25 : NS_DECL_NSIPAYMENTREQUESTSERVICE
26 :
27 0 : PaymentRequestService() = default;
28 :
29 : static already_AddRefed<PaymentRequestService> GetSingleton();
30 :
31 : already_AddRefed<nsIPaymentRequest>
32 : GetPaymentRequestByIndex(const uint32_t index);
33 :
34 : uint32_t NumPayments() const;
35 :
36 : private:
37 0 : ~PaymentRequestService() = default;
38 :
39 : nsresult
40 : SetActionCallback(const nsAString& aRequestId,
41 : nsIPaymentActionCallback* aCallback);
42 : nsresult
43 : RemoveActionCallback(const nsAString& aRequestId);
44 :
45 : // this method is only used for testing
46 : nsresult
47 : CallTestingUIAction(const nsAString& aRequestId, uint32_t aActionType);
48 :
49 : FallibleTArray<nsCOMPtr<nsIPaymentRequest>> mRequestQueue;
50 :
51 : nsInterfaceHashtable<nsStringHashKey, nsIPaymentActionCallback> mCallbackHashtable;
52 :
53 : nsCOMPtr<nsIPaymentUIService> mTestingUIService;
54 : };
55 :
56 : } // end of namespace dom
57 : } // end of namespace mozilla
58 :
59 : #endif
|