LibWeb/Loader: Add filtering_enabled flag in ContentFilter

This allows us to toggle content filtering on or off. Default is set to
true to match current behavior.
This commit is contained in:
rmg-x 2025-03-06 17:42:40 -06:00 committed by Tim Ledbetter
commit 00aa72c16e
Notes: github-actions[bot] 2025-03-10 12:31:37 +00:00
2 changed files with 7 additions and 0 deletions

View file

@ -21,6 +21,9 @@ ContentFilter::~ContentFilter() = default;
bool ContentFilter::is_filtered(const URL::URL& url) const
{
if (!filtering_enabled())
return false;
if (url.scheme() == "data")
return false;

View file

@ -16,6 +16,9 @@ class ContentFilter {
public:
static ContentFilter& the();
bool filtering_enabled() const { return m_filtering_enabled; }
void set_filtering_enabled(bool const enabled) { m_filtering_enabled = enabled; }
bool is_filtered(const URL::URL&) const;
ErrorOr<void> set_patterns(ReadonlySpan<String>);
@ -27,6 +30,7 @@ private:
String text;
};
Vector<Pattern> m_patterns;
bool m_filtering_enabled { true };
};
}