summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-04-21 07:54:56 -0400
committerAndreas Kling <kling@serenityos.org>2023-04-22 12:32:40 +0200
commit5089766af68f6aa9c39d829bafb5ffde6b1e76ca (patch)
tree5b116e2679f33d66c20d24296de656701996e612 /Userland/Applications
parent76ae60da1566dd3d9c33c36da98e963b23a39801 (diff)
downloadserenity-5089766af68f6aa9c39d829bafb5ffde6b1e76ca.zip
Browser+Ladybird+LibWeb: Port content filters to String
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Browser/Browser.h2
-rw-r--r--Userland/Applications/Browser/Tab.cpp6
-rw-r--r--Userland/Applications/Browser/main.cpp11
3 files changed, 9 insertions, 10 deletions
diff --git a/Userland/Applications/Browser/Browser.h b/Userland/Applications/Browser/Browser.h
index b95273a1a7..5e94030131 100644
--- a/Userland/Applications/Browser/Browser.h
+++ b/Userland/Applications/Browser/Browser.h
@@ -15,7 +15,7 @@ namespace Browser {
extern DeprecatedString g_home_url;
extern DeprecatedString g_new_tab_url;
extern DeprecatedString g_search_engine;
-extern Vector<DeprecatedString> g_content_filters;
+extern Vector<String> g_content_filters;
extern bool g_content_filters_enabled;
extern Vector<String> g_autoplay_allowlist;
extern bool g_autoplay_allowed_on_all_websites;
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 1469ea2500..45645c4cb3 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -126,11 +126,7 @@ Tab::Tab(BrowserWindow& window)
auto preferred_color_scheme = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, "auto"sv));
m_web_content_view->set_preferred_color_scheme(preferred_color_scheme);
- if (g_content_filters_enabled)
- m_web_content_view->set_content_filters(g_content_filters);
- else
- m_web_content_view->set_content_filters({});
-
+ content_filters_changed();
autoplay_allowlist_changed();
m_web_content_view->set_proxy_mappings(g_proxies, g_proxy_mappings);
diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp
index fd037227ab..8744fc7fab 100644
--- a/Userland/Applications/Browser/main.cpp
+++ b/Userland/Applications/Browser/main.cpp
@@ -34,7 +34,7 @@ namespace Browser {
DeprecatedString g_search_engine;
DeprecatedString g_home_url;
DeprecatedString g_new_tab_url;
-Vector<DeprecatedString> g_content_filters;
+Vector<String> g_content_filters;
bool g_content_filters_enabled { true };
Vector<String> g_autoplay_allowlist;
bool g_autoplay_allowed_on_all_websites { false };
@@ -47,7 +47,7 @@ DeprecatedString g_webdriver_content_ipc_path;
static ErrorOr<void> load_content_filters()
{
- auto file = TRY(Core::File::open(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::File::OpenMode::Read));
+ auto file = TRY(Core::File::open(TRY(String::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory())), Core::File::OpenMode::Read));
auto ad_filter_list = TRY(Core::BufferedFile::create(move(file)));
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
@@ -55,8 +55,11 @@ static ErrorOr<void> load_content_filters()
while (TRY(ad_filter_list->can_read_line())) {
auto line = TRY(ad_filter_list->read_line(buffer));
- if (!line.is_empty())
- Browser::g_content_filters.append(line);
+ if (line.is_empty())
+ continue;
+
+ auto pattern = TRY(String::from_utf8(line));
+ TRY(Browser::g_content_filters.try_append(move(pattern)));
}
return {};