mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:17:34 +00:00
Browser+LibWeb+WebContent: Implement per-URL-pattern proxies
...at least for SOCKS5.
This commit is contained in:
parent
f9fc28931f
commit
a42e03b01a
15 changed files with 155 additions and 6 deletions
|
@ -14,6 +14,8 @@ namespace Browser {
|
|||
extern String g_home_url;
|
||||
extern String g_search_engine;
|
||||
extern Vector<String> g_content_filters;
|
||||
extern Vector<String> g_proxies;
|
||||
extern HashMap<String, size_t> g_proxy_mappings;
|
||||
extern bool g_content_filters_enabled;
|
||||
extern IconBag g_icon_bag;
|
||||
|
||||
|
|
|
@ -575,15 +575,34 @@ void BrowserWindow::content_filters_changed()
|
|||
});
|
||||
}
|
||||
|
||||
void BrowserWindow::proxy_mappings_changed()
|
||||
{
|
||||
tab_widget().for_each_child_of_type<Browser::Tab>([](auto& tab) {
|
||||
tab.proxy_mappings_changed();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
void BrowserWindow::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
|
||||
{
|
||||
if (domain != "Browser" || group != "Preferences")
|
||||
if (domain != "Browser")
|
||||
return;
|
||||
|
||||
if (key == "SearchEngine")
|
||||
Browser::g_search_engine = value;
|
||||
else if (key == "Home")
|
||||
Browser::g_home_url = value;
|
||||
if (group == "Preferences") {
|
||||
if (key == "SearchEngine")
|
||||
Browser::g_search_engine = value;
|
||||
else if (key == "Home")
|
||||
Browser::g_home_url = value;
|
||||
} else if (group.starts_with("Proxy:")) {
|
||||
dbgln("Proxy mapping changed: {}/{} = {}", group, key, value);
|
||||
auto proxy_spec = group.substring_view(6);
|
||||
auto existing_proxy = Browser::g_proxies.find(proxy_spec);
|
||||
if (existing_proxy.is_end())
|
||||
Browser::g_proxies.append(proxy_spec);
|
||||
|
||||
Browser::g_proxy_mappings.set(key, existing_proxy.index());
|
||||
proxy_mappings_changed();
|
||||
}
|
||||
|
||||
// TODO: ColorScheme
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
GUI::Action& inspect_dom_node_action() { return *m_inspect_dom_node_action; }
|
||||
|
||||
void content_filters_changed();
|
||||
void proxy_mappings_changed();
|
||||
|
||||
private:
|
||||
explicit BrowserWindow(CookieJar&, URL);
|
||||
|
|
|
@ -118,6 +118,8 @@ Tab::Tab(BrowserWindow& window)
|
|||
else
|
||||
m_web_content_view->set_content_filters({});
|
||||
|
||||
m_web_content_view->set_proxy_mappings(g_proxies, g_proxy_mappings);
|
||||
|
||||
auto& go_back_button = toolbar.add_action(window.go_back_action());
|
||||
go_back_button.on_context_menu_request = [this](auto& context_menu_event) {
|
||||
if (!m_history.can_go_back())
|
||||
|
@ -516,6 +518,11 @@ void Tab::content_filters_changed()
|
|||
m_web_content_view->set_content_filters({});
|
||||
}
|
||||
|
||||
void Tab::proxy_mappings_changed()
|
||||
{
|
||||
m_web_content_view->set_proxy_mappings(g_proxies, g_proxy_mappings);
|
||||
}
|
||||
|
||||
void Tab::action_entered(GUI::Action& action)
|
||||
{
|
||||
m_statusbar->set_override_text(action.status_tip());
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
void did_become_active();
|
||||
void context_menu_requested(Gfx::IntPoint const& screen_position);
|
||||
void content_filters_changed();
|
||||
void proxy_mappings_changed();
|
||||
|
||||
void action_entered(GUI::Action&);
|
||||
void action_left(GUI::Action&);
|
||||
|
|
|
@ -31,6 +31,8 @@ String g_search_engine;
|
|||
String g_home_url;
|
||||
Vector<String> g_content_filters;
|
||||
bool g_content_filters_enabled { true };
|
||||
Vector<String> g_proxies;
|
||||
HashMap<String, size_t> g_proxy_mappings;
|
||||
IconBag g_icon_bag;
|
||||
|
||||
}
|
||||
|
@ -96,6 +98,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(load_content_filters());
|
||||
|
||||
for (auto& group : Config::list_groups("Browser")) {
|
||||
if (!group.starts_with("Proxy:"))
|
||||
continue;
|
||||
|
||||
for (auto& key : Config::list_keys("Browser", group)) {
|
||||
auto proxy_spec = group.substring_view(6);
|
||||
auto existing_proxy = Browser::g_proxies.find(proxy_spec);
|
||||
if (existing_proxy.is_end())
|
||||
Browser::g_proxies.append(proxy_spec);
|
||||
|
||||
Browser::g_proxy_mappings.set(key, existing_proxy.index());
|
||||
}
|
||||
}
|
||||
|
||||
URL first_url = Browser::url_from_user_input(Browser::g_home_url);
|
||||
if (specified_url) {
|
||||
if (Core::File::exists(specified_url)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue