aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-web-view.c
diff options
context:
space:
mode:
authorXan Lopez <xan@gnome.org>2009-11-30 20:12:12 +0800
committerXan Lopez <xan@gnome.org>2009-11-30 20:12:12 +0800
commit2aca0c21a8f140a6d3b6bddfa4aed1b31326b1cd (patch)
tree0aac1c4c5b9afd5beaaa86047b1a1f8f7283f1e2 /embed/ephy-web-view.c
parentd23fdbe06441c06d532666e0d0d1d79091094378 (diff)
downloadgsoc2013-epiphany-2aca0c21a8f140a6d3b6bddfa4aed1b31326b1cd.tar.gz
gsoc2013-epiphany-2aca0c21a8f140a6d3b6bddfa4aed1b31326b1cd.tar.zst
gsoc2013-epiphany-2aca0c21a8f140a6d3b6bddfa4aed1b31326b1cd.zip
ephy-web-view.c: fix auto-google search when using Ctrl-Enter
Bug #603324
Diffstat (limited to 'embed/ephy-web-view.c')
-rw-r--r--embed/ephy-web-view.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 72c511221..4844bb1f8 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1052,6 +1052,38 @@ ephy_web_view_new (void)
return GTK_WIDGET (g_object_new (EPHY_TYPE_WEB_VIEW, NULL));
}
+static char*
+normalize_or_autosearch_url (EphyWebView *view, const char *url)
+{
+ char *effective_url;
+ SoupURI *soup_uri = NULL;
+ EphyWebViewPrivate *priv = view->priv;
+
+ /* We use SoupURI as an indication of whether the value given in url
+ * is not something we want to search; we only do that, though, if
+ * the address has a web scheme, because SoupURI will consider any
+ * string: as a valid scheme, and we will end up prepending http://
+ * to it */
+ if (ephy_embed_utils_address_has_web_scheme (url))
+ soup_uri = soup_uri_new (url);
+
+ /* If the string doesn't look like an URI, let's search it; */
+ if (soup_uri == NULL &&
+ priv->non_search_regex &&
+ !g_regex_match (priv->non_search_regex, url, 0, NULL)) {
+ char *query_param = soup_form_encode ("q", url, NULL);
+ /* + 2 here is getting rid of 'q=' */
+ effective_url = g_strdup_printf (_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8"), query_param + 2);
+ g_free (query_param);
+ } else
+ effective_url = ephy_embed_utils_normalize_address (url);
+
+ if (soup_uri)
+ soup_uri_free (soup_uri);
+
+ return effective_url;
+}
+
/**
* ephy_web_view_load_request:
* @web_view: the #EphyWebView in which to load the request
@@ -1071,7 +1103,7 @@ ephy_web_view_load_request (EphyWebView *web_view,
g_return_if_fail (WEBKIT_IS_NETWORK_REQUEST(request));
url = webkit_network_request_get_uri (request);
- effective_url = ephy_embed_utils_normalize_address (url);
+ effective_url = normalize_or_autosearch_url (web_view, url);
webkit_network_request_set_uri (request, effective_url);
g_free (effective_url);
@@ -1090,42 +1122,18 @@ void
ephy_web_view_load_url (EphyWebView *view,
const char *url)
{
- EphyWebViewPrivate *priv;
- SoupURI *soup_uri = NULL;
char *effective_url;
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
g_return_if_fail (url);
- priv = view->priv;
-
- /* We use SoupURI as an indication of whether the value given in url
- * is not something we want to search; we only do that, though, if
- * the address has a web scheme, because SoupURI will consider any
- * string: as a valid scheme, and we will end up prepending http://
- * to it */
- if (ephy_embed_utils_address_has_web_scheme (url))
- soup_uri = soup_uri_new (url);
-
- /* If the string doesn't look like an URI, let's search it; */
- if (soup_uri == NULL &&
- priv->non_search_regex &&
- !g_regex_match (priv->non_search_regex, url, 0, NULL)) {
- char *query_param = soup_form_encode ("q", url, NULL);
- /* + 2 here is getting rid of 'q=' */
- effective_url = g_strdup_printf (_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8"), query_param + 2);
- g_free (query_param);
- } else
- effective_url = ephy_embed_utils_normalize_address (url);
+ effective_url = normalize_or_autosearch_url (view, url);
if (g_str_has_prefix (effective_url, "javascript:"))
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view), effective_url);
else
webkit_web_view_open (WEBKIT_WEB_VIEW (view), effective_url);
- if (soup_uri)
- soup_uri_free (soup_uri);
-
g_free (effective_url);
}