summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-30 05:16:33 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-30 05:16:33 (EDT)
commitc93e3a1f32554feb4028d6854168a34b1a3e674a (patch)
tree31910a065d17a06c3fbbdf26b89b03e9a56ff879
parent958b15c7339e0cbf327168f0914a82a9c4241fac (diff)
downloadmarquee-c93e3a1f32554feb4028d6854168a34b1a3e674a.zip
marquee-c93e3a1f32554feb4028d6854168a34b1a3e674a.tar.gz
marquee-c93e3a1f32554feb4028d6854168a34b1a3e674a.tar.bz2
mq_web_view_view_source_scheme_methods.rewrite_uri(): Implement
-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 *