[epiphany/mcatanzaro/user-agent] Simplify user agent construction



commit 299be3e06562ad2c5422728a822dfbd6c9c08299
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    | 13 +++++++++----
 2 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index dcae90dd1..42b3d94ec 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_internal ());
 }
 
 static void
diff --git a/lib/ephy-user-agent.c b/lib/ephy-user-agent.c
index 7d598f733..be7b982b0 100644
--- a/lib/ephy-user-agent.c
+++ b/lib/ephy-user-agent.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "ephy-user-agent.h"
 
+#include "ephy-file-helpers.h"
 #include "ephy-settings.h"
 
 #include <webkit2/webkit2.h>
@@ -28,9 +29,10 @@
 const char *
 ephy_user_agent_get_internal (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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]