summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-12-29 13:04:46 +0100
committerportix <none@none>2012-12-29 13:04:46 +0100
commit7af387f69c403b32a86724858e051085ef2bd519 (patch)
tree253604b1609cd18667d07415d6e77defa227e32f /src
parent6c1d083ff8de9d79c79f1f16e8c2cf951832cda0 (diff)
parentb4479346804eaaff9252b9f878b21bb859b55956 (diff)
downloaddwb-7af387f69c403b32a86724858e051085ef2bd519.zip
Merging with https://bitbucket.org/portix/dwb
Diffstat (limited to 'src')
-rw-r--r--src/scripts.c23
-rw-r--r--src/view.c8
2 files changed, 31 insertions, 0 deletions
diff --git a/src/scripts.c b/src/scripts.c
index db3a06a8..b85c6218 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -1152,6 +1152,25 @@ request_callback(SoupSession *session, SoupMessage *message, JSObjectRef functio
}
JSValueUnprotect(s_global_context, function);
}
+static void
+set_request(JSContextRef ctx, SoupMessage *msg, JSValueRef val, JSValueRef *exc)
+{
+ char *content_type = NULL, *body = NULL;
+ JSObjectRef data = JSValueToObject(ctx, val, exc);
+ if (data == NULL)
+ return;
+ content_type = js_get_string_property(ctx, data, "contentType");
+ if (content_type != NULL)
+ {
+ body = js_get_string_property(ctx, data, "data");
+ if (body != NULL) {
+ soup_message_set_request(msg, content_type, SOUP_MEMORY_COPY, body, strlen(body));
+ }
+ }
+ g_free(content_type);
+ g_free(body);
+}
+
static JSValueRef
global_send_request(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
@@ -1179,6 +1198,8 @@ global_send_request(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, siz
msg = soup_message_new(method == NULL ? "GET" : method, uri);
if (msg == NULL)
goto error_out;
+ if (argc > 3 && !strcasecmp("POST", method))
+ set_request(ctx, msg, argv[3], exc);
JSValueProtect(ctx, function);
soup_session_queue_message(webkit_get_default_session(), msg, (SoupSessionCallback)request_callback, function);
@@ -1213,6 +1234,8 @@ global_send_request_sync(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject
method = js_value_to_char(ctx, argv[1], -1, exc);
msg = soup_message_new(method == NULL ? "GET" : method, uri);
+ if (argc > 2)
+ set_request(ctx, msg, argv[2], exc);
status = soup_session_send_message(webkit_get_default_session(), msg);
o = get_message_data(msg);
diff --git a/src/view.c b/src/view.c
index 44f70f14..82f0aa9b 100644
--- a/src/view.c
+++ b/src/view.c
@@ -599,6 +599,14 @@ view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetwo
return true;
}
break;
+ case WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED:
+ if (!dwb_confirm(dwb.state.fview, "Resubmit form [y/n]?"))
+ {
+ webkit_web_policy_decision_ignore(policy);
+ return true;
+ }
+ break;
+
default: break;
}