WebIdentityHandler.h (2069B)
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_WebIdentityHandler_h 8 #define mozilla_dom_WebIdentityHandler_h 9 10 #include "mozilla/dom/AbortFollower.h" 11 #include "mozilla/dom/CredentialManagementBinding.h" 12 #include "mozilla/dom/Promise.h" 13 #include "mozilla/dom/WebIdentityChild.h" 14 #include "nsCycleCollectionParticipant.h" 15 #include "nsPIDOMWindow.h" 16 17 namespace mozilla::dom { 18 19 class WebIdentityHandler final : public AbortFollower { 20 public: 21 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 22 NS_DECL_CYCLE_COLLECTION_CLASS(WebIdentityHandler) 23 24 explicit WebIdentityHandler(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) { 25 MOZ_ASSERT(NS_IsMainThread()); 26 MOZ_ASSERT(aWindow); 27 } 28 29 bool MaybeCreateActor(); 30 void ActorDestroyed(); 31 32 // AbortFollower 33 void RunAbortAlgorithm() override; 34 35 void GetCredential(const CredentialRequestOptions& aOptions, 36 bool aSameOriginWithAncestors, 37 const RefPtr<Promise>& aPromise); 38 39 void PreventSilentAccess(const RefPtr<Promise>& aPromise); 40 41 void Disconnect(const IdentityCredentialDisconnectOptions& aOptions, 42 const RefPtr<Promise>& aPromise); 43 44 void SetLoginStatus(const LoginStatus& aStatus, 45 const RefPtr<Promise>& aPromise); 46 47 RefPtr<MozPromise<nsresult, nsresult, true>> ResolveContinuationWindow( 48 const nsACString& aToken, const IdentityResolveOptions& aOptions); 49 50 RefPtr<MozPromise<bool, nsresult, true>> IsContinuationWindow(); 51 52 nsPIDOMWindowInner* GetWindow() { 53 MOZ_ASSERT(mWindow); 54 return mWindow; 55 } 56 57 private: 58 ~WebIdentityHandler(); 59 nsCOMPtr<nsPIDOMWindowInner> mWindow; 60 RefPtr<WebIdentityChild> mActor; 61 RefPtr<Promise> mGetPromise; 62 }; 63 64 } // namespace mozilla::dom 65 66 #endif // mozilla_dom_WebIdentityHandler_h