epiphany/epiphany-user-agent.patch

90 lines
3.2 KiB
Diff

diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in
index a847aa2..98f8db2 100644
--- a/data/epiphany.schemas.in
+++ b/data/epiphany.schemas.in
@@ -478,6 +478,17 @@
<short>Browse with caret</short>
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/epiphany/web/user_agent_vendor</key>
+ <applyto>/apps/epiphany/web/user_agent_vendor</applyto>
+ <owner>epiphany</owner>
+ <type>string</type>
+ <default>GNOME.org</default>
+ <locale name="C">
+ <short>Vendor to include in the user agent</short>
+ <long>String that will be appended to the user agent, containing vendor-specific information.</long>
+ </locale>
+ </schema>
<schema>
<key>/schemas/apps/epiphany/general/managed_network</key>
<applyto>/apps/epiphany/general/managed_network</applyto>
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index c1a14df..8c8f19b 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -134,6 +134,38 @@ webkit_pref_callback_user_stylesheet (GConfClient *client,
}
static void
+webkit_pref_callback_user_agent_vendor (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer data)
+{
+ GConfValue *gcvalue;
+ const char *value = NULL;
+ static char *webkit_user_agent = NULL;
+ char *user_agent = NULL;
+ char *webkit_pref = data;
+
+ gcvalue = gconf_entry_get_value (entry);
+
+ /* happens on initial notify if the key doesn't exist */
+ if (gcvalue != NULL &&
+ gcvalue->type == GCONF_VALUE_STRING) {
+ value = gconf_value_get_string (gcvalue);
+ }
+
+ if (webkit_user_agent == NULL) {
+ g_object_get (G_OBJECT(settings), "user-agent", &webkit_user_agent, NULL);
+ }
+
+ user_agent = g_strconcat (webkit_user_agent, " ",
+ "Epiphany/"VERSION, value ? " " : NULL,
+ value, NULL);
+
+ g_object_set (settings, webkit_pref, user_agent, NULL);
+ g_free (user_agent);
+}
+
+static void
webkit_pref_callback_font_size (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
@@ -228,7 +260,10 @@ static const PrefData webkit_pref_entries[] =
webkit_pref_callback_user_stylesheet },
{ CONF_CARET_BROWSING_ENABLED,
"enable-caret-browsing",
- webkit_pref_callback_boolean }
+ webkit_pref_callback_boolean },
+ { CONF_USER_AGENT_VENDOR,
+ "user-agent",
+ webkit_pref_callback_user_agent_vendor }
};
static void
diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h
index ada4ac8..cbe7423 100644
--- a/embed/ephy-embed-prefs.h
+++ b/embed/ephy-embed-prefs.h
@@ -41,6 +41,7 @@
#define CONF_DISPLAY_SMOOTHSCROLL "/apps/epiphany/web/smooth_scroll"
#define CONF_WEB_INSPECTOR_ENABLED "/apps/epiphany/web/inspector_enabled"
#define CONF_CARET_BROWSING_ENABLED "/apps/epiphany/web/browse_with_caret"
+#define CONF_USER_AGENT_VENDOR "/apps/epiphany/web/user_agent_vendor"
/* These are defined gnome wide now */
#define CONF_NETWORK_PROXY_MODE "/system/proxy/mode"