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_CREDENTIALCHOSENCALLBACK_H_
8 #define MOZILLA_CREDENTIALCHOSENCALLBACK_H_
10 #include "nsICredentialChosenCallback.h"
12 #include "nsStringFwd.h"
15 #include "mozilla/dom/IdentityCredentialSerializationHelpers.h"
16 #include "mozilla/dom/Promise.h"
20 using dom::IPCIdentityCredential
;
23 class CredentialChosenCallback final
: public nsICredentialChosenCallback
,
26 explicit CredentialChosenCallback(
27 CopyableTArray
<IPCIdentityCredential
>&& aOptions
,
28 const RefPtr
<MozPromise
<IPCIdentityCredential
, nsresult
, true>::Private
>&
30 : mOptions(aOptions
), mResult(aResult
) {}
33 Notify(const nsACString
& aCredential
) override
;
36 GetName(nsACString
& aName
) override
;
41 ~CredentialChosenCallback() {
43 mResult
->Reject(NS_ERROR_FAILURE
, __func__
);
47 // mOptions is the list of credentials presented to the user in the credential
48 // chooser. We maintain this list so we can resolve with the user's choice of
50 CopyableTArray
<IPCIdentityCredential
> mOptions
;
52 // mResult is a promise that will fulfill once the user has made a choice.
53 // Dismissal is represented as a reject(NS_OK), and selection resolves with
54 // an entry of mOptions.
55 RefPtr
<MozPromise
<IPCIdentityCredential
, nsresult
, true>::Private
> mResult
;
58 } // namespace mozilla
60 #endif /* MOZILLA_CREDENTIALCHOSENCALLBACK_H_ */