mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-16 15:21:56 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
42
Libraries/LibWeb/StorageAPI/StorageKey.cpp
Normal file
42
Libraries/LibWeb/StorageAPI/StorageKey.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOMURL/DOMURL.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
// https://storage.spec.whatwg.org/#obtain-a-storage-key
|
||||
Optional<StorageKey> obtain_a_storage_key(HTML::Environment const& environment)
|
||||
{
|
||||
// 1. Let key be the result of running obtain a storage key for non-storage purposes with environment.
|
||||
auto key = obtain_a_storage_key_for_non_storage_purposes(environment);
|
||||
|
||||
// 2. If key’s origin is an opaque origin, then return failure.
|
||||
if (key.origin.is_opaque())
|
||||
return {};
|
||||
|
||||
// FIXME: 3. If the user has disabled storage, then return failure.
|
||||
|
||||
// 4. Return key.
|
||||
return key;
|
||||
}
|
||||
|
||||
// https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes
|
||||
StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const& environment)
|
||||
{
|
||||
// 1. Let origin be environment’s origin if environment is an environment settings object; otherwise environment’s creation URL’s origin.
|
||||
if (is<HTML::EnvironmentSettingsObject>(environment)) {
|
||||
auto const& settings = static_cast<HTML::EnvironmentSettingsObject const&>(environment);
|
||||
// FIXME: EnvironmentSettingsObject::origin() should be const :|
|
||||
auto& mutable_settings = const_cast<HTML::EnvironmentSettingsObject&>(settings);
|
||||
return { mutable_settings.origin() };
|
||||
}
|
||||
return { environment.creation_url.origin() };
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue