summaryrefslogtreecommitdiff
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-private.h3
-rw-r--r--embed/ephy-embed-utils.c26
-rw-r--r--embed/ephy-embed-utils.h1
-rw-r--r--embed/ephy-web-view.c87
4 files changed, 30 insertions, 87 deletions
diff --git a/embed/ephy-embed-private.h b/embed/ephy-embed-private.h
index d023efb6a..5500b8218 100644
--- a/embed/ephy-embed-private.h
+++ b/embed/ephy-embed-private.h
@@ -61,9 +61,6 @@ void ephy_web_view_load_homepage (EphyWebView
char * ephy_web_view_create_web_application (EphyWebView *view,
const char *title,
GdkPixbuf *icon);
-char* ephy_web_view_normalize_or_autosearch_url (EphyWebView *view,
- const char *url);
-
EphyFrecentStore *ephy_embed_shell_get_frecent_store (EphyEmbedShell *shell);
G_END_DECLS
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 94ce59655..cd3978000 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -26,6 +26,7 @@
#include "ephy-about-handler.h"
#include "ephy-embed-private.h"
+#include "ephy-settings.h"
#include "ephy-string.h"
#include <string.h>
@@ -226,6 +227,31 @@ ephy_embed_utils_normalize_address (const char *address)
return effective_address ? effective_address : g_strdup (address);
}
+char *
+ephy_embed_utils_normalize_or_autosearch_address (const char *address)
+{
+ char *query_param, *url_search;
+ char *effective_address;
+
+ if (ephy_embed_utils_address_is_valid (address))
+ return ephy_embed_utils_normalize_address (address);
+
+ url_search = g_settings_get_string (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_KEYWORD_SEARCH_URL);
+ if (url_search == NULL || url_search[0] == '\0') {
+ g_free (url_search);
+ url_search = g_strdup (_("http://duckduckgo.com/?q=%s&amp;t=epiphany"));
+ }
+
+ query_param = soup_form_encode ("q", address, NULL);
+ /* + 2 here is getting rid of 'q=' */
+ effective_address = g_strdup_printf (url_search, query_param + 2);
+ g_free (query_param);
+ g_free (url_search);
+
+ return effective_address;
+}
+
gboolean
ephy_embed_utils_url_is_empty (const char *location)
{
diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h
index 2cb6a7e5a..c5d03425e 100644
--- a/embed/ephy-embed-utils.h
+++ b/embed/ephy-embed-utils.h
@@ -42,6 +42,7 @@ gboolean ephy_embed_utils_address_has_web_scheme (const char *add
gboolean ephy_embed_utils_address_is_existing_absolute_filename (const char *address);
gboolean ephy_embed_utils_address_is_valid (const char *address);
char* ephy_embed_utils_normalize_address (const char *address);
+char * ephy_embed_utils_normalize_or_autosearch_address (const char *address);
gboolean ephy_embed_utils_url_is_empty (const char *location);
gboolean ephy_embed_utils_is_no_show_address (const char *address);
void ephy_embed_utils_shutdown (void);
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index f8228b9ba..5b7e780f1 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2030,48 +2030,6 @@ ephy_web_view_new_with_related_view (WebKitWebView *related_view)
}
/**
- * 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;
-
- g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), NULL);
- g_return_val_if_fail (url, NULL);
-
- /* If the string doesn't look like an URI, let's search it; */
- if (!ephy_embed_utils_address_is_valid (url)) {
- char *query_param, *url_search;
-
- url_search = g_settings_get_string (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_KEYWORD_SEARCH_URL);
-
- if (url_search == NULL || url_search[0] == '\0') {
- g_free (url_search);
-
- url_search = g_strdup (_("http://duckduckgo.com/?q=%s&amp;t=epiphany"));
- }
-
- query_param = soup_form_encode ("q", url, NULL);
- /* + 2 here is getting rid of 'q=' */
- effective_url = g_strdup_printf (url_search, query_param + 2);
- g_free (query_param);
- g_free (url_search);
- } else
- effective_url = ephy_embed_utils_normalize_address (url);
-
- return effective_url;
-}
-
-/**
* ephy_web_view_load_request:
* @view: the #EphyWebView in which to load the request
* @request: the #WebKitNetworkRequest to be loaded
@@ -2089,7 +2047,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 = ephy_web_view_normalize_or_autosearch_url (view, url);
+ effective_url = ephy_embed_utils_normalize_address (url);
webkit_uri_request_set_uri (request, effective_url);
g_free (effective_url);
@@ -2155,47 +2113,8 @@ ephy_web_view_load_url (EphyWebView *view,
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
g_return_if_fail (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
- * WEB SCHEME>:<DATA>. To fix this, let's do a HEAD request to the
- * effective URI prefxed with http://; if we get OK Status the URI
- * exists, and we'll go ahead, otherwise we'll try to launch a
- * proper handler through gtk_show_uri. We only do this in
- * ephy_web_view_load_url, since this case is only relevant for URIs
- * typed in the location entry, which uses this method to do the
- * load. */
- if (!ephy_embed_utils_address_has_web_scheme (effective_url)) {
-#if 0
- /* TODO: WebKit2, Network features */
- SoupMessage *message;
- SoupSession *session;
- char *temp_url;
- HEADAttemptData *data;
-
- temp_url = g_strconcat ("http://", effective_url, NULL);
-
- session = webkit_get_default_session ();
- message = soup_message_new (SOUP_METHOD_HEAD,
- temp_url);
-
- if (message) {
- data = g_slice_new (HEADAttemptData);
- data->view = view;
- data->original_uri = g_strdup (effective_url);
- soup_session_queue_message (session, message,
- effective_url_head_cb, data);
- } else {
- /* If we cannot even create a message fallback to the effective
- * url, the gtk_show_uri code will make another attempt in
- * EphyWindow's policy code. */
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), effective_url);
- }
-
- g_free (temp_url);
-#endif
- } else if (g_str_has_prefix (effective_url, "javascript:")) {
+ effective_url = ephy_embed_utils_normalize_address (url);
+ if (g_str_has_prefix (effective_url, "javascript:")) {
char *decoded_url;
decoded_url = soup_uri_decode (effective_url);