Skip to content

Commit

Permalink
Merge r159572 - [GTK] Remove Chromium as user agent and claim to be S…
Browse files Browse the repository at this point in the history
…afari 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):
  • Loading branch information
ceyusa authored and carlosgcampos committed Dec 2, 2013
1 parent e7acd84 commit a5ddc63
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2013-11-20 Víctor Manuel Jáquez Leal <vjaquez@igalia.com>

[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):

2013-09-24 Lorenzo Tilve <ltilve@igalia.com>

[GTK] Fix compilation problems when setting ENABLE_DRAG_SUPPORT = FALSE
Expand Down
42 changes: 24 additions & 18 deletions Source/WebCore/platform/gtk/UserAgentGtk.cpp
Expand Up @@ -36,6 +36,21 @@

namespace WebCore {

#if OS(DARWIN) || OS(UNIX)
static const char* cpuDescriptionForUAString()
{
#if CPU(PPC) || CPU(PPC64)
return "PPC";
#elif CPU(X86) || CPU(X86_64)
return "Intel";
#elif CPU(ARM) || CPU(ARM64)
return "ARM";
#else
return "Unknown";
#endif
}
#endif

static const char* platformForUAString()
{
#if PLATFORM(X11)
Expand All @@ -59,18 +74,10 @@ static String platformVersionForUAString()

#if OS(WINDOWS)
uaOSVersion = windowsVersionForUAString();
#elif OS(DARWIN)
#if CPU(X86) || CPU(X86_64)
uaOSVersion = "Intel Mac OS X";
#else
uaOSVersion = "PPC Mac OS X";
#endif
#elif OS(UNIX)
struct utsname name;
if (uname(&name) != -1)
uaOSVersion = String::format("%s %s", name.sysname, name.machine);
else
uaOSVersion = String("Unknown");
#elif OS(DARWIN) || OS(UNIX)
// We will always claim to be Safari in Mac OS X, since Safari in Linux triggers the iOS path on
// some websites.
uaOSVersion = String::format("%s Mac OS X", cpuDescriptionForUAString());
#else
uaOSVersion = String("Unknown");
#endif
Expand All @@ -79,17 +86,16 @@ static String platformVersionForUAString()

String standardUserAgent(const String& applicationName, const String& applicationVersion)
{
// Create a default user agent string with a liberal interpretation of
// Create a default user agent string with a liberal interpretation of
// https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference
//
// Forming a functional user agent is really difficult. We must mention Safari, because some
// sites check for that when detecting WebKit browsers. Additionally some sites assume that
// browsers that are "Safari" but not running on OS X are the Safari iOS browser, so we
// also claim to be Chromium. Getting this wrong can cause sites to load the wrong JavaScript,
// CSS, or custom fonts. In some cases sites won't load resources at all.
// browsers that are "Safari" but not running on OS X are the Safari iOS browse. Getting this
// wrong can cause sites to load the wrong JavaScript, CSS, or custom fonts. In some cases
// sites won't load resources at all.
DEFINE_STATIC_LOCAL(const CString, uaVersion, (String::format("%i.%i", USER_AGENT_GTK_MAJOR_VERSION, USER_AGENT_GTK_MINOR_VERSION).utf8()));
DEFINE_STATIC_LOCAL(const String, staticUA, (String::format("Mozilla/5.0 (%s; %s) AppleWebKit/%s (KHTML, like Gecko) "
"Chromium/25.0.1349.2 Chrome/25.0.1349.2 Safari/%s",
DEFINE_STATIC_LOCAL(const String, staticUA, (String::format("Mozilla/5.0 (%s; %s) AppleWebKit/%s (KHTML, like Gecko) Safari/%s",
platformForUAString(), platformVersionForUAString().utf8().data(),
uaVersion.data(), uaVersion.data())));
if (applicationName.isEmpty())
Expand Down

0 comments on commit a5ddc63

Please sign in to comment.