From 73759d75da834dada7b4748cdccd85a81d9fc495 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 31 Oct 2017 01:39:53 -0400 Subject: mq_web_view_view_source_scheme_methods.initialize(): Use hash table and get origin URI from URI Trading MqApplication's registered tabs hash table for a query parameters hash table. --- (limited to 'src') diff --git a/src/web-view-schemes/view-source.c b/src/web-view-schemes/view-source.c index d2f9f7e..40fc496 100644 --- a/src/web-view-schemes/view-source.c +++ b/src/web-view-schemes/view-source.c @@ -42,23 +42,18 @@ match_uri(const gchar *uri) static void initialize(MqWebView *web_view, MqWebViewScheme *scheme, const gchar *uri) { - MqTabPage *origin_tab; + gchar *query_str; + GHashTable *query; - /* TODO: Handle "view-source:URI" URIs. */ - g_assert(g_str_has_prefix(uri, "view-source:origin-tab=")); + query_str = g_strdup(uri + strlen("view-source:")); + query = parse_query_string(query_str); - /* Parse origin tab ID out of URI. */ - uri += strlen("view-source:origin-tab="); - scheme->view_source.origin_tab_id = atoi64(uri); + scheme->view_source.origin_tab_id = atoi64(g_hash_table_lookup(query, + "origin-tab")); + scheme->view_source.uri = g_strdup(g_hash_table_lookup(query, "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. */ - scheme->view_source.uri = mq_web_view_get_uri( - mq_tab_page_get_web_view(origin_tab)); + g_hash_table_unref(query); + g_free(query_str); } static void -- cgit v0.9.1