Replace createwindow() with createview()
We can now perform some filtering before opening a new view (window) when requested by JavaScript (either random or by a click).
This commit is contained in:
parent
92d7ba7ed8
commit
1f99df029c
37
surf.c
37
surf.c
|
@ -114,7 +114,7 @@ static WebKitCookieAcceptPolicy cookiepolicy_get(void);
|
||||||
static char cookiepolicy_set(const WebKitCookieAcceptPolicy p);
|
static char cookiepolicy_set(const WebKitCookieAcceptPolicy p);
|
||||||
|
|
||||||
static char *copystr(char **str, const char *src);
|
static char *copystr(char **str, const char *src);
|
||||||
static WebKitWebView *createwindow(WebKitWebView *v, WebKitWebFrame *f,
|
static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a,
|
||||||
Client *c);
|
Client *c);
|
||||||
static gboolean decidedownload(WebKitWebView *v, WebKitWebFrame *f,
|
static gboolean decidedownload(WebKitWebView *v, WebKitWebFrame *f,
|
||||||
WebKitNetworkRequest *r, gchar *m,
|
WebKitNetworkRequest *r, gchar *m,
|
||||||
|
@ -427,11 +427,34 @@ copystr(char **str, const char *src)
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebKitWebView *
|
GtkWidget *
|
||||||
createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c)
|
createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c)
|
||||||
{
|
{
|
||||||
Client *n = newclient();
|
Client *n;
|
||||||
return n->view;
|
|
||||||
|
switch (webkit_navigation_action_get_navigation_type(a)) {
|
||||||
|
case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */
|
||||||
|
/*
|
||||||
|
* popup windows of type “other” are almost always triggered
|
||||||
|
* by user gesture, so inverse the logic here
|
||||||
|
*/
|
||||||
|
if (webkit_navigation_action_is_user_gesture(a)) {
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */
|
||||||
|
case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */
|
||||||
|
case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */
|
||||||
|
case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */
|
||||||
|
case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED:
|
||||||
|
n = newclient(c);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GTK_WIDGET(n->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -890,8 +913,8 @@ newview(Client *c, WebKitWebView *rv)
|
||||||
"permission-request",
|
"permission-request",
|
||||||
G_CALLBACK(permissionrequested), c);
|
G_CALLBACK(permissionrequested), c);
|
||||||
g_signal_connect(G_OBJECT(v),
|
g_signal_connect(G_OBJECT(v),
|
||||||
"create-web-view",
|
"create",
|
||||||
G_CALLBACK(createwindow), c);
|
G_CALLBACK(createview), c);
|
||||||
g_signal_connect(G_OBJECT(v), "ready-to-show",
|
g_signal_connect(G_OBJECT(v), "ready-to-show",
|
||||||
G_CALLBACK(showview), c);
|
G_CALLBACK(showview), c);
|
||||||
g_signal_connect(G_OBJECT(v),
|
g_signal_connect(G_OBJECT(v),
|
||||||
|
|
Loading…
Reference in New Issue