script/dom/credentialmanagement/
credentialscontainer.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4use std::rc::Rc;
5
6use dom_struct::dom_struct;
7use script_bindings::codegen::GenericBindings::CredentialsContainerBinding::{
8    CredentialCreationOptions, CredentialRequestOptions,
9};
10use script_bindings::error::{Error, Fallible};
11
12use crate::dom::bindings::codegen::Bindings::CredentialsContainerBinding::CredentialsContainerMethods;
13use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
14use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
15use crate::dom::bindings::root::DomRoot;
16use crate::dom::credentialmanagement::credential::Credential;
17use crate::dom::globalscope::GlobalScope;
18use crate::dom::promise::Promise;
19use crate::script_runtime::CanGc;
20
21#[dom_struct]
22pub(crate) struct CredentialsContainer {
23    reflector_: Reflector,
24}
25
26impl CredentialsContainer {
27    pub(crate) fn new_inherited() -> CredentialsContainer {
28        CredentialsContainer {
29            reflector_: Reflector::new(),
30        }
31    }
32
33    pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<CredentialsContainer> {
34        reflect_dom_object(
35            Box::new(CredentialsContainer::new_inherited()),
36            global,
37            can_gc,
38        )
39    }
40}
41
42impl CredentialsContainerMethods<DomTypeHolder> for CredentialsContainer {
43    // https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-get
44    fn Get(&self, _options: &CredentialRequestOptions<DomTypeHolder>) -> Fallible<Rc<Promise>> {
45        Err(Error::NotSupported)
46    }
47
48    // https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-store
49    fn Store(&self, _credential: &Credential) -> Fallible<Rc<Promise>> {
50        Err(Error::NotSupported)
51    }
52
53    // https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-create
54    fn Create(&self, _options: &CredentialCreationOptions<DomTypeHolder>) -> Fallible<Rc<Promise>> {
55        Err(Error::NotSupported)
56    }
57
58    // https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-preventsilentaccess
59    fn PreventSilentAccess(&self) -> Fallible<Rc<Promise>> {
60        Err(Error::NotSupported)
61    }
62}