summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-31 01:58:34 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-31 01:59:44 (EDT)
commitd47a99e0654bb3ad145bc4e96e509b798ef77454 (patch)
tree004953c55a05aa9e05f8121dbc51d67599b4dd8c /src
parentca654cfbc868c990c2d31af3da98ceaa28ab252f (diff)
downloadmarquee-d47a99e0654bb3ad145bc4e96e509b798ef77454.zip
marquee-d47a99e0654bb3ad145bc4e96e509b798ef77454.tar.gz
marquee-d47a99e0654bb3ad145bc4e96e509b798ef77454.tar.bz2
mq_view_source_request(): Use hash table and get origin URI from path/query
Diffstat (limited to 'src')
-rw-r--r--src/view-source.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/view-source.c b/src/view-source.c
index bace681..3fa07dd 100644
--- a/src/view-source.c
+++ b/src/view-source.c
@@ -31,6 +31,7 @@
typedef struct {
WebKitURISchemeRequest *request;
+ gchar *uri;
gulong handler_id;
} DataSignalData;
@@ -82,21 +83,24 @@ void
mq_view_source_request(WebKitURISchemeRequest *request,
MqApplication *application)
{
- const gchar *path;
+ gchar *path;
+ GHashTable *query;
gint64 origin_tab_id;
+ gchar *uri;
MqTabPage *origin_tab;
MqWebView *origin_web_view;
guchar *data;
gsize length;
DataSignalData *data_signal_data;
- path = webkit_uri_scheme_request_get_path(request);
- /* TODO: Handle "view-source:URI" URIs. */
- g_assert(g_str_has_prefix(path, "origin-tab="));
+ path = g_strdup(webkit_uri_scheme_request_get_path(request));
+ query = parse_query_string(path);
- /* Parse origin tab ID out of path. */
- path += strlen("origin-tab=");
- origin_tab_id = atoi64(path);
+ origin_tab_id = atoi64(g_hash_table_lookup(query, "origin-tab"));
+ uri = g_strdup(g_hash_table_lookup(query, "uri"));
+
+ g_hash_table_unref(query);
+ g_free(path);
/* Look up origin tab. */
origin_tab = mq_application_get_tab(application, origin_tab_id);
@@ -109,6 +113,7 @@ mq_view_source_request(WebKitURISchemeRequest *request,
} else {
data_signal_data = g_new(DataSignalData, 1);
data_signal_data->request = request;
+ data_signal_data->uri = uri;
data_signal_data->handler_id = g_signal_connect(origin_web_view,
"notify::data", G_CALLBACK(data_cb), data_signal_data);
}