Files
ladybird/Libraries/LibWeb/CredentialManagement/PasswordCredential.cpp
Shannon Booth 5adfd1c43a LibWeb/Bindings: Generate struct definitions from IDL dictionaries
Previously we were inconsistent by generating code for enum definitions
but not generating code for dictionaries. With future changes to the
IDL generator to expose helpers to convert to and from IDL values
this produced circular depdendencies. To solve this problem, also
generate the dictionary definitions in bindings headers.
2026-05-09 10:49:49 +02:00

55 lines
2.0 KiB
C++

/*
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/CredentialManagement/PasswordCredential.h>
#include <LibWeb/CredentialManagement/PasswordCredentialOperations.h>
namespace Web::CredentialManagement {
GC_DEFINE_ALLOCATOR(PasswordCredential);
// https://www.w3.org/TR/credential-management-1/#dom-passwordcredential-passwordcredential
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> PasswordCredential::construct_impl(JS::Realm& realm, GC::Ref<HTML::HTMLFormElement> form)
{
// 1. Let origin be the current settings object's origin.
auto origin = HTML::current_settings_object().origin();
// 2. Let r be the result of executing Create a PasswordCredential from an HTMLFormElement given form and origin.
// 3. If r is an exception, throw r. Otherwise, return r.
return create_password_credential(realm, form, move(origin));
}
// https://www.w3.org/TR/credential-management-1/#dom-passwordcredential-passwordcredential-data
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> PasswordCredential::construct_impl(JS::Realm& realm, Bindings::PasswordCredentialData const& data)
{
// AD-HOC: Let origin be the current settings object's origin.
auto origin = HTML::current_settings_object().origin();
// 1. Let r be the result of executing Create a PasswordCredential from PasswordCredentialData on data.
// 2. If r is an exception, throw r.
return create_password_credential(realm, data, move(origin));
}
PasswordCredential::~PasswordCredential()
{
}
PasswordCredential::PasswordCredential(JS::Realm& realm, Bindings::PasswordCredentialData const& data, URL::Origin origin)
: Credential(realm, data.id)
, CredentialUserData(data.name.value_or(String {}), data.icon_url.value_or(String {}))
, m_password(data.password)
, m_origin(move(origin))
{
}
void PasswordCredential::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(PasswordCredential);
Base::initialize(realm);
}
}