LibWeb: Add referrer policy to Fetch::Infrastructure::Request

The enum is in its own directory and namespace as there's a standalone
spec for it, that will later also house AOs.

- https://w3c.github.io/webappsec-referrer-policy/
- https://www.w3.org/TR/referrer-policy/
This commit is contained in:
Linus Groh 2022-09-24 00:29:45 +01:00
parent a602a4c780
commit dc6fb43d26
Notes: sideshowbarker 2024-07-17 09:39:38 +09:00
3 changed files with 32 additions and 1 deletions

View File

@ -257,6 +257,9 @@ public:
[[nodiscard]] ReferrerType const& referrer() const { return m_referrer; }
void set_referrer(ReferrerType referrer) { m_referrer = move(referrer); }
[[nodiscard]] Optional<ReferrerPolicy::ReferrerPolicy> const& referrer_policy() const { return m_referrer_policy; }
void set_referrer_policy(Optional<ReferrerPolicy::ReferrerPolicy> referrer_policy) { m_referrer_policy = move(referrer_policy); }
[[nodiscard]] ResponseTainting response_tainting() const { return m_response_tainting; }
void set_response_tainting(ResponseTainting response_tainting) { m_response_tainting = response_tainting; }
@ -364,7 +367,8 @@ private:
ReferrerType m_referrer { Referrer::Client };
// https://fetch.spec.whatwg.org/#concept-request-referrer-policy
// FIXME: A request has an associated referrer policy, which is a referrer policy. Unless stated otherwise it is the empty string.
// A request has an associated referrer policy, which is a referrer policy. Unless stated otherwise it is the empty string.
Optional<ReferrerPolicy::ReferrerPolicy> m_referrer_policy;
// https://fetch.spec.whatwg.org/#concept-request-mode
// A request has an associated mode, which is "same-origin", "cors", "no-cors", "navigate", or "websocket". Unless stated otherwise, it is "no-cors".

View File

@ -357,6 +357,10 @@ namespace Web::Platform {
class Timer;
}
namespace Web::ReferrerPolicy {
enum class ReferrerPolicy;
}
namespace Web::RequestIdleCallback {
class IdleDeadline;
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Web::ReferrerPolicy {
// https://w3c.github.io/webappsec-referrer-policy/#enumdef-referrerpolicy
enum class ReferrerPolicy {
NoReferrer,
NoReferrerWhenDowngrade,
SameOrigin,
Origin,
StrictOrigin,
OriginWhenCrossOrigin,
StrictOriginWhenCrossOrigin,
UnsafeURL,
};
}