Changeset 159572 in webkit


Ignore:
Timestamp:
Nov 20, 2013 10:44:01 AM (10 years ago)
Author:
vjaquez@igalia.com
Message:

[GTK] Remove Chromium as user agent and claim to be Safari in OS X
https://bugs.webkit.org/show_bug.cgi?id=124229

Reviewed by Martin Robinson.

http://www.duolingo.com/ doesn't get render correctly because it uses
Chrome/Chromium specific variables, added after it was forked. Because
of this, it is necessary to remove the Chrome/Chromium identification
in the user agent. Also, from now on, by default, The GTK+ port will
claim to be Safari in OS X to avoid loading wrong resources.

  • platform/gtk/UserAgentGtk.cpp:

(WebCore::standardUserAgent):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r159570 r159572  
     12013-11-20  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [GTK] Remove Chromium as user agent and claim to be Safari in OS X
     4        https://bugs.webkit.org/show_bug.cgi?id=124229
     5
     6        Reviewed by Martin Robinson.
     7
     8        http://www.duolingo.com/ doesn't get render correctly because it uses
     9        Chrome/Chromium specific variables, added after it was forked. Because
     10        of this, it is necessary to remove the Chrome/Chromium identification
     11        in the user agent. Also, from now on, by default, The GTK+ port will
     12        claim to be Safari in OS X to avoid loading wrong resources.
     13
     14        * platform/gtk/UserAgentGtk.cpp:
     15        (WebCore::standardUserAgent):
     16
    1172013-11-20  Commit Queue  <commit-queue@webkit.org>
    218
  • trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp

    r145795 r159572  
    3737namespace WebCore {
    3838
     39#if OS(DARWIN) || OS(UNIX)
     40static const char* cpuDescriptionForUAString()
     41{
     42#if CPU(PPC) || CPU(PPC64)
     43    return "PPC";
     44#elif CPU(X86) || CPU(X86_64)
     45    return "Intel";
     46#elif CPU(ARM) || CPU(ARM64)
     47    return "ARM";
     48#else
     49    return "Unknown";
     50#endif
     51}
     52#endif
     53
    3954static const char* platformForUAString()
    4055{
     
    6075#if OS(WINDOWS)
    6176    uaOSVersion = windowsVersionForUAString();
    62 #elif OS(DARWIN)
    63 #if CPU(X86) || CPU(X86_64)
    64     uaOSVersion = "Intel Mac OS X";
    65 #else
    66     uaOSVersion = "PPC Mac OS X";
    67 #endif
    68 #elif OS(UNIX)
    69     struct utsname name;
    70     if (uname(&name) != -1)
    71         uaOSVersion = String::format("%s %s", name.sysname, name.machine);
    72     else
    73         uaOSVersion = String("Unknown");
     77#elif OS(DARWIN) || OS(UNIX)
     78    // We will always claim to be Safari in Mac OS X, since Safari in Linux triggers the iOS path on
     79    // some websites.
     80    uaOSVersion = String::format("%s Mac OS X", cpuDescriptionForUAString());
    7481#else
    7582    uaOSVersion = String("Unknown");
     
    8087String standardUserAgent(const String& applicationName, const String& applicationVersion)
    8188{
    82     // Create a default user agent string with a liberal interpretation of 
     89    // Create a default user agent string with a liberal interpretation of
    8390    // https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference
    8491    //
    8592    // Forming a functional user agent is really difficult. We must mention Safari, because some
    8693    // sites check for that when detecting WebKit browsers. Additionally some sites assume that
    87     // browsers that are "Safari" but not running on OS X are the Safari iOS browser, so we
    88     // also claim to be  Chromium. Getting this wrong can cause sites to load the wrong JavaScript,
    89     // CSS, or custom fonts. In some cases sites won't load resources at all.
     94    // browsers that are "Safari" but not running on OS X are the Safari iOS browse. Getting this
     95    // wrong can cause sites to load the wrong JavaScript, CSS, or custom fonts. In some cases
     96    // sites won't load resources at all.
    9097    DEFINE_STATIC_LOCAL(const CString, uaVersion, (String::format("%i.%i", USER_AGENT_GTK_MAJOR_VERSION, USER_AGENT_GTK_MINOR_VERSION).utf8()));
    91     DEFINE_STATIC_LOCAL(const String, staticUA, (String::format("Mozilla/5.0 (%s; %s) AppleWebKit/%s (KHTML, like Gecko) "
    92                                                                 "Chromium/25.0.1349.2 Chrome/25.0.1349.2 Safari/%s",
     98    DEFINE_STATIC_LOCAL(const String, staticUA, (String::format("Mozilla/5.0 (%s; %s) AppleWebKit/%s (KHTML, like Gecko) Safari/%s",
    9399                                                                platformForUAString(), platformVersionForUAString().utf8().data(),
    94100                                                                uaVersion.data(), uaVersion.data())));
Note: See TracChangeset for help on using the changeset viewer.