StorageKey.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Optional.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/HTML/Origin.h>
  10. namespace Web::StorageAPI {
  11. // https://storage.spec.whatwg.org/#storage-keys
  12. struct StorageKey {
  13. // A storage key is a tuple consisting of an origin (an origin). [HTML]
  14. // NOTE: This is expected to change; see Client-Side Storage Partitioning https://privacycg.github.io/storage-partitioning/.
  15. HTML::Origin origin;
  16. friend bool operator==(StorageKey const& a, StorageKey const& b)
  17. {
  18. // To determine whether a storage key A equals storage key B, run these steps:
  19. // 1. If A’s origin is not same origin with B’s origin, then return false.
  20. // 2. Return true.
  21. return a.origin.is_same_origin(b.origin);
  22. }
  23. };
  24. Optional<StorageKey> obtain_a_storage_key(HTML::Environment const&);
  25. StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
  26. }