[epiphany] ephy-embed-prefs: Port user agent to WebKit2
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-embed-prefs: Port user agent to WebKit2
- Date: Mon, 8 Oct 2012 08:37:27 +0000 (UTC)
commit 7512839e6add584e184805d3781f9976831a2188
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Sep 24 12:32:22 2012 +0200
ephy-embed-prefs: Port user agent to WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=684443
embed/ephy-embed-prefs.c | 65 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 9 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 2c93463..10f5084 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -82,14 +82,11 @@ webkit_pref_callback_user_stylesheet (GSettings *settings,
}
static char *
-webkit_pref_get_internal_user_agent (void)
+webkit_pref_get_vendor_user_agent (void)
{
- char *user_agent;
- char *webkit_user_agent;
- char *vendor_user_agent;
+ char *vendor_user_agent = NULL;
GKeyFile *branding_keyfile;
- vendor_user_agent = NULL;
branding_keyfile = g_key_file_new ();
if (g_key_file_load_from_file (branding_keyfile, SHARE_DIR"/branding.conf",
@@ -122,10 +119,44 @@ webkit_pref_get_internal_user_agent (void)
g_key_file_free (branding_keyfile);
+ return vendor_user_agent;
+}
+
#ifdef HAVE_WEBKIT2
- /* TODO: User agent */
- return g_strdup ("");
+static const char *
+webkit_pref_get_internal_user_agent (void)
+{
+ static char *user_agent = NULL;
+ static gboolean initialized = FALSE;
+ char *vendor_user_agent;
+ const char *webkit_user_agent;
+
+ if (initialized)
+ return user_agent;
+
+ initialized = TRUE;
+
+ vendor_user_agent = webkit_pref_get_vendor_user_agent ();
+ if (!vendor_user_agent)
+ return NULL;
+
+ webkit_user_agent = webkit_settings_get_user_agent (webkit_settings);
+ user_agent = g_strdup_printf ("%s %s Epiphany/%s", webkit_user_agent,
+ vendor_user_agent, VERSION);
+ g_free (vendor_user_agent);
+
+ return user_agent;
+}
#else
+static char *
+webkit_pref_get_internal_user_agent (void)
+{
+ char *user_agent;
+ char *webkit_user_agent;
+ char *vendor_user_agent;
+
+ vendor_user_agent = webkit_pref_get_vendor_user_agent ();
+
g_object_get (webkit_settings, "user-agent", &webkit_user_agent, NULL);
user_agent = g_strconcat (webkit_user_agent, " ",
@@ -138,8 +169,8 @@ webkit_pref_get_internal_user_agent (void)
g_free (webkit_user_agent);
return user_agent;
-#endif
}
+#endif
static void
webkit_pref_callback_user_agent (GSettings *settings,
@@ -147,7 +178,23 @@ webkit_pref_callback_user_agent (GSettings *settings,
gpointer data)
{
#ifdef HAVE_WEBKIT2
- /* TODO: User agent */
+ char *value;
+ const char *internal_user_agent;
+
+ value = g_settings_get_string (settings, key);
+ if (value != NULL && value[0] != '\0') {
+ webkit_settings_set_user_agent (webkit_settings, value);
+ g_free (value);
+ return;
+ }
+ g_free (value);
+
+ internal_user_agent = webkit_pref_get_internal_user_agent ();
+ if (internal_user_agent)
+ webkit_settings_set_user_agent (webkit_settings, internal_user_agent);
+ else
+ webkit_settings_set_user_agent_with_application_details (webkit_settings,
+ "Epiphany", VERSION);
#else
char *value = NULL;
static char *internal_user_agent = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]