static String buildUserAgentString(const UserAgentQuirks& quirks) { StringBuilder uaString; uaString.appendLiteral("Mozilla/5.0 "); uaString.append('('); if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform)) uaString.appendLiteral("Macintosh"); else uaString.append(platformForUAString()); uaString.appendLiteral("; "); if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform)) { uaString.append(cpuDescriptionForUAString()); uaString.appendLiteral(" Mac OS X"); } else uaString.append(platformVersionForUAString()); uaString.appendLiteral(") AppleWebKit/"); uaString.append(versionForUAString()); // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See // https://bugs.webkit.org/show_bug.cgi?id=133403 for details. uaString.appendLiteral(" (KHTML, like Gecko) Version/8.0 Safari/"); uaString.append(versionForUAString()); return uaString.toString(); }
static String buildUserAgentString(const UserAgentQuirks& quirks) { StringBuilder uaString; uaString.appendLiteral("Mozilla/5.0 "); uaString.append('('); if (quirks.contains(UserAgentQuirks::NeedsMacintoshPlatform)) uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsMacintoshPlatform)); else if (quirks.contains(UserAgentQuirks::NeedsLinuxDesktopPlatform)) uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsLinuxDesktopPlatform)); else { uaString.append(platformForUAString()); uaString.appendLiteral("; "); uaString.append(platformVersionForUAString()); } if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) { uaString.appendLiteral("; "); uaString.append(UserAgentQuirks::firefoxRevisionString()); uaString.appendLiteral(") "); } else { uaString.appendLiteral(") AppleWebKit/"); uaString.append(versionForUAString()); uaString.appendLiteral(" (KHTML, like Gecko) "); } // Note that Chrome UAs advertise *both* Chrome and Safari. if (quirks.contains(UserAgentQuirks::NeedsChromeBrowser)) { uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsChromeBrowser)); uaString.appendLiteral(" "); } else if (quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) { uaString.append(UserAgentQuirks::stringForQuirk(UserAgentQuirks::NeedsFirefoxBrowser)); uaString.appendLiteral(" "); } if (!quirks.contains(UserAgentQuirks::NeedsFirefoxBrowser)) { // Version/X is mandatory *before* Safari/X to be a valid Safari UA. See // https://bugs.webkit.org/show_bug.cgi?id=133403 for details. uaString.appendLiteral("Version/10.0 Safari/"); uaString.append(versionForUAString()); } return uaString.toString(); }