summaryrefslogtreecommitdiffstats
path: root/src/web-view-schemes
diff options
context:
space:
mode:
Diffstat (limited to 'src/web-view-schemes')
-rw-r--r--src/web-view-schemes/view-source.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/web-view-schemes/view-source.c b/src/web-view-schemes/view-source.c
index e7a1ecb..ec9fe85 100644
--- a/src/web-view-schemes/view-source.c
+++ b/src/web-view-schemes/view-source.c
@@ -21,19 +21,42 @@
#include "schemes.h"
+#include <inttypes.h>
+#include <string.h>
+
#include <glib.h>
#include <webkit2/webkit2.h>
#include "../application.h"
#include "../config.h"
-#include "../notebook.h"
+#include "../string-utils.h"
#include "../tab-page.h"
#include "../web-view.h"
static gchar *
rewrite_uri(MqWebViewScheme G_GNUC_UNUSED *scheme, const gchar *uri)
{
- return g_strdup(uri);
+ MqTabPage *origin_tab;
+
+ g_assert(g_str_has_prefix(uri, "view-source:origin-tab="));
+
+ /* Parse origin tab ID out of URI. */
+ uri += strlen("view-source:origin-tab=");
+ scheme->view_source.origin_tab_id = atoi64(uri);
+
+ /* Look up origin tab. */
+ origin_tab = mq_application_get_tab(mq_tab_page_get_application(
+ mq_web_view_get_tab_page(web_view)),
+ scheme->view_source.origin_tab_id);
+
+ /* Get origin tab's URI and data. */
+ scheme->view_source.uri = mq_web_view_get_uri(
+ mq_tab_page_get_web_view(origin_tab));
+ /* TODO: Get data. */
+
+ /* Rewrite URI. */
+ return g_strdup_printf("view-source:view-tab=%" PRId64,
+ mq_tab_page_get_id(web_view));
}
static gchar *