script/dom/credentialmanagement/
credential.rs1use std::rc::Rc;
5
6use dom_struct::dom_struct;
7use js::realm::CurrentRealm;
8use script_bindings::reflector::{Reflector, reflect_dom_object};
9use script_bindings::str::{DOMString, USVString};
10
11use crate::dom::bindings::codegen::Bindings::CredentialBinding::CredentialMethods;
12use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::globalscope::GlobalScope;
15use crate::dom::promise::Promise;
16use crate::dom::window::Window;
17use crate::script_runtime::CanGc;
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 global: &GlobalScope,
38 id: USVString,
39 credential_type: DOMString,
40 can_gc: CanGc,
41 ) -> DomRoot<Credential> {
42 reflect_dom_object(
43 Box::new(Credential::new_inherited(id, credential_type)),
44 global,
45 can_gc,
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}