From 4e049c4c58b92d1e4b3f39633bf1a272ba28a3e0 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Mon, 7 Jan 2013 19:33:54 +0100 Subject: [PATCH] Do not allow to load favicon images. --- src/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.c b/src/main.c index 3f51486..142197e 100644 --- a/src/main.c +++ b/src/main.c @@ -54,6 +54,9 @@ static gboolean vp_mimetype_decision_cb(WebKitWebView* webview, mime_type, WebKitWebPolicyDecision* decision, gpointer data); static gboolean vp_download_requested_cb(WebKitWebView* view, WebKitDownload* download, gpointer data); static void vp_download_progress_cp(WebKitDownload* download, GParamSpec* pspec); +static void vp_request_start_cb(WebKitWebView* webview, WebKitWebFrame* frame, + WebKitWebResource* resource, WebKitNetworkRequest* request, + WebKitNetworkResponse* response, gpointer data); /* functions */ static gboolean vp_process_input(const char* input); @@ -702,6 +705,7 @@ static void vp_setup_signals(void) "signal::title-changed", G_CALLBACK(vp_title_changed_cb), NULL, "signal::mime-type-policy-decision-requested", G_CALLBACK(vp_mimetype_decision_cb), NULL, "signal::download-requested", G_CALLBACK(vp_download_requested_cb), NULL, + "signal::resource-request-starting", G_CALLBACK(vp_request_start_cb), NULL, NULL ); @@ -862,6 +866,19 @@ static gboolean vp_download_requested_cb(WebKitWebView* view, WebKitDownload* do return TRUE; } +/** + * Callback to filter started resource request. + */ +static void vp_request_start_cb(WebKitWebView* webview, WebKitWebFrame* frame, + WebKitWebResource* resource, WebKitNetworkRequest* request, + WebKitNetworkResponse* response, gpointer data) +{ + const gchar* uri = webkit_network_request_get_uri(request); + if (g_str_has_suffix(uri, "/favicon.ico")) { + webkit_network_request_set_uri(request, "about:blank"); + } +} + static void vp_download_progress_cp(WebKitDownload* download, GParamSpec* pspec) { WebKitDownloadStatus status = webkit_download_get_status(download); -- 2.20.1