From c93e3a1f32554feb4028d6854168a34b1a3e674a Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 30 Oct 2017 05:16:33 -0400 Subject: mq_web_view_view_source_scheme_methods.rewrite_uri(): Implement --- (limited to 'src/web-view-schemes') 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 +#include + #include #include #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 * -- cgit v0.9.1