MerchantValidationEvent.h (2441B)
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_MerchantValidationEvent_h 8 #define mozilla_dom_MerchantValidationEvent_h 9 10 #include "mozilla/dom/Event.h" 11 #include "mozilla/dom/MerchantValidationEventBinding.h" 12 #include "mozilla/dom/PromiseNativeHandler.h" 13 14 class nsIURI; 15 16 namespace mozilla { 17 class ErrorResult; 18 19 namespace dom { 20 21 class Promise; 22 class PaymentRequest; 23 class MerchantValidationEvent : public Event, public PromiseNativeHandler { 24 public: 25 NS_DECL_ISUPPORTS_INHERITED 26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( 27 MerchantValidationEvent, Event) 28 29 explicit MerchantValidationEvent(EventTarget* aOwner); 30 31 virtual JSObject* WrapObjectInternal( 32 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; 33 34 virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, 35 ErrorResult& aRv) override; 36 virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, 37 ErrorResult& aRv) override; 38 39 static already_AddRefed<MerchantValidationEvent> Constructor( 40 EventTarget* aOwner, const nsAString& aType, 41 const MerchantValidationEventInit& aEventInitDict, ErrorResult& aRv); 42 43 // Called by WebIDL constructor 44 static already_AddRefed<MerchantValidationEvent> Constructor( 45 const GlobalObject& aGlobal, const nsAString& aType, 46 const MerchantValidationEventInit& aEventInitDict, ErrorResult& aRv); 47 48 void Complete(Promise& aPromise, ErrorResult& aRv); 49 50 void SetRequest(PaymentRequest* aRequest); 51 52 void GetValidationURL(nsAString& aValidationURL); 53 54 void GetMethodName(nsAString& aMethodName); 55 56 void SetMethodName(const nsAString& aMethodName); 57 58 protected: 59 void init(const MerchantValidationEventInit& aEventInitDict, 60 ErrorResult& aRv); 61 ~MerchantValidationEvent(); 62 63 private: 64 // Indicating whether an Complete()-initiated update is currently in progress. 65 bool mWaitForUpdate; 66 nsCOMPtr<nsIURI> mValidationURL; 67 RefPtr<PaymentRequest> mRequest; 68 nsString mMethodName; 69 }; 70 71 } // namespace dom 72 } // namespace mozilla 73 74 #endif // mozilla_dom_MerchantValidationEvent_h