summaryrefslogtreecommitdiff
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-shell.c14
-rw-r--r--embed/ephy-embed-shell.h3
-rw-r--r--embed/ephy-embed-utils.c25
3 files changed, 31 insertions, 11 deletions
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 101caf900..4556ae9d8 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -70,6 +70,7 @@ typedef struct {
GList *web_extensions;
EphyFiltersManager *filters_manager;
GCancellable *cancellable;
+ EphySearchEngineManager *search_engine_manager;
} EphyEmbedShellPrivate;
enum {
@@ -124,6 +125,7 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->web_context);
g_clear_object (&priv->dbus_server);
g_clear_object (&priv->filters_manager);
+ g_clear_object (&priv->search_engine_manager);
G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
}
@@ -955,6 +957,8 @@ ephy_embed_shell_startup (GApplication *application)
ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy);
g_free (cookie_policy);
+ priv->search_engine_manager = ephy_search_engine_manager_new ();
+
#ifdef HAVE_LIBHTTPSEVERYWHERE
/* We might want to be smarter about this in the future. For now,
* trigger an update of the rulesets once each time Epiphany is started.
@@ -1437,3 +1441,13 @@ ephy_embed_shell_get_hosts_manager (EphyEmbedShell *shell)
priv->hosts_manager = ephy_hosts_manager_new ();
return priv->hosts_manager;
}
+
+EphySearchEngineManager *
+ephy_embed_shell_get_search_engine_manager (EphyEmbedShell *shell)
+{
+ EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
+
+ if (!priv->search_engine_manager)
+ priv->search_engine_manager = ephy_search_engine_manager_new ();
+ return priv->search_engine_manager;
+}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index e327e7e69..4fc5d05a9 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -25,6 +25,7 @@
#include "ephy-downloads-manager.h"
#include "ephy-history-service.h"
#include "ephy-hosts-manager.h"
+#include "ephy-search-engine-manager.h"
G_BEGIN_DECLS
@@ -79,5 +80,5 @@ void ephy_embed_shell_schedule_thumbnail_update (EphyEmbedShell
WebKitUserContentManager *ephy_embed_shell_get_user_content_manager (EphyEmbedShell *shell);
EphyDownloadsManager *ephy_embed_shell_get_downloads_manager (EphyEmbedShell *shell);
EphyHostsManager *ephy_embed_shell_get_hosts_manager (EphyEmbedShell *shell);
-
+EphySearchEngineManager *ephy_embed_shell_get_search_engine_manager (EphyEmbedShell *shell);
G_END_DECLS
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 90dcd9572..81bb4b9a1 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -29,10 +29,10 @@
#include "ephy-string.h"
#include "ephy-view-source-handler.h"
-#include <string.h>
+#include <JavaScriptCore/JavaScript.h>
#include <glib/gi18n.h>
#include <libsoup/soup.h>
-#include <JavaScriptCore/JavaScript.h>
+#include <string.h>
static GRegex *non_search_regex;
static GRegex *domain_regex;
@@ -230,15 +230,20 @@ ephy_embed_utils_normalize_address (const char *address)
char *
ephy_embed_utils_autosearch_address (const char *search_key)
{
- char *query_param, *url_search;
+ char *query_param;
+ const char *url_search;
+ char *default_name;
char *effective_address;
+ EphyEmbedShell *shell;
+ EphySearchEngineManager *search_engine_manager;
- 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 (_("https://duckduckgo.com/?q=%s&amp;t=epiphany"));
- }
+ shell = ephy_embed_shell_get_default ();
+ search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
+ default_name = ephy_search_engine_manager_get_default_engine (search_engine_manager);
+ url_search = ephy_search_engine_manager_get_url (search_engine_manager, default_name);
+
+ if (url_search == NULL || url_search[0] == '\0')
+ url_search = _("https://duckduckgo.com/?q=%s&amp;t=epiphany");
query_param = soup_form_encode ("q", search_key, NULL);
#pragma GCC diagnostic push
@@ -248,7 +253,7 @@ ephy_embed_utils_autosearch_address (const char *search_key)
effective_address = g_strdup_printf (url_search, query_param + 2);
#pragma GCC diagnostic pop
g_free (query_param);
- g_free (url_search);
+ g_free (default_name);
return effective_address;
}