From: Daniel Carl Date: Sun, 25 May 2014 16:10:34 +0000 (+0200) Subject: Use custom protocol handler for every opened URI (#82). X-Git-Url: https://git.owens.tech/dummy.html/dummy.html/git?a=commitdiff_plain;h=5953c03fa330bff764e6647fdb874967a1afdb29;p=vimb.git Use custom protocol handler for every opened URI (#82). --- diff --git a/src/main.c b/src/main.c index 3d1bbd0..ebcc4d4 100644 --- a/src/main.c +++ b/src/main.c @@ -73,6 +73,10 @@ static gboolean create_web_view_received_uri_cb(WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *action, WebKitWebPolicyDecision *policy, gpointer data); +static gboolean navigation_decision_requested_cb(WebKitWebView *view, + WebKitWebFrame *frame, WebKitNetworkRequest *request, + WebKitWebNavigationAction *action, WebKitWebPolicyDecision *policy, + gpointer data); static void hover_link_cb(WebKitWebView *webview, const char *title, const char *link); static void title_changed_cb(WebKitWebView *webview, WebKitWebFrame *frame, const char *title); static gboolean mimetype_decision_cb(WebKitWebView *webview, @@ -171,10 +175,6 @@ gboolean vb_load_uri(const Arg *arg) path = vb.config.home_page; } - if (handle_uri(path)) { - return true; - } - if (strstr(path, "://") || !strncmp(path, "about:", 6)) { uri = g_strdup(path); } else if (stat(path, &st) == 0) { @@ -829,6 +829,7 @@ static void setup_signals() "signal::download-requested", G_CALLBACK(vb_download), NULL, "signal::should-show-delete-interface-for-element", G_CALLBACK(gtk_false), NULL, "signal::resource-request-starting", G_CALLBACK(webview_request_starting_cb), NULL, + "signal::navigation-policy-decision-requested", G_CALLBACK(navigation_decision_requested_cb), NULL, NULL ); @@ -978,6 +979,15 @@ static gboolean create_web_view_received_uri_cb(WebKitWebView *view, return true; } +static gboolean navigation_decision_requested_cb(WebKitWebView *view, + WebKitWebFrame *frame, WebKitNetworkRequest *request, + WebKitWebNavigationAction *action, WebKitWebPolicyDecision *policy, + gpointer data) +{ + /* try to find a protocall handler to open the uri */ + return handle_uri(webkit_network_request_get_uri(request)); +} + static void hover_link_cb(WebKitWebView *webview, const char *title, const char *link) { char *message;