Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 : #include "mozilla/dom/PublicKeyCredential.h"
8 : #include "mozilla/dom/WebAuthenticationBinding.h"
9 : #include "nsCycleCollectionParticipant.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(PublicKeyCredential, Credential, mResponse)
15 :
16 0 : NS_IMPL_ADDREF_INHERITED(PublicKeyCredential, Credential)
17 0 : NS_IMPL_RELEASE_INHERITED(PublicKeyCredential, Credential)
18 :
19 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PublicKeyCredential)
20 0 : NS_INTERFACE_MAP_END_INHERITING(Credential)
21 :
22 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PublicKeyCredential, Credential)
23 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
24 :
25 0 : PublicKeyCredential::PublicKeyCredential(nsPIDOMWindowInner* aParent)
26 0 : : Credential(aParent)
27 0 : {}
28 :
29 0 : PublicKeyCredential::~PublicKeyCredential()
30 0 : {}
31 :
32 : JSObject*
33 0 : PublicKeyCredential::WrapObject(JSContext* aCx,
34 : JS::Handle<JSObject*> aGivenProto)
35 : {
36 0 : return PublicKeyCredentialBinding::Wrap(aCx, this, aGivenProto);
37 : }
38 :
39 : void
40 0 : PublicKeyCredential::GetRawId(JSContext* aCx,
41 : JS::MutableHandle<JSObject*> aRetVal) const
42 : {
43 0 : aRetVal.set(mRawId.ToUint8Array(aCx));
44 0 : }
45 :
46 : already_AddRefed<AuthenticatorResponse>
47 0 : PublicKeyCredential::Response() const
48 : {
49 0 : RefPtr<AuthenticatorResponse> temp(mResponse);
50 0 : return temp.forget();
51 : }
52 :
53 : nsresult
54 0 : PublicKeyCredential::SetRawId(CryptoBuffer& aBuffer)
55 : {
56 0 : if (NS_WARN_IF(!mRawId.Assign(aBuffer))) {
57 0 : return NS_ERROR_OUT_OF_MEMORY;
58 : }
59 0 : return NS_OK;
60 : }
61 :
62 : void
63 0 : PublicKeyCredential::SetResponse(RefPtr<AuthenticatorResponse> aResponse)
64 : {
65 0 : mResponse = aResponse;
66 0 : }
67 :
68 : } // namespace dom
69 : } // namespace mozilla
|