Cookie.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DeprecatedString.h>
  8. #include <AK/Time.h>
  9. #include <LibIPC/Forward.h>
  10. namespace Web::Cookie {
  11. enum class SameSite {
  12. Default,
  13. None,
  14. Strict,
  15. Lax
  16. };
  17. enum class Source {
  18. NonHttp,
  19. Http,
  20. };
  21. struct Cookie {
  22. DeprecatedString creation_time_to_string() const;
  23. DeprecatedString last_access_time_to_string() const;
  24. DeprecatedString expiry_time_to_string() const;
  25. DeprecatedString name;
  26. DeprecatedString value;
  27. SameSite same_site;
  28. Time creation_time {};
  29. Time last_access_time {};
  30. Time expiry_time {};
  31. DeprecatedString domain {};
  32. DeprecatedString path {};
  33. bool secure { false };
  34. bool http_only { false };
  35. bool host_only { false };
  36. bool persistent { false };
  37. };
  38. StringView same_site_to_string(SameSite same_site_mode);
  39. SameSite same_site_from_string(StringView same_site_mode);
  40. }
  41. namespace IPC {
  42. template<>
  43. ErrorOr<void> encode(Encoder&, Web::Cookie::Cookie const&);
  44. template<>
  45. ErrorOr<Web::Cookie::Cookie> decode(Decoder&);
  46. }