mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Implement StorageKey and related AOs from Storage specification
This commit is contained in:
parent
1d43d5b086
commit
f0270b92f1
Notes:
github-actions[bot]
2024-09-20 21:42:31 +00:00
Author: https://github.com/ADKaster
Commit: f0270b92f1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1404
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 77 additions and 0 deletions
34
Userland/Libraries/LibWeb/StorageAPI/StorageKey.h
Normal file
34
Userland/Libraries/LibWeb/StorageAPI/StorageKey.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
// https://storage.spec.whatwg.org/#storage-keys
|
||||
struct StorageKey {
|
||||
|
||||
// A storage key is a tuple consisting of an origin (an origin). [HTML]
|
||||
// NOTE: This is expected to change; see Client-Side Storage Partitioning https://privacycg.github.io/storage-partitioning/.
|
||||
HTML::Origin origin;
|
||||
|
||||
friend bool operator==(StorageKey const& a, StorageKey const& b)
|
||||
{
|
||||
// To determine whether a storage key A equals storage key B, run these steps:
|
||||
// 1. If A’s origin is not same origin with B’s origin, then return false.
|
||||
// 2. Return true.
|
||||
return a.origin.is_same_origin(b.origin);
|
||||
}
|
||||
};
|
||||
|
||||
Optional<StorageKey> obtain_a_storage_key(HTML::Environment const&);
|
||||
StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue