diff options
author | Adrien Plazas <kekun.plazas@laposte.net> | 2019-05-31 17:29:22 +0200 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@posteo.net> | 2019-06-11 14:14:57 +0000 |
commit | 3a3d32efb169a5a371aaff74fe4ce052e7507f82 (patch) | |
tree | d907ac66bec64f9756d50b4e7cb2d12ae0ae18f0 | |
parent | e812bbb61eb0e372c48a1bc42778f7390c1736ea (diff) | |
download | epiphany-3a3d32efb169a5a371aaff74fe4ce052e7507f82.tar.gz |
Add the "mobile-user-agent" setting
This allows to use a mobile user agent.
-rw-r--r-- | data/org.gnome.epiphany.gschema.xml | 5 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.c | 5 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 2 | ||||
-rw-r--r-- | lib/ephy-user-agent.c | 6 |
4 files changed, 17 insertions, 1 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml index 758668cbc..0392949a2 100644 --- a/data/org.gnome.epiphany.gschema.xml +++ b/data/org.gnome.epiphany.gschema.xml @@ -184,6 +184,11 @@ <summary>User agent</summary> <description>String that will be used as user agent, to identify the browser to the web servers.</description> </key> + <key type="b" name="mobile-user-agent"> + <default>false</default> + <summary>Mobile user agent</summary> + <description>Whether to present a mobile user agent. If the user agent is overridden, this will have no effect.</description> + </key> <key type="b" name="do-not-track"> <default>true</default> <summary>Do Not Track</summary> diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c index 1a0fb5d72..dcae90dd1 100644 --- a/embed/ephy-embed-prefs.c +++ b/embed/ephy-embed-prefs.c @@ -472,6 +472,11 @@ static const PrefData webkit_pref_entries[] = "user-agent", webkit_pref_callback_user_agent }, { EPHY_PREFS_WEB_SCHEMA, + EPHY_PREFS_WEB_MOBILE_USER_AGENT, + "mobile-user-agent", + /* No need for a specific callback, we just want to update the user agent. */ + webkit_pref_callback_user_agent }, + { EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_COOKIES_POLICY, "accept-policy", webkit_pref_callback_cookie_accept_policy }, diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index 34cadfcf1..b23098051 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -111,6 +111,7 @@ static const char * const ephy_prefs_state_schema[] = { #define EPHY_PREFS_WEB_ENABLE_WEBAUDIO "enable-webaudio" #define EPHY_PREFS_WEB_ENABLE_SMOOTH_SCROLLING "enable-smooth-scrolling" #define EPHY_PREFS_WEB_USER_AGENT "user-agent" +#define EPHY_PREFS_WEB_MOBILE_USER_AGENT "mobile-user-agent" #define EPHY_PREFS_WEB_COOKIES_POLICY "cookies-policy" #define EPHY_PREFS_WEB_DEFAULT_ENCODING "default-encoding" #define EPHY_PREFS_WEB_DO_NOT_TRACK "do-not-track" @@ -142,6 +143,7 @@ static const char * const ephy_prefs_web_schema[] = { EPHY_PREFS_WEB_ENABLE_WEBAUDIO, EPHY_PREFS_WEB_ENABLE_SMOOTH_SCROLLING, EPHY_PREFS_WEB_USER_AGENT, + EPHY_PREFS_WEB_MOBILE_USER_AGENT, EPHY_PREFS_WEB_COOKIES_POLICY, EPHY_PREFS_WEB_DEFAULT_ENCODING, EPHY_PREFS_WEB_DO_NOT_TRACK, diff --git a/lib/ephy-user-agent.c b/lib/ephy-user-agent.c index 7bcf6f50d..7d598f733 100644 --- a/lib/ephy-user-agent.c +++ b/lib/ephy-user-agent.c @@ -30,6 +30,7 @@ ephy_user_agent_get_internal (void) { WebKitSettings *settings; static char *user_agent = NULL; + gboolean mobile = FALSE; if (user_agent) return user_agent; @@ -41,8 +42,11 @@ ephy_user_agent_get_internal (void) g_free (user_agent); } + mobile = g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_MOBILE_USER_AGENT); settings = webkit_settings_new (); - user_agent = g_strdup_printf ("%s Epiphany/605.1.15", webkit_settings_get_user_agent (settings)); + user_agent = g_strdup_printf ("%s%s Epiphany/605.1.15", + webkit_settings_get_user_agent (settings), + mobile ? " Mobile" : ""); g_object_unref (settings); return user_agent; |