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_PaymentRequestUpdateEvent_h
8 : #define mozilla_dom_PaymentRequestUpdateEvent_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/ErrorResult.h"
12 : #include "mozilla/dom/Event.h"
13 : #include "mozilla/dom/PaymentRequestUpdateEventBinding.h"
14 : #include "mozilla/dom/PromiseNativeHandler.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class Promise;
20 :
21 : class PaymentRequestUpdateEvent final : public Event
22 : , public PromiseNativeHandler
23 : {
24 : public:
25 : NS_DECL_ISUPPORTS_INHERITED
26 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PaymentRequestUpdateEvent, Event)
27 :
28 : explicit PaymentRequestUpdateEvent(EventTarget* aOwner);
29 :
30 : virtual JSObject*
31 : WrapObjectInternal(JSContext* aCx,
32 : JS::Handle<JSObject*> aGivenProto) override;
33 :
34 : virtual void
35 : ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
36 : virtual void
37 : RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
38 :
39 : static already_AddRefed<PaymentRequestUpdateEvent>
40 : Constructor(EventTarget* aOwner,
41 : const nsAString& aType,
42 : const PaymentRequestUpdateEventInit& aEventInitDict);
43 :
44 : static already_AddRefed<PaymentRequestUpdateEvent>
45 : Constructor(const GlobalObject& aGlobal,
46 : const nsAString& aType,
47 : const PaymentRequestUpdateEventInit& aEventInitDict,
48 : ErrorResult& aRv);
49 :
50 : void UpdateWith(Promise& aPromise, ErrorResult& aRv);
51 :
52 : bool IsTrusted() const;
53 :
54 : protected:
55 : ~PaymentRequestUpdateEvent();
56 :
57 : private:
58 : // Indicating whether an updateWith()-initiated update is currently in progress.
59 : bool mWaitForUpdate;
60 : RefPtr<PaymentRequest> mRequest;
61 : };
62 :
63 : } // namespace dom
64 : } // namespace mozilla
65 :
66 : #endif // mozilla_dom_PaymentRequestUpdateEvent_h
|