summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Cookie
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/Cookie')
-rw-r--r--Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp39
-rw-r--r--Userland/Libraries/LibWeb/Cookie/ParsedCookie.h8
2 files changed, 47 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
index 8f4b7e058e..6d0d0d4940 100644
--- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
+++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
@@ -25,7 +25,10 @@
*/
#include "ParsedCookie.h"
+#include <AK/StdLibExtras.h>
#include <AK/Vector.h>
+#include <LibIPC/Decoder.h>
+#include <LibIPC/Encoder.h>
#include <ctype.h>
namespace Web::Cookie {
@@ -351,3 +354,39 @@ Optional<Core::DateTime> parse_date_time(StringView date_string)
}
}
+
+bool IPC::encode(IPC::Encoder& encoder, const Web::Cookie::ParsedCookie& cookie)
+{
+ encoder << cookie.name;
+ encoder << cookie.value;
+ encoder << cookie.expiry_time_from_expires_attribute;
+ encoder << cookie.expiry_time_from_max_age_attribute;
+ encoder << cookie.domain;
+ encoder << cookie.path;
+ encoder << cookie.secure_attribute_present;
+ encoder << cookie.http_only_attribute_present;
+
+ return true;
+}
+
+bool IPC::decode(IPC::Decoder& decoder, Web::Cookie::ParsedCookie& cookie)
+{
+ if (!decoder.decode(cookie.name))
+ return false;
+ if (!decoder.decode(cookie.value))
+ return false;
+ if (!decoder.decode(cookie.expiry_time_from_expires_attribute))
+ return false;
+ if (!decoder.decode(cookie.expiry_time_from_max_age_attribute))
+ return false;
+ if (!decoder.decode(cookie.domain))
+ return false;
+ if (!decoder.decode(cookie.path))
+ return false;
+ if (!decoder.decode(cookie.secure_attribute_present))
+ return false;
+ if (!decoder.decode(cookie.http_only_attribute_present))
+ return false;
+
+ return true;
+}
diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
index c48103b28e..5d3c8b8020 100644
--- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
+++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
@@ -29,6 +29,7 @@
#include <AK/Optional.h>
#include <AK/String.h>
#include <LibCore/DateTime.h>
+#include <LibIPC/Forward.h>
namespace Web::Cookie {
@@ -46,3 +47,10 @@ struct ParsedCookie {
Optional<ParsedCookie> parse_cookie(const String& cookie_string);
}
+
+namespace IPC {
+
+bool encode(IPC::Encoder&, const Web::Cookie::ParsedCookie&);
+bool decode(IPC::Decoder&, Web::Cookie::ParsedCookie&);
+
+}