summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/web-view.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/web-view.c b/src/web-view.c
index 74c9da6..10e96a3 100644
--- a/src/web-view.c
+++ b/src/web-view.c
@@ -567,6 +567,38 @@ button_press_cb(GtkWidget *widget, GdkEventButton *event)
return TRUE;
}
+static gboolean
+decide_response_policy(MqWebView G_GNUC_UNUSED *web_view,
+ WebKitResponsePolicyDecision *decision)
+{
+ if (webkit_response_policy_decision_is_mime_type_supported(decision)) {
+ webkit_policy_decision_use(WEBKIT_POLICY_DECISION(decision));
+ } else {
+ webkit_policy_decision_download(
+ WEBKIT_POLICY_DECISION(decision));
+ }
+ return TRUE;
+}
+
+static gboolean
+decide_policy_cb(MqWebView *web_view, WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType decision_type)
+{
+ switch (decision_type) {
+ case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION:
+ /* TODO */
+ return FALSE;
+ case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION:
+ /* TODO */
+ return FALSE;
+ case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
+ return decide_response_policy(web_view,
+ WEBKIT_RESPONSE_POLICY_DECISION(decision));
+ default:
+ return FALSE;
+ }
+}
+
static void
constructed(GObject *object)
{
@@ -720,6 +752,8 @@ mq_web_view_init(MqWebView *web_view)
G_CALLBACK(mouse_target_changed_cb), NULL);
g_signal_connect(web_view, "button-press-event",
G_CALLBACK(button_press_cb), NULL);
+ g_signal_connect(web_view, "decide-policy",
+ G_CALLBACK(decide_policy_cb), NULL);
}
MqWebView *