Diff
Modified: trunk/ChangeLog (220630 => 220631)
--- trunk/ChangeLog 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/ChangeLog 2017-08-13 12:13:27 UTC (rev 220631)
@@ -1,3 +1,15 @@
+2017-08-13 Adrian Perez de Castro <[email protected]>
+
+ [WPE] Implement WebCore::standardUserAgent()
+ https://bugs.webkit.org/show_bug.cgi?id=175507
+
+ Reviewed by Carlos Alberto Lopez Perez.
+
+ Implement missing User-Agent handling for the WPE port by sharing the code with the GTK+ port.
+
+ * Source/cmake/OptionsGTK.cmake: Rename "GTK" with "GLIB" in UA version macros.
+ * Source/cmake/OptionsWPE.cmake: Add UA version macros.
+
2017-08-11 Ryosuke Niwa <[email protected]>
Replace DATA_TRANSFER_ITEMS by a runtime flag and add a stub implementation
Modified: trunk/Source/WebCore/ChangeLog (220630 => 220631)
--- trunk/Source/WebCore/ChangeLog 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebCore/ChangeLog 2017-08-13 12:13:27 UTC (rev 220631)
@@ -1,3 +1,17 @@
+2017-08-13 Adrian Perez de Castro <[email protected]>
+
+ [WPE] Implement WebCore::standardUserAgent()
+ https://bugs.webkit.org/show_bug.cgi?id=175507
+
+ Reviewed by Carlos Alberto Lopez Perez.
+
+ Implement missing User-Agent handling for the WPE port by sharing the code with the GTK+ port.
+
+ * PlatformGTK.cmake: Handlde renaming of UserAgentGtk.cpp to UserAgentGLib.cpp.
+ * PlatformWPE.cmake: Add UserAgentGLib.cpp and UserAgentQuirks.cpp to the list of built WebCore sources.
+ * platform/glib/UserAgentGLib.cpp: Renamed from Source/WebCore/platform/gtk/UserAgentGtk.cpp.
+ (WebCore::versionForUAString): Change "GTK" in UA version macros to "GLIB".
+
2017-08-11 Ryosuke Niwa <[email protected]>
Replace DATA_TRANSFER_ITEMS by a runtime flag and add a stub implementation
Modified: trunk/Source/WebCore/PlatformGTK.cmake (220630 => 220631)
--- trunk/Source/WebCore/PlatformGTK.cmake 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2017-08-13 12:13:27 UTC (rev 220631)
@@ -74,6 +74,7 @@
platform/glib/MainThreadSharedTimerGLib.cpp
platform/glib/SSLKeyGeneratorGLib.cpp
platform/glib/SharedBufferGlib.cpp
+ platform/glib/UserAgentGLib.cpp
platform/graphics/GLContext.cpp
platform/graphics/GraphicsContext3DPrivate.cpp
@@ -105,7 +106,6 @@
platform/gtk/PasteboardGtk.cpp
platform/gtk/ScrollAnimatorGtk.cpp
platform/gtk/SelectionData.cpp
- platform/gtk/UserAgentGtk.cpp
platform/network/soup/AuthenticationChallengeSoup.cpp
platform/network/soup/CertificateInfo.cpp
Modified: trunk/Source/WebCore/PlatformWPE.cmake (220630 => 220631)
--- trunk/Source/WebCore/PlatformWPE.cmake 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebCore/PlatformWPE.cmake 2017-08-13 12:13:27 UTC (rev 220631)
@@ -66,6 +66,7 @@
platform/Cursor.cpp
platform/PlatformStrategies.cpp
platform/Theme.cpp
+ platform/UserAgentQuirks.cpp
platform/audio/glib/AudioBusGLib.cpp
@@ -76,6 +77,7 @@
platform/glib/MainThreadSharedTimerGLib.cpp
platform/glib/SSLKeyGeneratorGLib.cpp
platform/glib/SharedBufferGlib.cpp
+ platform/glib/UserAgentGLib.cpp
platform/graphics/GLContext.cpp
platform/graphics/GraphicsContext3DPrivate.cpp
Copied: trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp (from rev 220630, trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp) (0 => 220631)
--- trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp (rev 0)
+++ trunk/Source/WebCore/platform/glib/UserAgentGLib.cpp 2017-08-13 12:13:27 UTC (rev 220631)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2012, 2014, 2016 Igalia S.L.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UserAgent.h"
+
+#include "URL.h"
+#include "UserAgentQuirks.h"
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringBuilder.h>
+
+#if OS(UNIX)
+#include <sys/utsname.h>
+#endif
+
+// WARNING! WARNING! WARNING!
+//
+// The user agent is ludicrously fragile. The most innocent change can
+// and will break websites. Read the git log for this file carefully
+// before changing user agent construction. You have been warned.
+
+namespace WebCore {
+
+static const char* platformForUAString()
+{
+#if OS(MAC_OS_X)
+ return "Macintosh";
+#else
+ return "X11";
+#endif
+}
+
+static const String platformVersionForUAString()
+{
+#if OS(UNIX)
+ struct utsname name;
+ uname(&name);
+ static NeverDestroyed<const String> uaOSVersion(String::format("%s %s", name.sysname, name.machine));
+ return uaOSVersion;
+#else
+ // We will always claim to be Safari in Intel Mac OS X, since Safari without
+ // OS X or anything on ARM triggers mobile versions of some websites.
+ //
+ // FIXME: The final result should include OS version, e.g. "Intel Mac OS X 10_8_4".
+ static NeverDestroyed<const String> uaOSVersion(MAKE_STATIC_STRING_IMPL("Intel Mac OS X"));
+ return uaOSVersion;
+#endif
+}
+
+static const char* versionForUAString()
+{
+ return USER_AGENT_GLIB_MAJOR_VERSION "." USER_AGENT_GLIB_MINOR_VERSION;
+}
+
+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());
+ }
+
+ 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(" ");
+ }
+
+ // 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/11.0 Safari/");
+ uaString.append(versionForUAString());
+
+ return uaString.toString();
+}
+
+static const String standardUserAgentStatic()
+{
+ static NeverDestroyed<const String> uaStatic(buildUserAgentString(UserAgentQuirks()));
+ return uaStatic;
+}
+
+String standardUserAgent(const String& applicationName, const String& applicationVersion)
+{
+ // 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. 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.
+ if (applicationName.isEmpty())
+ return standardUserAgentStatic();
+
+ String finalApplicationVersion = applicationVersion;
+ if (finalApplicationVersion.isEmpty())
+ finalApplicationVersion = versionForUAString();
+
+ return standardUserAgentStatic() + ' ' + applicationName + '/' + finalApplicationVersion;
+}
+
+String standardUserAgentForURL(const URL& url)
+{
+ auto quirks = UserAgentQuirks::quirksForURL(url);
+ // The null string means we don't need a specific UA for the given URL.
+ return quirks.isEmpty() ? String() : buildUserAgentString(quirks);
+}
+
+} // namespace WebCore
+
Deleted: trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp (220630 => 220631)
--- trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebCore/platform/gtk/UserAgentGtk.cpp 2017-08-13 12:13:27 UTC (rev 220631)
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2012, 2014, 2016 Igalia S.L.
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "UserAgent.h"
-
-#include "URL.h"
-#include "UserAgentQuirks.h"
-#include <wtf/NeverDestroyed.h>
-#include <wtf/text/StringBuilder.h>
-
-#if OS(UNIX)
-#include <sys/utsname.h>
-#endif
-
-// WARNING! WARNING! WARNING!
-//
-// The user agent is ludicrously fragile. The most innocent change can
-// and will break websites. Read the git log for this file carefully
-// before changing user agent construction. You have been warned.
-
-namespace WebCore {
-
-static const char* platformForUAString()
-{
-#if OS(MAC_OS_X)
- return "Macintosh";
-#else
- return "X11";
-#endif
-}
-
-static const String platformVersionForUAString()
-{
-#if OS(UNIX)
- struct utsname name;
- uname(&name);
- static NeverDestroyed<const String> uaOSVersion(String::format("%s %s", name.sysname, name.machine));
- return uaOSVersion;
-#else
- // We will always claim to be Safari in Intel Mac OS X, since Safari without
- // OS X or anything on ARM triggers mobile versions of some websites.
- //
- // FIXME: The final result should include OS version, e.g. "Intel Mac OS X 10_8_4".
- static NeverDestroyed<const String> uaOSVersion(MAKE_STATIC_STRING_IMPL("Intel Mac OS X"));
- return uaOSVersion;
-#endif
-}
-
-static const char* versionForUAString()
-{
- return USER_AGENT_GTK_MAJOR_VERSION "." USER_AGENT_GTK_MINOR_VERSION;
-}
-
-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());
- }
-
- 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(" ");
- }
-
- // 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/11.0 Safari/");
- uaString.append(versionForUAString());
-
- return uaString.toString();
-}
-
-static const String standardUserAgentStatic()
-{
- static NeverDestroyed<const String> uaStatic(buildUserAgentString(UserAgentQuirks()));
- return uaStatic;
-}
-
-String standardUserAgent(const String& applicationName, const String& applicationVersion)
-{
- // 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. 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.
- if (applicationName.isEmpty())
- return standardUserAgentStatic();
-
- String finalApplicationVersion = applicationVersion;
- if (finalApplicationVersion.isEmpty())
- finalApplicationVersion = versionForUAString();
-
- return standardUserAgentStatic() + ' ' + applicationName + '/' + finalApplicationVersion;
-}
-
-String standardUserAgentForURL(const URL& url)
-{
- auto quirks = UserAgentQuirks::quirksForURL(url);
- // The null string means we don't need a specific UA for the given URL.
- return quirks.isEmpty() ? String() : buildUserAgentString(quirks);
-}
-
-} // namespace WebCore
-
Modified: trunk/Source/WebKit/ChangeLog (220630 => 220631)
--- trunk/Source/WebKit/ChangeLog 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebKit/ChangeLog 2017-08-13 12:13:27 UTC (rev 220631)
@@ -1,3 +1,18 @@
+2017-08-13 Adrian Perez de Castro <[email protected]>
+
+ [WPE] Implement WebCore::standardUserAgent()
+ https://bugs.webkit.org/show_bug.cgi?id=175507
+
+ Reviewed by Carlos Alberto Lopez Perez.
+
+ Implement missing User-Agent handling for the WPE port by sharing the code with the GTK+ port.
+
+ * UIProcess/API/glib/WebKitSettings.cpp: Remove preprocessor conditionals for the WPE port.
+ (webkit_settings_set_user_agent):
+ (webkit_settings_set_user_agent_with_application_details):
+ * UIProcess/wpe/WebPageProxyWPE.cpp:
+ (WebKit::WebPageProxy::standardUserAgent): Remove hardcoded value and make use of WebCore::standardUserAgent().
+
2017-08-11 Ryosuke Niwa <[email protected]>
Replace DATA_TRANSFER_ITEMS by a runtime flag and add a stub implementation
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp (220630 => 220631)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp 2017-08-13 12:13:27 UTC (rev 220631)
@@ -2850,7 +2850,6 @@
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
-#if PLATFORM(GTK)
WebKitSettingsPrivate* priv = settings->priv;
CString newUserAgent = (!userAgent || !strlen(userAgent)) ? WebCore::standardUserAgent("").utf8() : userAgent;
if (newUserAgent == priv->userAgent)
@@ -2858,9 +2857,6 @@
priv->userAgent = newUserAgent;
g_object_notify(G_OBJECT(settings), "user-agent");
-#elif PLATFORM(WPE)
- // FIXME: WPE should implement WebCore::standardUserAgent.
-#endif
}
/**
@@ -2877,12 +2873,8 @@
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
-#if PLATFORM(GTK)
CString newUserAgent = WebCore::standardUserAgent(String::fromUTF8(applicationName), String::fromUTF8(applicationVersion)).utf8();
webkit_settings_set_user_agent(settings, newUserAgent.data());
-#elif PLATFORM(WPE)
- // FIXME: WPE should implement WebCore::standardUserAgent.
-#endif
}
/**
Modified: trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp (220630 => 220631)
--- trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/WebKit/UIProcess/wpe/WebPageProxyWPE.cpp 2017-08-13 12:13:27 UTC (rev 220631)
@@ -29,6 +29,7 @@
#include "PageClientImpl.h"
#include "WebsiteDataStore.h"
#include <WebCore/NotImplemented.h>
+#include <WebCore/UserAgent.h>
namespace WebKit {
@@ -42,9 +43,9 @@
return m_pageClient._javascript_GlobalContext();
}
-String WebPageProxy::standardUserAgent(const String&)
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
{
- return "Mozilla/5.0 (Linux; x86_64 GNU/Linux) AppleWebKit/601.1 (KHTML, like Gecko) Version/8.0 Safari/601.1";
+ return WebCore::standardUserAgent(applicationNameForUserAgent);
}
void WebPageProxy::saveRecentSearches(const String&, const Vector<WebCore::RecentSearch>&)
Modified: trunk/Source/cmake/OptionsGTK.cmake (220630 => 220631)
--- trunk/Source/cmake/OptionsGTK.cmake 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/cmake/OptionsGTK.cmake 2017-08-13 12:13:27 UTC (rev 220631)
@@ -194,8 +194,8 @@
add_definitions(-DBUILDING_GTK__=1)
add_definitions(-DGETTEXT_PACKAGE="WebKit2GTK-${WEBKITGTK_API_VERSION}")
add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
-add_definitions(-DUSER_AGENT_GTK_MAJOR_VERSION="604")
-add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION="1")
+add_definitions(-DUSER_AGENT_GLIB_MAJOR_VERSION="604")
+add_definitions(-DUSER_AGENT_GLIB_MINOR_VERSION="1")
add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
set(GTK_LIBRARIES ${GTK3_LIBRARIES})
Modified: trunk/Source/cmake/OptionsWPE.cmake (220630 => 220631)
--- trunk/Source/cmake/OptionsWPE.cmake 2017-08-13 06:47:49 UTC (rev 220630)
+++ trunk/Source/cmake/OptionsWPE.cmake 2017-08-13 12:13:27 UTC (rev 220631)
@@ -126,6 +126,8 @@
add_definitions(-DBUILDING_WPE__=1)
add_definitions(-DGETTEXT_PACKAGE="WPE")
add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
+add_definitions(-DUSER_AGENT_GLIB_MAJOR_VERSION="601")
+add_definitions(-DUSER_AGENT_GLIB_MINOR_VERSION="1")
set(USE_UDIS86 1)