Title: [101379] trunk/Source/WebKit/gtk
Revision
101379
Author
mrobin...@webkit.org
Date
2011-11-29 07:49:58 -0800 (Tue, 29 Nov 2011)

Log Message

[GTK] Custom fonts on surlybikes.com and boingboing.net do not load
https://bugs.webkit.org/show_bug.cgi?id=69115

Reviewed by Gustavo Noronha Silva.

Instead of pretending to be Safari/Linux, pretend to be a Linux Chrome.
This fixes pages that assume that if a browser is Safari, but not OS X, it is
the iOS version of Safari.

* tests/testwebsettings.c:
(test_webkit_web_settings_user_agent): Update the test to reflect that the
user agent does not change.
* webkit/webkitwebsettings.cpp:
(chromeUserAgent): Renamed this from webkitUserAgent to more accurately
describe what it is.
(webkit_web_settings_class_init): Just use an empty string when initializing
the user agent to reduce code duplication.
(webkit_web_settings_set_property): Updated to reflect new method name.
(userAgentForURL): We don't need to special case Google Calendar any longer.

Modified Paths

Diff

Modified: trunk/Source/WebKit/gtk/ChangeLog (101378 => 101379)


--- trunk/Source/WebKit/gtk/ChangeLog	2011-11-29 15:49:04 UTC (rev 101378)
+++ trunk/Source/WebKit/gtk/ChangeLog	2011-11-29 15:49:58 UTC (rev 101379)
@@ -1,3 +1,25 @@
+2011-11-29  Martin Robinson  <mrobin...@igalia.com>
+
+        [GTK] Custom fonts on surlybikes.com and boingboing.net do not load
+        https://bugs.webkit.org/show_bug.cgi?id=69115
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Instead of pretending to be Safari/Linux, pretend to be a Linux Chrome.
+        This fixes pages that assume that if a browser is Safari, but not OS X, it is
+        the iOS version of Safari.
+
+        * tests/testwebsettings.c:
+        (test_webkit_web_settings_user_agent): Update the test to reflect that the
+        user agent does not change.
+        * webkit/webkitwebsettings.cpp:
+        (chromeUserAgent): Renamed this from webkitUserAgent to more accurately
+        describe what it is.
+        (webkit_web_settings_class_init): Just use an empty string when initializing
+        the user agent to reduce code duplication.
+        (webkit_web_settings_set_property): Updated to reflect new method name.
+        (userAgentForURL): We don't need to special case Google Calendar any longer.
+
 2011-11-29  Mario Sanchez Prada  <msanc...@igalia.com>
 
         [Gtk] Regression: text-inserted events lack text inserted and current line

Modified: trunk/Source/WebKit/gtk/tests/testwebsettings.c (101378 => 101379)


--- trunk/Source/WebKit/gtk/tests/testwebsettings.c	2011-11-29 15:49:04 UTC (rev 101378)
+++ trunk/Source/WebKit/gtk/tests/testwebsettings.c	2011-11-29 15:49:58 UTC (rev 101379)
@@ -139,10 +139,6 @@
     g_assert_cmpstr(userAgent, ==, "testwebsettings/0.1");
     g_free(userAgent);
 
-    userAgent = webkitWebSettingsUserAgentForURI(settings, "http://calendar.google.com/");
-    g_assert(g_str_has_prefix(userAgent, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en_US) AppleWebKit/"));
-    g_free(userAgent);
-
     g_free(defaultUserAgent);
     g_object_unref(webView);
 }

Modified: trunk/Source/WebKit/gtk/webkit/webkitwebsettings.cpp (101378 => 101379)


--- trunk/Source/WebKit/gtk/webkit/webkitwebsettings.cpp	2011-11-29 15:49:04 UTC (rev 101378)
+++ trunk/Source/WebKit/gtk/webkit/webkitwebsettings.cpp	2011-11-29 15:49:58 UTC (rev 101379)
@@ -172,30 +172,20 @@
     return uaOSVersion;
 }
 
-static String webkitUserAgent()
+static String chromeUserAgent()
 {
     // We mention Safari since many broken sites check for it (OmniWeb does this too)
     // We re-use the WebKit version, though it doesn't seem to matter much in practice
+    // We claim to be Chrome as well, which prevents sites that look for Safari and assume
+    // that since we are not OS X, that we are the mobile version of Safari.
 
     DEFINE_STATIC_LOCAL(const String, uaVersion, (makeString(String::number(WEBKIT_USER_AGENT_MAJOR_VERSION), '.', String::number(WEBKIT_USER_AGENT_MINOR_VERSION), '+')));
     DEFINE_STATIC_LOCAL(const String, staticUA, (makeString("Mozilla/5.0 (", webkitPlatform(), webkitOSVersion(), ") AppleWebKit/", uaVersion) +
-                                                 makeString(" (KHTML, like Gecko) Version/5.0 Safari/", uaVersion)));
+                                                 makeString(" (KHTML, like Gecko) Chromium/15.0.874.120 Chrome/15.0.874.120 Safari/", uaVersion)));
 
     return staticUA;
 }
 
-static String safariUserAgent()
-{
-    // We mention Safari since many broken sites check for it (OmniWeb does this too)
-    // We re-use the WebKit version, though it doesn't seem to matter much in practice
-
-    DEFINE_STATIC_LOCAL(const String, uaVersion, (makeString(String::number(WEBKIT_USER_AGENT_MAJOR_VERSION), '.', String::number(WEBKIT_USER_AGENT_MINOR_VERSION), '+')));
-    DEFINE_STATIC_LOCAL(const String, staticUA, (makeString("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en_US) AppleWebKit/", uaVersion) +
-                                                 makeString(" (KHTML, like Gecko) Version/5.0.5 Safari/", uaVersion)));
-
-    return staticUA;
-}
-
 static void webkit_web_settings_finalize(GObject* object);
 
 static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
@@ -621,7 +611,7 @@
                                     g_param_spec_string("user-agent",
                                                         _("User Agent"),
                                                         _("The User-Agent string used by WebKitGtk"),
-                                                        webkitUserAgent().utf8().data(),
+                                                        "", // An empty string means the default user-agent.
                                                         flags));
 
     /**
@@ -1038,7 +1028,7 @@
         break;
     case PROP_USER_AGENT:
         if (!g_value_get_string(value) || !strlen(g_value_get_string(value)))
-            priv->userAgent = webkitUserAgent().utf8();
+            priv->userAgent = chromeUserAgent().utf8();
         else
             priv->userAgent = g_value_get_string(value);
         break;
@@ -1437,25 +1427,12 @@
     return false;
 }
 
-static bool isGoogleCalendar(const KURL& url)
-{
-    if (url.host().find("calendar.google.") == 0
-        || (url.host().find("google.com") && url.path().startsWith("/calendar")))
-        return true;
-
-    return false;
-}
-
 static String userAgentForURL(const KURL& url)
 {
     // For Google domains, drop the browser's custom User Agent string, and use the
-    // standard WebKit/Safari one, so they don't give us a broken experience. Calendar
-    // thinks "Linux WebKit" means mobile.
-    if (isGoogleCalendar(url))
-        return safariUserAgent();
-
+    // standard Chrome one, so they don't give us a broken experience.
     if (isGoogleDomain(url.host()))
-        return webkitUserAgent();
+        return chromeUserAgent();
 
     return String();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to