Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / toolkit / components / credentialmanagement / IdentityCredentialRequestManager.h
blobcea1a4a3c01c929adf474ad4abec8053fdb8b575
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_IDENTITYCREDENTIALREQUESTMANAGER_H_
8 #define MOZILLA_IDENTITYCREDENTIALREQUESTMANAGER_H_
10 #include "mozilla/ClearOnShutdown.h"
11 #include "mozilla/PrincipalHashKey.h"
12 #include "mozilla/dom/IdentityCredential.h"
13 #include "mozilla/dom/IdentityCredentialBinding.h"
14 #include "mozilla/dom/IPCIdentityCredential.h"
15 #include "nsIPrincipal.h"
16 #include "nsTHashMap.h"
18 namespace mozilla {
20 class IdentityCredentialRequestManager final : nsISupports {
21 public:
22 NS_DECL_ISUPPORTS
24 static IdentityCredentialRequestManager* GetInstance();
26 // Store an active cross origin identity credential request happening from the
27 // given principal and inner window ID. These accumulate forever, but if the
28 // window goes away, we will be unable to notify of a store.
29 nsresult StorePendingRequest(
30 const nsCOMPtr<nsIPrincipal>& aRPPrincipal,
31 const dom::IdentityCredentialRequestOptions& aRequest,
32 const RefPtr<
33 dom::IdentityCredential::GetIPCIdentityCredentialPromise::Private>&
34 aPromise,
35 const RefPtr<dom::CanonicalBrowsingContext>& aBrowsingContext);
37 // If the given credential stored by the given principal would be effective
38 // for a previously stored request, notify the window that stored that request
39 // with the credential so it can resolve a promise with that credential data.
40 void NotifyOfStoredCredential(const nsCOMPtr<nsIPrincipal>& aIDPPrincipal,
41 const dom::IPCIdentityCredential& aCredential);
43 IdentityCredentialRequestManager(IdentityCredentialRequestManager& other) =
44 delete;
45 void operator=(const IdentityCredentialRequestManager&) = delete;
47 private:
48 static StaticRefPtr<IdentityCredentialRequestManager> sSingleton;
49 IdentityCredentialRequestManager() {};
50 ~IdentityCredentialRequestManager() = default;
52 struct PendingRequestEntry {
53 nsCOMPtr<nsIPrincipal> mRPPrincipal;
54 dom::IdentityCredentialRequestOptions mRequestOptions;
55 RefPtr<dom::IdentityCredential::GetIPCIdentityCredentialPromise::Private>
56 mPromise;
57 RefPtr<dom::CanonicalBrowsingContext> mBrowsingContext;
59 PendingRequestEntry(
60 nsIPrincipal* aRPPrincipal,
61 const dom::IdentityCredentialRequestOptions& aRequestOptions,
62 const RefPtr<
63 dom::IdentityCredential::GetIPCIdentityCredentialPromise::Private>&
64 aPromise,
65 const RefPtr<dom::CanonicalBrowsingContext>& aBrowsingContext)
66 : mRPPrincipal(aRPPrincipal),
67 mRequestOptions(aRequestOptions),
68 mPromise(aPromise),
69 mBrowsingContext(aBrowsingContext) {}
71 nsTHashMap<PrincipalHashKey, nsTArray<PendingRequestEntry>> mPendingRequests;
74 } // namespace mozilla
76 #endif /* MOZILLA_IDENTITYCREDENTIALSTORAGESERVICE_H_ */