[epiphany/mcatanzaro/user-agent] Simplify user agent construction
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/user-agent] Simplify user agent construction
- Date: Sun, 23 Jun 2019 17:04:57 +0000 (UTC)
commit a4a74ef717d1314ba6aecace1d692ce542015506
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Jun 23 11:12:08 2019 -0500
Simplify user agent construction
embed/ephy-embed-prefs.c | 13 ++-----------
lib/ephy-user-agent.c | 15 ++++++++++-----
lib/ephy-user-agent.h | 2 +-
3 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index dcae90dd1..a3158fcd8 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -142,17 +142,8 @@ webkit_pref_callback_user_agent (GSettings *settings,
const char *key,
gpointer data)
{
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- char *user_agent;
-
- if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_APPLICATION)
- user_agent = g_strdup_printf ("%s (Web App)", ephy_user_agent_get_internal ());
- else
- user_agent = g_strdup (ephy_user_agent_get_internal ());
-
- webkit_settings_set_user_agent (webkit_settings, user_agent);
-
- g_free (user_agent);
+ webkit_settings_set_user_agent (webkit_settings,
+ ephy_user_agent_get ());
}
static void
diff --git a/lib/ephy-user-agent.c b/lib/ephy-user-agent.c
index 7d598f733..d30114053 100644
--- a/lib/ephy-user-agent.c
+++ b/lib/ephy-user-agent.c
@@ -21,16 +21,18 @@
#include "config.h"
#include "ephy-user-agent.h"
+#include "ephy-file-helpers.h"
#include "ephy-settings.h"
#include <webkit2/webkit2.h>
const char *
-ephy_user_agent_get_internal (void)
+ephy_user_agent_get (void)
{
- WebKitSettings *settings;
static char *user_agent = NULL;
- gboolean mobile = FALSE;
+ WebKitSettings *settings;
+ gboolean mobile;
+ gboolean web_app;
if (user_agent)
return user_agent;
@@ -43,10 +45,13 @@ ephy_user_agent_get_internal (void)
}
mobile = g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_MOBILE_USER_AGENT);
+ web_app = ephy_profile_dir_is_web_application ();
+
settings = webkit_settings_new ();
- user_agent = g_strdup_printf ("%s%s Epiphany/605.1.15",
+ user_agent = g_strdup_printf ("%s%s Epiphany/605.1.15%s",
webkit_settings_get_user_agent (settings),
- mobile ? " Mobile" : "");
+ mobile ? " Mobile" : "",
+ web_app ? " (Web App)" : "");
g_object_unref (settings);
return user_agent;
diff --git a/lib/ephy-user-agent.h b/lib/ephy-user-agent.h
index 4f02b7a47..353bbbb49 100644
--- a/lib/ephy-user-agent.h
+++ b/lib/ephy-user-agent.h
@@ -24,6 +24,6 @@
G_BEGIN_DECLS
-const char *ephy_user_agent_get_internal (void);
+const char *ephy_user_agent_get (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]