Skip to content

Commit

Permalink
LibWeb/Storage: Add a storage key getter that takes a URL::Origin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shannonbooth authored and tcl3 committed Jan 21, 2025
1 parent ca3d9d9 commit 70df812
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/LibWeb/StorageAPI/StorageKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions Libraries/LibWeb/StorageAPI/StorageKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);

}
Expand Down

0 comments on commit 70df812

Please sign in to comment.