Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/payments/PaymentRequestService.h
Line
Count
Source (jump to first uncovered line)
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 "nsInterfaceHashtable.h"
11
#include "nsIPaymentRequestService.h"
12
#include "nsISimpleEnumerator.h"
13
#include "nsCOMPtr.h"
14
#include "nsTArray.h"
15
#include "PaymentRequestData.h"
16
17
namespace mozilla {
18
namespace dom {
19
20
// The implmentation of nsIPaymentRequestService
21
22
class PaymentRequestService final : public nsIPaymentRequestService
23
{
24
public:
25
  NS_DECL_ISUPPORTS
26
  NS_DECL_NSIPAYMENTREQUESTSERVICE
27
28
0
  PaymentRequestService() = default;
29
30
  static already_AddRefed<PaymentRequestService> GetSingleton();
31
32
  already_AddRefed<payments::PaymentRequest>
33
  GetPaymentRequestByIndex(const uint32_t index);
34
35
  uint32_t NumPayments() const;
36
37
  nsresult RequestPayment(const nsAString& aRequestId,
38
                          const IPCPaymentActionRequest& aAction,
39
                          PaymentRequestParent* aCallback);
40
private:
41
0
  ~PaymentRequestService() = default;
42
43
  nsresult GetPaymentRequestById(const nsAString& aRequestId,
44
                                 payments::PaymentRequest** aRequest);
45
46
  nsresult
47
  LaunchUIAction(const nsAString& aRequestId, uint32_t aActionType);
48
49
  bool
50
  CanMakePayment(const nsAString& aRequestId);
51
52
  nsresult
53
  ShowPayment(const nsAString& aRequestId);
54
55
  bool
56
  IsBasicCardPayment(const nsAString& aRequestId);
57
58
  FallibleTArray<RefPtr<payments::PaymentRequest>> mRequestQueue;
59
60
  nsCOMPtr<nsIPaymentUIService> mTestingUIService;
61
62
  RefPtr<payments::PaymentRequest> mShowingRequest;
63
};
64
65
} // end of namespace dom
66
} // end of namespace mozilla
67
68
#endif