From: Sébastien Marie <semarie@users.noreply.github.com>
Date: Fri, 24 Oct 2014 08:23:38 +0000 (+0200)
Subject: enable uri pattern for LoadProvisional autocmd
X-Git-Url: https://git.owens.tech/112-editable-focus.html/112-editable-focus.html/git?a=commitdiff_plain;h=18dbc8744bc5231335188df2210c52c6df917397;p=vimb.git

enable uri pattern for LoadProvisional autocmd

this prepare a new setting "content-security-policy" that need to be
setted very early (before LoadCommited, where some HTTP-Headers are
already processed by webkit).
---

diff --git a/doc/vimb.1 b/doc/vimb.1
index 7fbdbba..b123908 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -630,8 +630,7 @@ Events:
 .TP
 .B LoadProvisional
 Fired if a new page is going to opened. No data has been received yet, the load
-may still fail for transport issues. Out of this reason this event has no
-associated URL to match.
+may still fail for transport issues.
 .TP
 .B LoadCommited
 Fired if first data chunk has arrived, meaning that the necessary transport
diff --git a/src/main.c b/src/main.c
index dd31102..ed2d501 100644
--- a/src/main.c
+++ b/src/main.c
@@ -532,7 +532,13 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
     switch (webkit_web_view_get_load_status(view)) {
         case WEBKIT_LOAD_PROVISIONAL:
 #ifdef FEATURE_AUTOCMD
-            autocmd_run(AU_LOAD_PROVISIONAL, NULL, NULL);
+            {
+                WebKitWebFrame *frame     = webkit_web_view_get_main_frame(view);
+                WebKitWebDataSource *src  = webkit_web_frame_get_provisional_data_source(frame);
+                WebKitNetworkRequest *req = webkit_web_data_source_get_initial_request(src);
+                uri = webkit_network_request_get_uri(req);
+                autocmd_run(AU_LOAD_PROVISIONAL, uri, NULL);
+            }
 #endif
             /* update load progress in statusbar */
             vb.state.progress = 0;