aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-08-07 20:24:48 +0800
committerXan Lopez <xan@igalia.com>2012-08-07 20:26:10 +0800
commit393d8167c8f10578044d4245a1927ab2d9416578 (patch)
tree5902f2a7c0b5eeaceeffe33acb3ed162e478bf2e /embed
parentfa8fc3a78c404d29bb1d3d7a010acca1bd001c53 (diff)
downloadgsoc2013-epiphany-393d8167c8f10578044d4245a1927ab2d9416578.tar.gz
gsoc2013-epiphany-393d8167c8f10578044d4245a1927ab2d9416578.tar.zst
gsoc2013-epiphany-393d8167c8f10578044d4245a1927ab2d9416578.zip
ephy-web-view: export the 'normalize or autosearch' method
We are going to modify it a bit, and we really want to test it. Add some initial tests for the existing functionality.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-private.h3
-rw-r--r--embed/ephy-web-view.c29
2 files changed, 21 insertions, 11 deletions
diff --git a/embed/ephy-embed-private.h b/embed/ephy-embed-private.h
index f9cac0835..b23c5a3e0 100644
--- a/embed/ephy-embed-private.h
+++ b/embed/ephy-embed-private.h
@@ -65,6 +65,9 @@ GdkPixbuf * ephy_web_view_get_snapshot (EphyWebView
int height);
gboolean ephy_web_view_is_loading_homepage (EphyWebView *view);
+char* ephy_web_view_normalize_or_autosearch_url (EphyWebView *view,
+ const char *url);
+
G_END_DECLS
#endif
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index dfc05aa15..1d74862b3 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2815,19 +2815,26 @@ ephy_web_view_new (void)
return GTK_WIDGET (g_object_new (EPHY_TYPE_WEB_VIEW, NULL));
}
-/*
- * Returns a normalized representation of @url, or an autosearch string
- * for it if it has no scheme.
- *
- * Returns: the normalized @url or autosearch string
- */
-static char*
-normalize_or_autosearch_url (EphyWebView *view, const char *url)
+/**
+ * ephy_web_view_normalize_or_autosearch_url:
+ * @view: an %EphyWebView
+ * @url: a URI
+ *
+ * Returns a normalized representation of @url, or an autosearch
+ * string for it when necessary.
+ *
+ * Returns: the normalized @url or autosearch string.
+ **/
+char*
+ephy_web_view_normalize_or_autosearch_url (EphyWebView *view, const char *url)
{
char *effective_url;
char *scheme;
EphyWebViewPrivate *priv = view->priv;
+ g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), NULL);
+ g_return_val_if_fail (url, NULL);
+
scheme = g_uri_parse_scheme (url);
/* If the string doesn't look like an URI, let's search it; */
@@ -2889,7 +2896,7 @@ ephy_web_view_load_request (EphyWebView *view,
g_return_if_fail (WEBKIT_IS_URI_REQUEST(request));
url = webkit_uri_request_get_uri (request);
- effective_url = normalize_or_autosearch_url (view, url);
+ effective_url = ephy_web_view_normalize_or_autosearch_url (view, url);
// TODO: webkit_uri_request_set_uri?
webkit_web_view_load_uri (WEBKIT_WEB_VIEW(view), effective_url);
@@ -2898,7 +2905,7 @@ ephy_web_view_load_request (EphyWebView *view,
g_return_if_fail (WEBKIT_IS_NETWORK_REQUEST(request));
url = webkit_network_request_get_uri (request);
- effective_url = normalize_or_autosearch_url (view, url);
+ effective_url = ephy_web_view_normalize_or_autosearch_url (view, url);
webkit_network_request_set_uri (request, effective_url);
g_free (effective_url);
@@ -2963,7 +2970,7 @@ ephy_web_view_load_url (EphyWebView *view,
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
g_return_if_fail (url);
- effective_url = normalize_or_autosearch_url (view, url);
+ effective_url = ephy_web_view_normalize_or_autosearch_url (view, url);
/* After normalization there are still some cases that are
* impossible to tell apart. One example is <URI>:<PORT> and <NON