mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-28 04:00:33 +00:00
This adds the basic infrastructure for the Permissions API, including the `Permissions` and `PermissionStatus` interfaces. The API is exposed via `navigator.permissions` on both `Window` and `WorkerGlobalScope`. - `is_permission_supported` is hardcoded to return false. - The `query()` method checks for a secure context but rejects all queries since no powerful features are supported yet. The permission store and permission key related methods and algorithms. Ability for the user agent to store the permissions entries. Passes a few more subtests in `permissions/`. https://wpt.live/permissions/idlharness.any.html https://wpt.live/permissions/idlharness.any.worker.html https://wpt.live/permissions/edge-cases.https.html This one behaves differently because now the `query` property is defined. And the last subtest passes for the wrong reason. "Querying "fullscreen" permission with "allowWithoutGesture" false is unsupported" but in fact everything is currently unsupported. https://wpt.live/fullscreen/api/permission.tentative.https.html permission is marked as experimental in Navigator and WorkerNavigator, so tests that now pass actually don't because the tests don't have access to the interfaces.
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2026, Niccolo Antonelli-Dziri <niccolo.antonelli-dziri@protonmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Optional.h>
|
|
#include <AK/String.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibURL/Origin.h>
|
|
#include <LibWeb/Bindings/PermissionStatus.h>
|
|
#include <LibWeb/Bindings/Permissions.h>
|
|
#include <LibWeb/PermissionsAPI/Permissions.h>
|
|
|
|
namespace Web::PermissionsAPI {
|
|
|
|
// https://w3c.github.io/permissions/#dfn-permission-store-entry
|
|
struct PermissionStoreEntry {
|
|
Bindings::PermissionDescriptor descriptor;
|
|
URL::Origin permission_key; // https://w3c.github.io/permissions/#dfn-permission-key
|
|
Bindings::PermissionState state;
|
|
};
|
|
|
|
// https://w3c.github.io/permissions/#dfn-permission-store
|
|
class PermissionStore {
|
|
public:
|
|
static PermissionStore& the();
|
|
|
|
// https://w3c.github.io/permissions/#dfn-get-a-permission-store-entry
|
|
Optional<PermissionStoreEntry> get_permission_store_entry(Bindings::PermissionDescriptor const& descriptor, URL::Origin const& key);
|
|
|
|
// https://w3c.github.io/permissions/#dfn-set-a-permission-store-entry
|
|
void set_permission_store_entry(Bindings::PermissionDescriptor const& descriptor, URL::Origin const& key, Bindings::PermissionState state);
|
|
|
|
// https://w3c.github.io/permissions/#dfn-remove-a-permission-store-entry
|
|
void remove_permission_store_entry(Bindings::PermissionDescriptor const& descriptor, URL::Origin const& key);
|
|
|
|
private:
|
|
PermissionStore() = default;
|
|
|
|
Vector<PermissionStoreEntry> m_entries;
|
|
};
|
|
|
|
bool permission_key_is_equal_to(Bindings::PermissionDescriptor const& descriptor, URL::Origin const& key1, URL::Origin const& key2);
|
|
|
|
bool permission_key_comparison_algorithm(URL::Origin const& key1, URL::Origin const& key2);
|
|
|
|
URL::Origin permission_key_generation_algorithm(URL::Origin const& origin, URL::Origin const&);
|
|
|
|
}
|