Backed out changeset b06f19b95b94 (bug 1784438) for causing build bustages CLOSED...
[gecko.git] / toolkit / components / credentialmanagement / CredentialChosenCallback.cpp
bloba6bac0ced4f5f7a3bef91a93aa87e9a65a42e509
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 #include "mozilla/CredentialChosenCallback.h"
8 #include "mozilla/dom/Credential.h"
10 namespace mozilla {
12 using dom::Credential;
13 using dom::Promise;
15 nsresult CredentialChosenCallback::Notify(const nsACString& aCredentialId) {
16 MOZ_ASSERT(NS_IsMainThread());
18 if (!mResult) {
19 return NS_OK;
22 if (aCredentialId.IsVoid()) {
23 mResult->Reject(NS_OK, __func__);
24 mResult = nullptr;
25 return NS_OK;
28 for (auto option : mOptions) {
29 if (option.id().Equals(NS_ConvertUTF8toUTF16(aCredentialId))) {
30 mResult->Resolve(option, __func__);
31 mResult = nullptr;
32 return NS_OK;
36 mResult->Reject(nsresult::NS_ERROR_NO_CONTENT, __func__);
37 mResult = nullptr;
38 return NS_OK;
41 nsresult CredentialChosenCallback::GetName(nsACString& aName) {
42 aName.AssignLiteral("CredentialChosenCallback");
43 return NS_OK;
46 NS_IMPL_ISUPPORTS(CredentialChosenCallback, nsICredentialChosenCallback,
47 nsINamed)
49 } // namespace mozilla