summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/gtk
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-20 14:01:09 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-20 14:01:09 +0200
commit6dbcd09121fe266c7704a524b5cbd7f2754659c0 (patch)
tree5ae0d16cec0cc61f576d51c57b3a4613c7e91e22 /Source/WebKit2/UIProcess/API/gtk
parent6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (diff)
downloadqtwebkit-6dbcd09121fe266c7704a524b5cbd7f2754659c0.tar.gz
Imported WebKit commit 080af0beaa6f0ba8ff8f44cb8bd8b5dcf75ac0af (http://svn.webkit.org/repository/webkit/trunk@129119)
New snapshot with prospective build fix for incorrect QtWebKit master module header file creation
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp336
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h106
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h28
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp95
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h11
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp21
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h4
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp9
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp119
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h4
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt34
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp72
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp78
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h1
15 files changed, 893 insertions, 26 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp
new file mode 100644
index 000000000..53b46f875
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp
@@ -0,0 +1,336 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitSecurityManager.h"
+
+#include "WebContext.h"
+#include "WebKitSecurityManagerPrivate.h"
+#include "WebKitWebContextPrivate.h"
+#include <WebCore/SchemeRegistry.h>
+
+using namespace WebKit;
+
+typedef enum {
+ SecurityPolicyLocal,
+ SecurityPolicyNoAccess,
+ SecurityPolicyDisplayIsolated,
+ SecurityPolicySecure,
+ SecurityPolicyCORSEnabled,
+ SecurityPolicyEmptyDocument
+} SecurityPolicy;
+
+struct _WebKitSecurityManagerPrivate {
+ WebKitWebContext* webContext;
+};
+
+G_DEFINE_TYPE(WebKitSecurityManager, webkit_security_manager, G_TYPE_OBJECT)
+
+static void webkit_security_manager_init(WebKitSecurityManager* manager)
+{
+ WebKitSecurityManagerPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(manager, WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManagerPrivate);
+ manager->priv = priv;
+ new (priv) WebKitSecurityManagerPrivate();
+}
+
+static void webkitSecurityManagerFinalize(GObject* object)
+{
+ WebKitSecurityManagerPrivate* priv = WEBKIT_SECURITY_MANAGER(object)->priv;
+ priv->~WebKitSecurityManagerPrivate();
+ G_OBJECT_CLASS(webkit_security_manager_parent_class)->finalize(object);
+}
+
+static void webkit_security_manager_class_init(WebKitSecurityManagerClass* klass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
+ gObjectClass->finalize = webkitSecurityManagerFinalize;
+
+ g_type_class_add_private(klass, sizeof(WebKitSecurityManagerPrivate));
+}
+
+WebKitSecurityManager* webkitSecurityManagerCreate(WebKitWebContext* webContext)
+{
+ WebKitSecurityManager* manager = WEBKIT_SECURITY_MANAGER(g_object_new(WEBKIT_TYPE_SECURITY_MANAGER, NULL));
+ manager->priv->webContext = webContext;
+ return manager;
+}
+
+static void registerSecurityPolicyForURIScheme(WebKitSecurityManager* manager, const char* scheme, SecurityPolicy policy)
+{
+ String urlScheme = String::fromUTF8(scheme);
+ WebContext* webContext = toImpl(webkitWebContextGetWKContext(manager->priv->webContext));
+
+ // We keep the WebCore::SchemeRegistry of the UI process in sync with the
+ // web process one, so that we can return the SecurityPolicy for
+ // a given URI scheme synchronously without blocking.
+ switch (policy) {
+ case SecurityPolicyLocal:
+ WebCore::SchemeRegistry::registerURLSchemeAsLocal(urlScheme);
+ webContext->registerURLSchemeAsLocal(urlScheme);
+ break;
+ case SecurityPolicyNoAccess:
+ WebCore::SchemeRegistry::registerURLSchemeAsNoAccess(urlScheme);
+ webContext->registerURLSchemeAsNoAccess(urlScheme);
+ break;
+ case SecurityPolicyDisplayIsolated:
+ WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated(urlScheme);
+ webContext->registerURLSchemeAsDisplayIsolated(urlScheme);
+ break;
+ case SecurityPolicySecure:
+ WebCore::SchemeRegistry::registerURLSchemeAsSecure(urlScheme);
+ webContext->registerURLSchemeAsSecure(urlScheme);
+ break;
+ case SecurityPolicyCORSEnabled:
+ WebCore::SchemeRegistry::registerURLSchemeAsCORSEnabled(urlScheme);
+ webContext->registerURLSchemeAsCORSEnabled(urlScheme);
+ break;
+ case SecurityPolicyEmptyDocument:
+ WebCore::SchemeRegistry::registerURLSchemeAsEmptyDocument(urlScheme);
+ webContext->registerURLSchemeAsEmptyDocument(urlScheme);
+ break;
+ }
+}
+
+static bool checkSecurityPolicyForURIScheme(const char* scheme, SecurityPolicy policy)
+{
+ String urlScheme = String::fromUTF8(scheme);
+
+ switch (policy) {
+ case SecurityPolicyLocal:
+ return WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(urlScheme);
+ case SecurityPolicyNoAccess:
+ return WebCore::SchemeRegistry::shouldTreatURLSchemeAsNoAccess(urlScheme);
+ case SecurityPolicyDisplayIsolated:
+ return WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(urlScheme);
+ case SecurityPolicySecure:
+ return WebCore::SchemeRegistry::shouldTreatURLSchemeAsSecure(urlScheme);
+ case SecurityPolicyCORSEnabled:
+ return WebCore::SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(urlScheme);
+ case SecurityPolicyEmptyDocument:
+ return WebCore::SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(urlScheme);
+ }
+
+ return false;
+}
+
+/**
+ * webkit_security_manager_register_uri_scheme_as_local:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Register @scheme as a local scheme. This means that other non-local pages
+ * cannot link to or access URIs of this scheme.
+ */
+void webkit_security_manager_register_uri_scheme_as_local(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager));
+ g_return_if_fail(scheme);
+
+ registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyLocal);
+}
+
+/**
+ * webkit_security_manager_uri_scheme_is_local:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Whether @scheme is considered as a local scheme.
+ * See also webkit_security_manager_register_uri_scheme_as_local().
+ *
+ * Returns: %TRUE if @scheme is a local scheme or %FALSE otherwise.
+ */
+gboolean webkit_security_manager_uri_scheme_is_local(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE);
+ g_return_val_if_fail(scheme, FALSE);
+
+ return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyLocal);
+}
+
+/**
+ * webkit_security_manager_register_uri_scheme_as_no_access:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Register @scheme as a no-access scheme. This means that pages loaded
+ * with this URI scheme cannot access pages loaded with any other URI scheme.
+ */
+void webkit_security_manager_register_uri_scheme_as_no_access(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager));
+ g_return_if_fail(scheme);
+
+ registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyNoAccess);
+}
+
+/**
+ * webkit_security_manager_uri_scheme_is_no_access:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Whether @scheme is considered as a no-access scheme.
+ * See also webkit_security_manager_register_uri_scheme_as_no_access().
+ *
+ * Returns: %TRUE if @scheme is a no-access scheme or %FALSE otherwise.
+ */
+gboolean webkit_security_manager_uri_scheme_is_no_access(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE);
+ g_return_val_if_fail(scheme, FALSE);
+
+ return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyNoAccess);
+}
+
+/**
+ * webkit_security_manager_register_uri_scheme_as_display_isolated:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Register @scheme as a display isolated scheme. This means that pages cannot
+ * display these URIs unless they are from the same scheme.
+ */
+void webkit_security_manager_register_uri_scheme_as_display_isolated(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager));
+ g_return_if_fail(scheme);
+
+ registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyDisplayIsolated);
+}
+
+/**
+ * webkit_security_manager_uri_scheme_is_display_isolated:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Whether @scheme is considered as a display isolated scheme.
+ * See also webkit_security_manager_register_uri_scheme_as_display_isolated().
+ *
+ * Returns: %TRUE if @scheme is a display isolated scheme or %FALSE otherwise.
+ */
+gboolean webkit_security_manager_uri_scheme_is_display_isolated(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE);
+ g_return_val_if_fail(scheme, FALSE);
+
+ return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyDisplayIsolated);
+}
+
+/**
+ * webkit_security_manager_register_uri_scheme_as_secure:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Register @scheme as a secure scheme. This means that mixed
+ * content warnings won't be generated for this scheme when
+ * included by an HTTPS page.
+ */
+void webkit_security_manager_register_uri_scheme_as_secure(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager));
+ g_return_if_fail(scheme);
+
+ registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicySecure);
+}
+
+/**
+ * webkit_security_manager_uri_scheme_is_secure:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Whether @scheme is considered as a secure scheme.
+ * See also webkit_security_manager_register_uri_scheme_as_secure().
+ *
+ * Returns: %TRUE if @scheme is a secure scheme or %FALSE otherwise.
+ */
+gboolean webkit_security_manager_uri_scheme_is_secure(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE);
+ g_return_val_if_fail(scheme, FALSE);
+
+ return checkSecurityPolicyForURIScheme(scheme, SecurityPolicySecure);
+}
+
+/**
+ * webkit_security_manager_register_uri_scheme_as_cors_enabled:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Register @scheme as a CORS (Cross-origin resource sharing) enabled scheme.
+ * This means that CORS requests are allowed. See W3C CORS specification
+ * http://www.w3.org/TR/cors/.
+ */
+void webkit_security_manager_register_uri_scheme_as_cors_enabled(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager));
+ g_return_if_fail(scheme);
+
+ registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyCORSEnabled);
+}
+
+/**
+ * webkit_security_manager_uri_scheme_is_cors_enabled:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Whether @scheme is considered as a CORS enabled scheme.
+ * See also webkit_security_manager_register_uri_scheme_as_cors_enabled().
+ *
+ * Returns: %TRUE if @scheme is a CORS enabled scheme or %FALSE otherwise.
+ */
+gboolean webkit_security_manager_uri_scheme_is_cors_enabled(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE);
+ g_return_val_if_fail(scheme, FALSE);
+
+ return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyCORSEnabled);
+}
+
+/**
+ * webkit_security_manager_register_uri_scheme_as_empty_document:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Register @scheme as an empty document scheme. This means that
+ * they are allowd to commit synchronously.
+ */
+void webkit_security_manager_register_uri_scheme_as_empty_document(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager));
+ g_return_if_fail(scheme);
+
+ registerSecurityPolicyForURIScheme(manager, scheme, SecurityPolicyEmptyDocument);
+}
+
+/**
+ * webkit_security_manager_uri_scheme_is_empty_document:
+ * @security_manager: a #WebKitSecurityManager
+ * @scheme: a URI scheme
+ *
+ * Whether @scheme is considered as an empty document scheme.
+ * See also webkit_security_manager_register_uri_scheme_as_empty_document().
+ *
+ * Returns: %TRUE if @scheme is a an empty document scheme or %FALSE otherwise.
+ */
+gboolean webkit_security_manager_uri_scheme_is_empty_document(WebKitSecurityManager* manager, const char* scheme)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_MANAGER(manager), FALSE);
+ g_return_val_if_fail(scheme, FALSE);
+
+ return checkSecurityPolicyForURIScheme(scheme, SecurityPolicyEmptyDocument);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h
new file mode 100644
index 000000000..fb8c36eda
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitSecurityManager_h
+#define WebKitSecurityManager_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_SECURITY_MANAGER (webkit_security_manager_get_type())
+#define WEBKIT_SECURITY_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManager))
+#define WEBKIT_IS_SECURITY_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_SECURITY_MANAGER))
+#define WEBKIT_SECURITY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManagerClass))
+#define WEBKIT_IS_SECURITY_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SECURITY_MANAGER))
+#define WEBKIT_SECURITY_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SECURITY_MANAGER, WebKitSecurityManagerClass))
+
+typedef struct _WebKitSecurityManager WebKitSecurityManager;
+typedef struct _WebKitSecurityManagerClass WebKitSecurityManagerClass;
+typedef struct _WebKitSecurityManagerPrivate WebKitSecurityManagerPrivate;
+
+struct _WebKitSecurityManager {
+ GObject parent;
+
+ WebKitSecurityManagerPrivate *priv;
+};
+
+struct _WebKitSecurityManagerClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_security_manager_get_type (void);
+
+WEBKIT_API void
+webkit_security_manager_register_uri_scheme_as_local (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API gboolean
+webkit_security_manager_uri_scheme_is_local (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API void
+webkit_security_manager_register_uri_scheme_as_no_access (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API gboolean
+webkit_security_manager_uri_scheme_is_no_access (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API void
+webkit_security_manager_register_uri_scheme_as_display_isolated (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API gboolean
+webkit_security_manager_uri_scheme_is_display_isolated (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API void
+webkit_security_manager_register_uri_scheme_as_secure (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API gboolean
+webkit_security_manager_uri_scheme_is_secure (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API void
+webkit_security_manager_register_uri_scheme_as_cors_enabled (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API gboolean
+webkit_security_manager_uri_scheme_is_cors_enabled (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API void
+webkit_security_manager_register_uri_scheme_as_empty_document (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+WEBKIT_API gboolean
+webkit_security_manager_uri_scheme_is_empty_document (WebKitSecurityManager *security_manager,
+ const gchar *scheme);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h
new file mode 100644
index 000000000..feabdced6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManagerPrivate.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitSecurityManagerPrivate_h
+#define WebKitSecurityManagerPrivate_h
+
+#include "WebKitSecurityManager.h"
+#include "WebKitWebContext.h"
+
+WebKitSecurityManager* webkitSecurityManagerCreate(WebKitWebContext*);
+
+#endif // WebKitSecurityManagerPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
index 5e0be7d32..c0a64162a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
@@ -34,6 +34,7 @@
#include "WebKitPrivate.h"
#include "WebKitSettingsPrivate.h"
#include "WebPageProxy.h"
+#include <WebCore/UserAgentGtk.h>
#include <glib/gi18n-lib.h>
#include <wtf/text/CString.h>
@@ -47,6 +48,7 @@ struct _WebKitSettingsPrivate {
CString fantasyFontFamily;
CString pictographFontFamily;
CString defaultCharset;
+ CString userAgent;
bool allowModalDialogs;
bool zoomTextOnly;
};
@@ -114,7 +116,8 @@ enum {
PROP_MEDIA_PLAYBACK_ALLOWS_INLINE,
PROP_DRAW_COMPOSITING_INDICATORS,
PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
- PROP_ENABLE_PAGE_CACHE
+ PROP_ENABLE_PAGE_CACHE,
+ PROP_USER_AGENT
};
static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
@@ -245,6 +248,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
case PROP_ENABLE_PAGE_CACHE:
webkit_settings_set_enable_page_cache(settings, g_value_get_boolean(value));
break;
+ case PROP_USER_AGENT:
+ webkit_settings_set_user_agent(settings, g_value_get_string(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
break;
@@ -379,6 +385,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val
case PROP_ENABLE_PAGE_CACHE:
g_value_set_boolean(value, webkit_settings_get_enable_page_cache(settings));
break;
+ case PROP_USER_AGENT:
+ g_value_set_string(value, webkit_settings_get_user_agent(settings));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
break;
@@ -1010,6 +1019,26 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
TRUE,
readWriteConstructParamFlags));
+ /**
+ * WebKitSettings:user-agent:
+ *
+ * The user-agent string used by WebKit. Unusual user-agent strings may cause web
+ * content to render incorrectly or fail to run, as many web pages are written to
+ * parse the user-agent strings of only the most popular browsers. Therefore, it's
+ * typically better to not completely override the standard user-agent, but to use
+ * webkit_settings_set_user_agent_with_application_details() instead.
+ *
+ * If this property is set to the empty string or %NULL, it will revert to the standard
+ * user-agent.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_USER_AGENT,
+ g_param_spec_string("user-agent",
+ _("User agent string"),
+ _("The user agent string"),
+ 0, // A null string forces the standard user agent.
+ readWriteConstructParamFlags));
+
g_type_class_add_private(klass, sizeof(WebKitSettingsPrivate));
}
@@ -1048,8 +1077,13 @@ static void webkit_settings_init(WebKitSettings* settings)
void webkitSettingsAttachSettingsToPage(WebKitSettings* settings, WKPageRef wkPage)
{
- WKPageGroupSetPreferences(WKPageGetPageGroup(wkPage), settings->priv->preferences.get());
- WebKit::toImpl(wkPage)->setCanRunModal(settings->priv->allowModalDialogs);
+ WebKitSettingsPrivate* priv = settings->priv;
+ WKPageGroupSetPreferences(WKPageGetPageGroup(wkPage), priv->preferences.get());
+ WebKit::toImpl(wkPage)->setCanRunModal(priv->allowModalDialogs);
+
+ ASSERT(!priv->userAgent.isNull());
+ WKRetainPtr<WKStringRef> userAgent = adoptWK(WKStringCreateWithUTF8CString(priv->userAgent.data()));
+ WKPageSetCustomUserAgent(wkPage, userAgent.get());
}
/**
@@ -2555,3 +2589,58 @@ void webkit_settings_set_enable_page_cache(WebKitSettings* settings, gboolean en
WKPreferencesSetPageCacheEnabled(priv->preferences.get(), enabled);
g_object_notify(G_OBJECT(settings), "enable-page-cache");
}
+
+/**
+ * webkit_settings_get_user_agent:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:user-agent property.
+ *
+ * Returns: The current value of the user-agent property.
+ */
+const char* webkit_settings_get_user_agent(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ ASSERT(!priv->userAgent.isNull());
+ return priv->userAgent.data();
+}
+
+/**
+ * webkit_settings_set_user_agent:
+ * @settings: a #WebKitSettings
+ * @user_agent: (allow-none): The new custom user agent string or %NULL to use the default user agent
+ *
+ * Set the #WebKitSettings:user-agent property.
+ */
+void webkit_settings_set_user_agent(WebKitSettings* settings, const char* userAgent)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ CString newUserAgent = (!userAgent || !strlen(userAgent)) ? WebCore::standardUserAgent("").utf8() : userAgent;
+ if (newUserAgent == priv->userAgent)
+ return;
+
+ priv->userAgent = newUserAgent;
+ g_object_notify(G_OBJECT(settings), "user-agent");
+}
+
+/**
+ * webkit_settings_set_user_agent_with_application_details:
+ * @settings: a #WebKitSettings
+ * @application_name: (allow-none): The application name used for the user agent or %NULL to use the default user agent.
+ * @application_version: (allow-none): The application version for the user agent or %NULL to user the default version.
+ *
+ * Set the #WebKitSettings:user-agent property by appending the application details to the default user
+ * agent. If no application name or version is given, the default user agent used will be used. If only
+ * the version is given, the default engine version is used with the given application name.
+ */
+void webkit_settings_set_user_agent_with_application_details(WebKitSettings* settings, const char* applicationName, const char* applicationVersion)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ CString newUserAgent = WebCore::standardUserAgent(String::fromUTF8(applicationName), String::fromUTF8(applicationVersion)).utf8();
+ webkit_settings_set_user_agent(settings, newUserAgent.data());
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
index 0c719cd47..b35a23f06 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
@@ -362,6 +362,17 @@ WEBKIT_API void
webkit_settings_set_enable_page_cache (WebKitSettings *settings,
gboolean enabled);
+WEBKIT_API const gchar *
+webkit_settings_get_user_agent (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_user_agent (WebKitSettings *settings,
+ const gchar *user_agent);
+WEBKIT_API void
+webkit_settings_set_user_agent_with_application_details (WebKitSettings *settings,
+ const gchar *application_name,
+ const gchar *application_version);
+
G_END_DECLS
#endif /* WebKitSettings_h */
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
index e9231e47b..5b2c26697 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
@@ -28,6 +28,7 @@
#include "WebKitPluginPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitRequestManagerClient.h"
+#include "WebKitSecurityManagerPrivate.h"
#include "WebKitTextChecker.h"
#include "WebKitURISchemeRequestPrivate.h"
#include "WebKitWebContextPrivate.h"
@@ -95,6 +96,7 @@ struct _WebKitWebContextPrivate {
WKRetainPtr<WKContextRef> context;
GRefPtr<WebKitCookieManager> cookieManager;
+ GRefPtr<WebKitSecurityManager> securityManager;
WKRetainPtr<WKSoupRequestManagerRef> requestManager;
URISchemeHandlerMap uriSchemeHandlers;
URISchemeRequestMap uriSchemeRequests;
@@ -322,6 +324,25 @@ WebKitCookieManager* webkit_web_context_get_cookie_manager(WebKitWebContext* con
}
/**
+ * webkit_web_context_get_security_manager:
+ * @context: a #WebKitWebContext
+ *
+ * Get the #WebKitSecurityManager of @context.
+ *
+ * Returns: (transfer none): the #WebKitSecurityManager of @context.
+ */
+WebKitSecurityManager* webkit_web_context_get_security_manager(WebKitWebContext* context)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
+
+ WebKitWebContextPrivate* priv = context->priv;
+ if (!priv->securityManager)
+ priv->securityManager = adoptGRef(webkitSecurityManagerCreate(context));
+
+ return priv->securityManager.get();
+}
+
+/**
* webkit_web_context_set_additional_plugins_directory:
* @context: a #WebKitWebContext
* @directory: the directory to add
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
index a2bf573f5..f77086f4d 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
@@ -28,6 +28,7 @@
#include <webkit2/WebKitCookieManager.h>
#include <webkit2/WebKitDefines.h>
#include <webkit2/WebKitDownload.h>
+#include <webkit2/WebKitSecurityManager.h>
#include <webkit2/WebKitURISchemeRequest.h>
G_BEGIN_DECLS
@@ -113,6 +114,9 @@ webkit_web_context_download_uri (WebKitWebContext
WEBKIT_API WebKitCookieManager *
webkit_web_context_get_cookie_manager (WebKitWebContext *context);
+WEBKIT_API WebKitSecurityManager *
+webkit_web_context_get_security_manager (WebKitWebContext *context);
+
WEBKIT_API void
webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context,
const gchar *directory);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index e35f603ff..1e6aa7fac 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -248,12 +248,19 @@ static void zoomTextOnlyChanged(WebKitSettings* settings, GParamSpec*, WebKitWeb
WKPageSetPageAndTextZoomFactors(wkPage, pageZoomLevel, textZoomLevel);
}
+static void userAgentChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
+{
+ WKRetainPtr<WKStringRef> userAgent = adoptWK(WKStringCreateWithUTF8CString(webkit_settings_get_user_agent(settings)));
+ WKPageSetCustomUserAgent(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))), userAgent.get());
+}
+
static void webkitWebViewSetSettings(WebKitWebView* webView, WebKitSettings* settings, WKPageRef wkPage)
{
webView->priv->settings = settings;
webkitSettingsAttachSettingsToPage(webView->priv->settings.get(), wkPage);
g_signal_connect(settings, "notify::allow-modal-dialogs", G_CALLBACK(allowModalDialogsChanged), webView);
g_signal_connect(settings, "notify::zoom-text-only", G_CALLBACK(zoomTextOnlyChanged), webView);
+ g_signal_connect(settings, "notify::user-agent", G_CALLBACK(userAgentChanged), webView);
}
static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView)
@@ -261,7 +268,7 @@ static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView
WebKitSettings* settings = webView->priv->settings.get();
g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(allowModalDialogsChanged), webView);
g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(zoomTextOnlyChanged), webView);
-
+ g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(userAgentChanged), webView);
}
static void webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(WebKitWebView* webView)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
index 0482b347e..23b02f649 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -67,7 +67,7 @@
#endif
#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
-#include <gdk/gdkx.h>
+#include <WebCore/RedirectedXCompositeWindow.h>
#endif
using namespace WebKit;
@@ -90,14 +90,20 @@ struct _WebKitWebViewBasePrivate {
IntSize resizerSize;
GRefPtr<AtkObject> accessible;
bool needsResizeOnMap;
-#if ENABLE(FULLSCREEN_API)
- bool fullScreenModeActive;
- WebFullScreenClientGtk fullScreenClient;
-#endif
GtkWidget* inspectorView;
unsigned inspectorViewHeight;
GOwnPtr<GdkEvent> contextMenuEvent;
WebContextMenuProxyGtk* activeContextMenuProxy;
+
+#if ENABLE(FULLSCREEN_API)
+ bool fullScreenModeActive;
+ WebFullScreenClientGtk fullScreenClient;
+#endif
+
+#if USE(TEXTURE_MAPPER_GL)
+ OwnPtr<RedirectedXCompositeWindow> redirectedWindow;
+ bool readyToRenderAcceleratedCompositingResults;
+#endif
};
G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
@@ -162,9 +168,6 @@ static void webkitWebViewBaseRealize(GtkWidget* widget)
gint attributesMask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributesMask);
-#if USE(TEXTURE_MAPPER_GL)
- gdk_window_ensure_native(window);
-#endif
gtk_widget_set_window(widget, window);
gdk_window_set_user_data(window, widget);
@@ -264,7 +267,6 @@ static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase)
priv->shouldForwardNextKeyEvent = FALSE;
GtkWidget* viewWidget = GTK_WIDGET(webkitWebViewBase);
- gtk_widget_set_double_buffered(viewWidget, FALSE);
gtk_widget_set_can_focus(viewWidget, TRUE);
priv->imContext = adoptGRef(gtk_im_multicontext_new());
@@ -275,11 +277,38 @@ static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase)
gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), 0, 0,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::defaultPasteboardHelper()->targetList());
+
+#if USE(TEXTURE_MAPPER_GL)
+ priv->redirectedWindow = RedirectedXCompositeWindow::create(IntSize(1, 1));
+ priv->readyToRenderAcceleratedCompositingResults = false;
+#endif
+}
+
+#if USE(TEXTURE_MAPPER_GL)
+static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect)
+{
+ if (!drawingArea->isInAcceleratedCompositingMode())
+ return false;
+
+ // To avoid flashes when initializing accelerated compositing for the first
+ // time, we wait until we know there's a frame ready before rendering.
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+ if (!priv->readyToRenderAcceleratedCompositingResults)
+ return false;
+
+ ASSERT(priv->redirectedWindow);
+ cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+ cairo_surface_t* surface = priv->redirectedWindow->cairoSurfaceForWidget(GTK_WIDGET(webViewBase));
+ cairo_set_source_surface(cr, surface, 0, 0);
+ cairo_fill(cr);
+ return true;
}
+#endif
static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
{
- DrawingAreaProxy* drawingArea = WEBKIT_WEB_VIEW_BASE(widget)->priv->pageProxy->drawingArea();
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webViewBase->priv->pageProxy->drawingArea());
if (!drawingArea)
return FALSE;
@@ -287,8 +316,13 @@ static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
return FALSE;
+#if USE(TEXTURE_MAPPER_GL)
+ if (webkitWebViewRenderAcceleratedCompositingResults(webViewBase, drawingArea, cr, &clipRect))
+ return FALSE;
+#endif
+
WebCore::Region unpaintedRegion; // This is simply unused.
- static_cast<DrawingAreaProxyImpl*>(drawingArea)->paint(cr, clipRect, unpaintedRegion);
+ drawingArea->paint(cr, clipRect, unpaintedRegion);
return FALSE;
}
@@ -309,7 +343,7 @@ static void webkitWebViewBaseChildAllocate(GtkWidget* child, gpointer userData)
priv->children.set(child, IntRect());
}
-static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation)
+static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation, bool sizeChanged)
{
gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase);
@@ -324,6 +358,11 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase
viewRect.setHeight(allocation->height - priv->inspectorViewHeight);
}
+#if USE(TEXTURE_MAPPER_GL)
+ if (sizeChanged)
+ webViewBase->priv->redirectedWindow->resize(viewRect.size());
+#endif
+
if (priv->pageProxy->drawingArea())
priv->pageProxy->drawingArea()->setSize(viewRect.size(), IntSize());
@@ -334,14 +373,18 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase
static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
{
+ bool sizeChanged = gtk_widget_get_allocated_width(widget) != allocation->width
+ || gtk_widget_get_allocated_height(widget) != allocation->height;
+
GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation);
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
- if (!gtk_widget_get_mapped(GTK_WIDGET(webViewBase)) && !webViewBase->priv->pageProxy->drawingArea()->size().isEmpty()) {
+ if (sizeChanged && !gtk_widget_get_mapped(widget) && !webViewBase->priv->pageProxy->drawingArea()->size().isEmpty()) {
webViewBase->priv->needsResizeOnMap = true;
return;
}
- resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation);
+
+ resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation, sizeChanged);
}
static void webkitWebViewBaseMap(GtkWidget* widget)
@@ -349,19 +392,12 @@ static void webkitWebViewBaseMap(GtkWidget* widget)
GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget);
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
-#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
- GdkWindow* gdkWindow = gtk_widget_get_window(widget);
- ASSERT(gdkWindow);
- if (gdk_window_has_native(gdkWindow))
- webViewBase->priv->pageProxy->widgetMapped(GDK_WINDOW_XID(gdkWindow));
-#endif
-
if (!webViewBase->priv->needsResizeOnMap)
return;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
- resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation);
+ resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation, true /* sizeChanged */);
webViewBase->priv->needsResizeOnMap = false;
}
@@ -680,6 +716,10 @@ void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WKCont
#if ENABLE(FULLSCREEN_API)
priv->pageProxy->fullScreenManager()->setWebView(webkitWebViewBase);
#endif
+
+#if USE(TEXTURE_MAPPER_GL)
+ priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId());
+#endif
}
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip)
@@ -803,3 +843,38 @@ GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase* webkitWebView
{
return webkitWebViewBase->priv->contextMenuEvent.release();
}
+
+#if USE(TEXTURE_MAPPER_GL)
+static gboolean queueAnotherDrawOfAcceleratedCompositingResults(gpointer* webViewBasePointer)
+{
+ // The WebViewBase may have been destroyed in the time since we queued this
+ // draw and the time we are actually executing.
+ if (!*webViewBasePointer) {
+ fastFree(webViewBasePointer);
+ return FALSE;
+ }
+
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(*webViewBasePointer);
+ gtk_widget_queue_draw(GTK_WIDGET(webViewBase));
+ webViewBase->priv->readyToRenderAcceleratedCompositingResults = true;
+
+ g_object_remove_weak_pointer(G_OBJECT(webViewBase), webViewBasePointer);
+ fastFree(webViewBasePointer);
+
+ return FALSE;
+}
+
+void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase* webViewBase)
+{
+ gtk_widget_queue_draw(GTK_WIDGET(webViewBase));
+
+ // Redraw again, one frame later, as it might take some time for the new GL frame to be available.
+ // This prevents the display from always being one frame behind in the case GL hasn't yet finished
+ // rendering to the window.
+ // TODO: Add XDamage support to RedirectedXCompositeWindow to accomplish this.
+ gpointer* webViewBasePointer = static_cast<gpointer*>(fastMalloc(sizeof(gpointer)));
+ g_object_add_weak_pointer(G_OBJECT(webViewBase), webViewBasePointer);
+ *webViewBasePointer = webViewBase;
+ g_timeout_add(1000 / 60, reinterpret_cast<GSourceFunc>(queueAnotherDrawOfAcceleratedCompositingResults), webViewBasePointer);
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
index 1295f3d53..031e5d59b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
@@ -52,4 +52,8 @@ void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebContextMe
WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*);
GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase*);
+#if USE(TEXTURE_MAPPER_GL)
+void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase*);
+#endif
+
#endif // WebKitWebViewBasePrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
index 6aac7c843..a7f34e6d1 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -40,6 +40,7 @@
<xi:include href="xml/WebKitContextMenu.xml"/>
<xi:include href="xml/WebKitContextMenuItem.xml"/>
<xi:include href="xml/WebKitFormSubmissionRequest.xml"/>
+ <xi:include href="xml/WebKitSecurityManager.xml"/>
</chapter>
<index id="index-all">
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
index 596498c83..73defe419 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -30,6 +30,7 @@ webkit_web_context_set_cache_model
webkit_web_context_clear_cache
webkit_web_context_download_uri
webkit_web_context_get_cookie_manager
+webkit_web_context_get_security_manager
webkit_web_context_set_additional_plugins_directory
webkit_web_context_get_plugins
webkit_web_context_get_plugins_finish
@@ -283,6 +284,9 @@ webkit_settings_get_enable_site_specific_quirks
webkit_settings_set_enable_site_specific_quirks
webkit_settings_get_enable_page_cache
webkit_settings_set_enable_page_cache
+webkit_settings_get_user_agent
+webkit_settings_set_user_agent
+webkit_settings_set_user_agent_with_application_details
<SUBSECTION Standard>
WebKitSettingsClass
@@ -845,3 +849,33 @@ WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS
WebKitFormSubmissionRequestPrivate
webkit_form_submission_request_get_type
</SECTION>
+
+<SECTION>
+<FILE>WebKitSecurityManager</FILE>
+WebKitSecurityManager
+webkit_security_manager_register_uri_scheme_as_local
+webkit_security_manager_uri_scheme_is_local
+webkit_security_manager_register_uri_scheme_as_no_access
+webkit_security_manager_uri_scheme_is_no_access
+webkit_security_manager_register_uri_scheme_as_display_isolated
+webkit_security_manager_uri_scheme_is_display_isolated
+webkit_security_manager_register_uri_scheme_as_secure
+webkit_security_manager_uri_scheme_is_secure
+webkit_security_manager_register_uri_scheme_as_cors_enabled
+webkit_security_manager_uri_scheme_is_cors_enabled
+webkit_security_manager_register_uri_scheme_as_empty_document
+webkit_security_manager_uri_scheme_is_empty_document
+
+<SUBSECTION Standard>
+WebKitSecurityManagerClass
+WEBKIT_TYPE_SECURITY_MANAGER
+WEBKIT_SECURITY_MANAGER
+WEBKIT_IS_SECURITY_MANAGER
+WEBKIT_SECURITY_MANAGER_CLASS
+WEBKIT_IS_SECURITY_MANAGER_CLASS
+WEBKIT_SECURITY_MANAGER_GET_CLASS
+
+<SUBSECTION Private>
+WebKitSecurityManagerPrivate
+webkit_security_manager_get_type
+</SECTION>
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
index 5e6e91b09..d8e355472 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
@@ -31,10 +31,14 @@
#include "config.h"
#include "TestMain.h"
+#include "WebViewTest.h"
+#include "WebKitTestServer.h"
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include <wtf/gobject/GRefPtr.h>
+static WebKitTestServer* gServer;
+
static void testWebKitSettings(Test*, gconstpointer)
{
WebKitSettings* settings = webkit_settings_new();
@@ -254,13 +258,81 @@ void testWebKitSettingsNewWithSettings(Test* test, gconstpointer)
g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings.get()));
}
+static CString convertWebViewMainResourceDataToCString(WebViewTest* test)
+{
+ size_t mainResourceDataSize = 0;
+ const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+ return CString(mainResourceData, mainResourceDataSize);
+}
+
+static void assertThatUserAgentIsSentInHeaders(WebViewTest* test, const CString& userAgent)
+{
+ test->loadURI(gServer->getURIForPath("/").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpstr(convertWebViewMainResourceDataToCString(test).data(), ==, userAgent.data());
+}
+
+static void testWebKitSettingsUserAgent(WebViewTest* test, gconstpointer)
+{
+ GRefPtr<WebKitSettings> settings = adoptGRef(webkit_settings_new());
+ CString defaultUserAgent = webkit_settings_get_user_agent(settings.get());
+ webkit_web_view_set_settings(test->m_webView, settings.get());
+
+ g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Safari"));
+ g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Chromium"));
+ g_assert(g_strstr_len(defaultUserAgent.data(), -1, "Chrome"));
+
+ webkit_settings_set_user_agent(settings.get(), 0);
+ g_assert_cmpstr(defaultUserAgent.data(), ==, webkit_settings_get_user_agent(settings.get()));
+ assertThatUserAgentIsSentInHeaders(test, defaultUserAgent.data());
+
+ webkit_settings_set_user_agent(settings.get(), "");
+ g_assert_cmpstr(defaultUserAgent.data(), ==, webkit_settings_get_user_agent(settings.get()));
+
+ const char* funkyUserAgent = "Funky!";
+ webkit_settings_set_user_agent(settings.get(), funkyUserAgent);
+ g_assert_cmpstr(funkyUserAgent, ==, webkit_settings_get_user_agent(settings.get()));
+ assertThatUserAgentIsSentInHeaders(test, funkyUserAgent);
+
+ webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", 0);
+ CString userAgentWithNullVersion = webkit_settings_get_user_agent(settings.get());
+ g_assert_cmpstr(g_strstr_len(userAgentWithNullVersion.data(), -1, defaultUserAgent.data()), ==, userAgentWithNullVersion.data());
+ g_assert(g_strstr_len(userAgentWithNullVersion.data(), -1, "WebKitGTK+"));
+
+ webkit_settings_set_user_agent_with_application_details(settings.get(), "WebKitGTK+", "");
+ g_assert_cmpstr(webkit_settings_get_user_agent(settings.get()), ==, userAgentWithNullVersion.data());
+
+ webkit_settings_set_user_agent_with_application_details(settings.get(), "WebCatGTK+", "3.4.5");
+ const char* newUserAgent = webkit_settings_get_user_agent(settings.get());
+ g_assert(g_strstr_len(newUserAgent, -1, "3.4.5"));
+ g_assert(g_strstr_len(newUserAgent, -1, "WebCatGTK+"));
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ const char* userAgent = soup_message_headers_get_one(message->request_headers, "User-Agent");
+ soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, userAgent, strlen(userAgent));
+ soup_message_body_complete(message->response_body);
+}
+
void beforeAll()
{
+ gServer = new WebKitTestServer();
+ gServer->run(serverCallback);
+
Test::add("WebKitSettings", "webkit-settings", testWebKitSettings);
Test::add("WebKitSettings", "new-with-settings", testWebKitSettingsNewWithSettings);
+ WebViewTest::add("WebKitSettings", "user-agent", testWebKitSettingsUserAgent);
}
void afterAll()
{
+ delete gServer;
}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
index 7c712244e..7a13d285d 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
@@ -297,6 +297,83 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char*
soup_message_body_complete(message->response_body);
}
+class SecurityPolicyTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(SecurityPolicyTest);
+
+ enum SecurityPolicy {
+ Local = 1 << 1,
+ NoAccess = 1 << 2,
+ DisplayIsolated = 1 << 3,
+ Secure = 1 << 4,
+ CORSEnabled = 1 << 5,
+ EmptyDocument = 1 << 6
+ };
+
+ SecurityPolicyTest()
+ : m_manager(webkit_web_context_get_security_manager(webkit_web_context_get_default()))
+ {
+ }
+
+ void verifyThatSchemeMatchesPolicy(const char* scheme, unsigned policy)
+ {
+ if (policy & Local)
+ g_assert(webkit_security_manager_uri_scheme_is_local(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_local(m_manager, scheme));
+ if (policy & NoAccess)
+ g_assert(webkit_security_manager_uri_scheme_is_no_access(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_no_access(m_manager, scheme));
+ if (policy & DisplayIsolated)
+ g_assert(webkit_security_manager_uri_scheme_is_display_isolated(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_display_isolated(m_manager, scheme));
+ if (policy & Secure)
+ g_assert(webkit_security_manager_uri_scheme_is_secure(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_secure(m_manager, scheme));
+ if (policy & CORSEnabled)
+ g_assert(webkit_security_manager_uri_scheme_is_cors_enabled(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_cors_enabled(m_manager, scheme));
+ if (policy & EmptyDocument)
+ g_assert(webkit_security_manager_uri_scheme_is_empty_document(m_manager, scheme));
+ else
+ g_assert(!webkit_security_manager_uri_scheme_is_empty_document(m_manager, scheme));
+ }
+
+ WebKitSecurityManager* m_manager;
+};
+
+static void testWebContextSecurityPolicy(SecurityPolicyTest* test, gconstpointer)
+{
+ // VerifyThatSchemeMatchesPolicy default policy for well known schemes.
+ test->verifyThatSchemeMatchesPolicy("http", SecurityPolicyTest::CORSEnabled);
+ test->verifyThatSchemeMatchesPolicy("https", SecurityPolicyTest::CORSEnabled | SecurityPolicyTest::Secure);
+ test->verifyThatSchemeMatchesPolicy("file", SecurityPolicyTest::Local);
+ test->verifyThatSchemeMatchesPolicy("data", SecurityPolicyTest::NoAccess | SecurityPolicyTest::Secure);
+ test->verifyThatSchemeMatchesPolicy("about", SecurityPolicyTest::NoAccess | SecurityPolicyTest::Secure | SecurityPolicyTest::EmptyDocument);
+
+ // Custom scheme.
+ test->verifyThatSchemeMatchesPolicy("foo", 0);
+
+ webkit_security_manager_register_uri_scheme_as_local(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local);
+ webkit_security_manager_register_uri_scheme_as_no_access(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess);
+ webkit_security_manager_register_uri_scheme_as_display_isolated(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated);
+ webkit_security_manager_register_uri_scheme_as_secure(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure);
+ webkit_security_manager_register_uri_scheme_as_cors_enabled(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure
+ | SecurityPolicyTest::CORSEnabled);
+ webkit_security_manager_register_uri_scheme_as_empty_document(test->m_manager, "foo");
+ test->verifyThatSchemeMatchesPolicy("foo", SecurityPolicyTest::Local | SecurityPolicyTest::NoAccess | SecurityPolicyTest::DisplayIsolated | SecurityPolicyTest::Secure
+ | SecurityPolicyTest::CORSEnabled | SecurityPolicyTest::EmptyDocument);
+}
+
void beforeAll()
{
kServer = new WebKitTestServer();
@@ -307,6 +384,7 @@ void beforeAll()
URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme);
Test::add("WebKitWebContext", "spell-checker", testWebContextSpellChecker);
WebViewTest::add("WebKitWebContext", "languages", testWebContextLanguages);
+ SecurityPolicyTest::add("WebKitSecurityManager", "security-policy", testWebContextSecurityPolicy);
}
void afterAll()
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index 116dafc2d..e1f3ba04a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -47,6 +47,7 @@
#include <webkit2/WebKitPrintOperation.h>
#include <webkit2/WebKitResponsePolicyDecision.h>
#include <webkit2/WebKitScriptDialog.h>
+#include <webkit2/WebKitSecurityManager.h>
#include <webkit2/WebKitSettings.h>
#include <webkit2/WebKitURIRequest.h>
#include <webkit2/WebKitURIResponse.h>