summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}