Introduce Automatic user agent and allow quirks
The new Automatic user agent is meant to pick the string that websites most likely check for. Right now this is Safari. Quirks built-in to WebKit are also used. The separate Midori identification has no quirks. Fixes: https://bugs.launchpad.net/midori/+bug/865503
This commit is contained in:
parent
76a9bc38ff
commit
3e60f4424b
3 changed files with 20 additions and 7 deletions
|
@ -496,6 +496,7 @@ g_icon_to_string (GIcon *icon)
|
||||||
* "custom-PROPERTY": the last value of an enumeration will be the "custom"
|
* "custom-PROPERTY": the last value of an enumeration will be the "custom"
|
||||||
* value, where the user may enter text freely, which then updates
|
* value, where the user may enter text freely, which then updates
|
||||||
* the property PROPERTY instead. This applies only to enumerations.
|
* the property PROPERTY instead. This applies only to enumerations.
|
||||||
|
* Since 0.4.2 mnemonics are automatically stripped.
|
||||||
* Since 0.2.9 the following hints are also supported:
|
* Since 0.2.9 the following hints are also supported:
|
||||||
* "languages": the widget will be particularly suitable for choosing
|
* "languages": the widget will be particularly suitable for choosing
|
||||||
* multiple language codes, ie. "de,en_GB".
|
* multiple language codes, ie. "de,en_GB".
|
||||||
|
@ -880,12 +881,14 @@ katze_property_proxy (gpointer object,
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < enum_class->n_values; i++)
|
for (i = 0; i < enum_class->n_values; i++)
|
||||||
{
|
{
|
||||||
const gchar* label = gettext (enum_class->values[i].value_nick);
|
const gchar* raw_label = gettext (enum_class->values[i].value_nick);
|
||||||
|
gchar* label = katze_strip_mnemonics (raw_label);
|
||||||
#ifdef HAVE_HILDON_2_2
|
#ifdef HAVE_HILDON_2_2
|
||||||
hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), label);
|
hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), label);
|
||||||
#else
|
#else
|
||||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), label);
|
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), label);
|
||||||
#endif
|
#endif
|
||||||
|
g_free (label);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_HILDON_2_2
|
#ifdef HAVE_HILDON_2_2
|
||||||
hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, value);
|
hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, value);
|
||||||
|
|
|
@ -290,7 +290,8 @@ midori_identity_get_type (void)
|
||||||
if (!type)
|
if (!type)
|
||||||
{
|
{
|
||||||
static const GEnumValue values[] = {
|
static const GEnumValue values[] = {
|
||||||
{ MIDORI_IDENT_MIDORI, "MIDORI_IDENT_MIDORI", N_("Midori") },
|
{ MIDORI_IDENT_MIDORI, "MIDORI_IDENT_MIDORI", N_("_Automatic") },
|
||||||
|
{ MIDORI_IDENT_GENUINE, "MIDORI_IDENT_GENUINE", N_("Midori") },
|
||||||
{ MIDORI_IDENT_SAFARI, "MIDORI_IDENT_SAFARI", N_("Safari") },
|
{ MIDORI_IDENT_SAFARI, "MIDORI_IDENT_SAFARI", N_("Safari") },
|
||||||
{ MIDORI_IDENT_IPHONE, "MIDORI_IDENT_IPHONE", N_("iPhone") },
|
{ MIDORI_IDENT_IPHONE, "MIDORI_IDENT_IPHONE", N_("iPhone") },
|
||||||
{ MIDORI_IDENT_FIREFOX, "MIDORI_IDENT_FIREFOX", N_("Firefox") },
|
{ MIDORI_IDENT_FIREFOX, "MIDORI_IDENT_FIREFOX", N_("Firefox") },
|
||||||
|
@ -1096,7 +1097,8 @@ get_sys_name (void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gchar*
|
static gchar*
|
||||||
generate_ident_string (MidoriIdentity identify_as)
|
generate_ident_string (MidoriWebSettings* web_settings,
|
||||||
|
MidoriIdentity identify_as)
|
||||||
{
|
{
|
||||||
const gchar* platform =
|
const gchar* platform =
|
||||||
#if HAVE_HILDON
|
#if HAVE_HILDON
|
||||||
|
@ -1133,12 +1135,19 @@ generate_ident_string (MidoriIdentity identify_as)
|
||||||
const int webcore_major = WEBKIT_USER_AGENT_MAJOR_VERSION;
|
const int webcore_major = WEBKIT_USER_AGENT_MAJOR_VERSION;
|
||||||
const int webcore_minor = WEBKIT_USER_AGENT_MINOR_VERSION;
|
const int webcore_minor = WEBKIT_USER_AGENT_MINOR_VERSION;
|
||||||
|
|
||||||
|
#if WEBKIT_CHECK_VERSION (1, 1, 18)
|
||||||
|
g_object_set (web_settings, "enable-site-specific-quirks",
|
||||||
|
identify_as != MIDORI_IDENT_GENUINE, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (identify_as)
|
switch (identify_as)
|
||||||
{
|
{
|
||||||
case MIDORI_IDENT_MIDORI:
|
case MIDORI_IDENT_GENUINE:
|
||||||
return g_strdup_printf ("Mozilla/5.0 (%s %s) AppleWebKit/%d.%d+ %s",
|
return g_strdup_printf ("Mozilla/5.0 (%s %s) AppleWebKit/%d.%d+ %s",
|
||||||
platform, os, webcore_major, webcore_minor, appname);
|
platform, os, webcore_major, webcore_minor, appname);
|
||||||
|
case MIDORI_IDENT_MIDORI:
|
||||||
case MIDORI_IDENT_SAFARI:
|
case MIDORI_IDENT_SAFARI:
|
||||||
|
g_object_set (web_settings, "enable-site-specific-quirks", TRUE, NULL);
|
||||||
return g_strdup_printf ("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; %s) "
|
return g_strdup_printf ("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; %s) "
|
||||||
"AppleWebKit/%d+ (KHTML, like Gecko) Version/5.0 Safari/%d.%d+ %s",
|
"AppleWebKit/%d+ (KHTML, like Gecko) Version/5.0 Safari/%d.%d+ %s",
|
||||||
lang, webcore_major, webcore_major, webcore_minor, appname);
|
lang, webcore_major, webcore_major, webcore_minor, appname);
|
||||||
|
@ -1365,7 +1374,7 @@ midori_web_settings_set_property (GObject* object,
|
||||||
web_settings->identify_as = g_value_get_enum (value);
|
web_settings->identify_as = g_value_get_enum (value);
|
||||||
if (web_settings->identify_as != MIDORI_IDENT_CUSTOM)
|
if (web_settings->identify_as != MIDORI_IDENT_CUSTOM)
|
||||||
{
|
{
|
||||||
gchar* string = generate_ident_string (web_settings->identify_as);
|
gchar* string = generate_ident_string (web_settings, web_settings->identify_as);
|
||||||
katze_assign (web_settings->ident_string, string);
|
katze_assign (web_settings->ident_string, string);
|
||||||
g_object_set (web_settings, "user-agent", string, NULL);
|
g_object_set (web_settings, "user-agent", string, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1625,7 +1634,7 @@ midori_web_settings_get_property (GObject* object,
|
||||||
case PROP_USER_AGENT:
|
case PROP_USER_AGENT:
|
||||||
if (!g_strcmp0 (web_settings->ident_string, ""))
|
if (!g_strcmp0 (web_settings->ident_string, ""))
|
||||||
{
|
{
|
||||||
gchar* string = generate_ident_string (web_settings->identify_as);
|
gchar* string = generate_ident_string (web_settings, web_settings->identify_as);
|
||||||
katze_assign (web_settings->ident_string, string);
|
katze_assign (web_settings->ident_string, string);
|
||||||
}
|
}
|
||||||
g_value_set_string (value, web_settings->ident_string);
|
g_value_set_string (value, web_settings->ident_string);
|
||||||
|
|
|
@ -137,7 +137,8 @@ midori_proxy_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MIDORI_IDENT_MIDORI,
|
MIDORI_IDENT_MIDORI /* Automatic */,
|
||||||
|
MIDORI_IDENT_GENUINE /* Midori */,
|
||||||
MIDORI_IDENT_SAFARI,
|
MIDORI_IDENT_SAFARI,
|
||||||
MIDORI_IDENT_IPHONE,
|
MIDORI_IDENT_IPHONE,
|
||||||
MIDORI_IDENT_FIREFOX,
|
MIDORI_IDENT_FIREFOX,
|
||||||
|
|
Loading…
Reference in a new issue