LibWeb/Storage: Add a storage key getter that takes a URL::Origin

When we serialize blob URL entries we do not serialize the entire
environment settings object and only use it's origin. To allow
a Blob URL entry to access its relevant storage key, add a getter
that simply takes an origin.
This commit is contained in:
Shannon Booth 2025-01-19 18:15:06 +13:00 committed by Tim Ledbetter
parent ca3d9d9ee0
commit 70df8122b1
Notes: github-actions[bot] 2025-01-21 19:23:14 +00:00
2 changed files with 7 additions and 0 deletions

View file

@ -26,6 +26,12 @@ Optional<StorageKey> obtain_a_storage_key(HTML::Environment const& environment)
return key;
}
StorageKey obtain_a_storage_key_for_non_storage_purposes(URL::Origin const& origin)
{
// NOTE: This function exists as there are cases where we don't have the full environment object, but we still need to obtain a storage key.
return { origin };
}
// 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)
{

View file

@ -30,6 +30,7 @@ struct StorageKey {
};
Optional<StorageKey> obtain_a_storage_key(HTML::Environment const&);
StorageKey obtain_a_storage_key_for_non_storage_purposes(URL::Origin const&);
StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
}