aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-web-view.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-23 07:24:53 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-27 14:16:53 +0800
commit51b74eee72ecf1323105f9c12942f2fe303ec7e1 (patch)
treec1753630859f8a1f07e258e121300416ebfc7476 /e-util/e-web-view.c
parent14b4291ebd16d3f9efddad49ec726d92edb258bc (diff)
downloadgsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.tar
gsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.tar.gz
gsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.tar.bz2
gsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.tar.lz
gsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.tar.xz
gsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.tar.zst
gsoc2013-evolution-51b74eee72ecf1323105f9c12942f2fe303ec7e1.zip
Add e_web_view_redirect_uri().
Replaces the given URI with a redirected URI as necessary, primarily for use with custom SoupRequest handlers. Typically this function would be called just prior to handing a request off to a SoupSession, such as from a WebKitWebView "resource-request-starting" signal handler. Case in point: EMailDisplay now implements the redirect_uri() method, and calls it from its own "resource-request-starting" signal handler.
Diffstat (limited to 'e-util/e-web-view.c')
-rw-r--r--e-util/e-web-view.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 38320baa3c..68ca266ca1 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -1080,6 +1080,13 @@ web_view_load_uri (EWebView *web_view,
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
}
+static gchar *
+web_view_redirect_uri (EWebView *web_view,
+ const gchar *uri)
+{
+ return g_strdup (uri);
+}
+
static gboolean
web_view_popup_event (EWebView *web_view,
const gchar *uri)
@@ -1367,6 +1374,7 @@ e_web_view_class_init (EWebViewClass *class)
class->link_clicked = web_view_link_clicked;
class->load_string = web_view_load_string;
class->load_uri = web_view_load_uri;
+ class->redirect_uri = web_view_redirect_uri;
class->popup_event = web_view_popup_event;
class->stop_loading = web_view_stop_loading;
class->update_actions = web_view_update_actions;
@@ -1811,6 +1819,37 @@ e_web_view_load_uri (EWebView *web_view,
class->load_uri (web_view, uri);
}
+/**
+ * e_web_view_redirect_uri:
+ * @web_view: an #EWebView
+ * @uri: the requested URI
+ *
+ * Replaces @uri with a redirected URI as necessary, primarily for use
+ * with custom #SoupRequest handlers. Typically this function would be
+ * called just prior to handing a request off to a #SoupSession, such as
+ * from a #WebKitWebView #WebKitWebView::resource-request-starting signal
+ * handler.
+ *
+ * A newly-allocated URI string is always returned, whether the @uri was
+ * redirected or not. Free the returned string with g_free().
+ *
+ * Returns: the redirected URI or a copy of @uri
+ **/
+gchar *
+e_web_view_redirect_uri (EWebView *web_view,
+ const gchar *uri)
+{
+ EWebViewClass *class;
+
+ g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ class = E_WEB_VIEW_GET_CLASS (web_view);
+ g_return_val_if_fail (class->redirect_uri != NULL, NULL);
+
+ return class->redirect_uri (web_view, uri);
+}
+
void
e_web_view_reload (EWebView *web_view)
{