script/dom/credentialmanagement/
credential.rs1use std::rc::Rc;
5
6use dom_struct::dom_struct;
7use js::context::JSContext;
8use js::realm::CurrentRealm;
9use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
10use script_bindings::str::{DOMString, USVString};
11
12use crate::dom::bindings::codegen::Bindings::CredentialBinding::CredentialMethods;
13use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
14use crate::dom::bindings::root::DomRoot;
15use crate::dom::globalscope::GlobalScope;
16use crate::dom::promise::Promise;
17use crate::dom::window::Window;
18
19#[dom_struct]
20pub(crate) struct Credential {
21 reflector_: Reflector,
22 id: USVString,
23 credential_type: DOMString,
24}
25
26impl Credential {
27 pub(crate) fn new_inherited(id: USVString, credential_type: DOMString) -> Credential {
28 Credential {
29 reflector_: Reflector::new(),
30 id,
31 credential_type,
32 }
33 }
34
35 #[expect(dead_code)]
36 pub(crate) fn new(
37 cx: &mut JSContext,
38 global: &GlobalScope,
39 id: USVString,
40 credential_type: DOMString,
41 ) -> DomRoot<Credential> {
42 reflect_dom_object_with_cx(
43 Box::new(Credential::new_inherited(id, credential_type)),
44 global,
45 cx,
46 )
47 }
48}
49
50impl CredentialMethods<DomTypeHolder> for Credential {
51 fn Id(&self) -> USVString {
53 self.id.clone()
54 }
55
56 fn Type(&self) -> DOMString {
58 self.credential_type.clone()
59 }
60
61 fn IsConditionalMediationAvailable(cx: &mut CurrentRealm, _global: &Window) -> Rc<Promise> {
63 Promise::new_in_realm(cx)
64 }
65
66 fn WillRequestConditionalCreation(cx: &mut CurrentRealm, _global: &Window) -> Rc<Promise> {
68 Promise::new_in_realm(cx)
69 }
70}