summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-30 02:18:45 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-30 02:18:45 (EDT)
commit53242ccdd86c9b951d587608bc8261137efba5b9 (patch)
tree92d19c171936a9d178b76864413ad8c884c8d2cd /src
parent6ce1f1f9a8796c3ac47cfe2c4bd078151d1e5af2 (diff)
downloadmarquee-53242ccdd86c9b951d587608bc8261137efba5b9.zip
marquee-53242ccdd86c9b951d587608bc8261137efba5b9.tar.gz
marquee-53242ccdd86c9b951d587608bc8261137efba5b9.tar.bz2
MqWebView: Factor out URI rewriting into new static function
Diffstat (limited to 'src')
-rw-r--r--src/web-view.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/web-view.c b/src/web-view.c
index 5b649a7..0b8a26a 100644
--- a/src/web-view.c
+++ b/src/web-view.c
@@ -599,6 +599,16 @@ decide_policy_cb(MqWebView *web_view, WebKitPolicyDecision *decision,
}
}
+static gchar *
+rewrite_uri(const gchar *uri)
+{
+ if (g_str_has_prefix(uri, "about:")) {
+ return g_strconcat("mq-about:", uri + strlen("about:"), NULL);
+ } else {
+ return g_strdup(uri);
+ }
+}
+
static void
constructed(GObject *object)
{
@@ -620,16 +630,9 @@ constructed(GObject *object)
mq_tab_page_get_application(web_view->tab_page)));
if (web_view->uri) {
- if (g_str_has_prefix(web_view->uri, "about:")) {
- rw_uri = g_strconcat("mq-about:",
- web_view->uri + strlen("about:"), NULL);
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view),
- rw_uri);
- g_free(rw_uri);
- } else {
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view),
- web_view->uri);
- }
+ rw_uri = rewrite_uri(web_view->uri);
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), rw_uri);
+ g_free(rw_uri);
} else {
new_tab_page = mq_config_get_string(web_view->config,
"tabs.new");
@@ -788,7 +791,7 @@ mq_web_view_load_uri(MqWebView *web_view, const gchar *uri)
web_view->uri = g_strdup(uri);
if (g_str_has_prefix(uri, "about:")) {
- rw_uri = g_strconcat("mq-about:", uri + strlen("about:"), NULL);
+ rw_uri = rewrite_uri(web_view->uri);
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), rw_uri);
g_free(rw_uri);
} else {