summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp47
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h27
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp16
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h21
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp110
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h59
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h28
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp92
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h52
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp20
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h7
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h5
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp51
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h27
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp9
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp195
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h73
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h32
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp75
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in84
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp114
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h48
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h11
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp25
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h3
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml3
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt59
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am7
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp50
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp128
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp69
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h3
37 files changed, 1574 insertions, 33 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp
new file mode 100644
index 000000000..f9d713180
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitContextMenuClient.h"
+
+#include "WebKitPrivate.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebKitWebViewPrivate.h"
+
+using namespace WebKit;
+
+static void getContextMenuFromProposedMenu(WKPageRef, WKArrayRef proposedMenu, WKArrayRef*, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo)
+{
+ webkitWebViewPopulateContextMenu(WEBKIT_WEB_VIEW(clientInfo), proposedMenu, hitTestResult);
+}
+
+void attachContextMenuClientToView(WebKitWebView* webView)
+{
+ WKPageContextMenuClient wkContextMenuClient = {
+ kWKPageContextMenuClientCurrentVersion,
+ webView, // clientInfo
+ 0, // getContextMenuFromProposedMenu_deprecatedForUseWithV0
+ 0, // customContextMenuItemSelected
+ 0, // contextMenuDismissed
+ getContextMenuFromProposedMenu,
+ };
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ WKPageSetPageContextMenuClient(wkPage, &wkContextMenuClient);
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h
new file mode 100644
index 000000000..9b28bf998
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.h
@@ -0,0 +1,27 @@
+/*
+ * 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 WebKitContextMenuClient_h
+#define WebKitContextMenuClient_h
+
+#include "WebKitWebView.h"
+
+void attachContextMenuClientToView(WebKitWebView*);
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp
index 61d316f6c..e0d7a60ea 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp
@@ -512,3 +512,19 @@ gdouble webkit_download_get_elapsed_time(WebKitDownload* download)
return g_timer_elapsed(priv->timer.get(), 0);
}
+
+/**
+ * webkit_download_get_received_data_length:
+ * @download: a #WebKitDownload
+ *
+ * Gets the length of the data already downloaded for @download
+ * in bytes.
+ *
+ * Returns: the amount of bytes already downloaded.
+ */
+guint64 webkit_download_get_received_data_length(WebKitDownload* download)
+{
+ g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0);
+
+ return download->priv->currentSize;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h
index b4a2d3bab..a02aa57fd 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h
@@ -56,29 +56,32 @@ struct _WebKitDownloadClass {
};
WEBKIT_API GType
-webkit_download_get_type (void);
+webkit_download_get_type (void);
WEBKIT_API WebKitURIRequest *
-webkit_download_get_request (WebKitDownload *download);
+webkit_download_get_request (WebKitDownload *download);
WEBKIT_API const gchar *
-webkit_download_get_destination (WebKitDownload *download);
+webkit_download_get_destination (WebKitDownload *download);
WEBKIT_API void
-webkit_download_set_destination (WebKitDownload *download,
- const gchar *uri);
+webkit_download_set_destination (WebKitDownload *download,
+ const gchar *uri);
WEBKIT_API WebKitURIResponse*
-webkit_download_get_response (WebKitDownload *download);
+webkit_download_get_response (WebKitDownload *download);
WEBKIT_API void
-webkit_download_cancel (WebKitDownload *download);
+webkit_download_cancel (WebKitDownload *download);
WEBKIT_API gdouble
-webkit_download_get_estimated_progress (WebKitDownload *download);
+webkit_download_get_estimated_progress (WebKitDownload *download);
WEBKIT_API gdouble
-webkit_download_get_elapsed_time (WebKitDownload *download);
+webkit_download_get_elapsed_time (WebKitDownload *download);
+
+WEBKIT_API guint64
+webkit_download_get_received_data_length (WebKitDownload* download);
G_END_DECLS
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp
new file mode 100644
index 000000000..51f186842
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitGeolocationPermissionRequest.h"
+
+#include "WebKitGeolocationPermissionRequestPrivate.h"
+#include "WebKitPermissionRequest.h"
+
+/**
+ * SECTION: WebKitGeolocationPermissionRequest
+ * @Short_description: A permission request for sharing user's location
+ * @Title: WebKitGeolocationPermissionRequest
+ * @See_also: #WebKitPermissionRequest, #WebKitWebView
+ *
+ * WebKitGeolocationPermissionRequest represents a request for
+ * permission to decide whether WebKit should provide the user's
+ * location to a website when requested throught the Geolocation API.
+ */
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
+G_DEFINE_TYPE_WITH_CODE(WebKitGeolocationPermissionRequest, webkit_geolocation_permission_request, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST,
+ webkit_permission_request_interface_init))
+
+struct _WebKitGeolocationPermissionRequestPrivate {
+ WKRetainPtr<WKGeolocationPermissionRequestRef> wkRequest;
+ bool madeDecision;
+};
+
+static void webkitGeolocationPermissionRequestAllow(WebKitPermissionRequest* request)
+{
+ ASSERT(WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(request));
+
+ WebKitGeolocationPermissionRequestPrivate* priv = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(request)->priv;
+
+ // Only one decision at a time.
+ if (priv->madeDecision)
+ return;
+
+ WKGeolocationPermissionRequestAllow(priv->wkRequest.get());
+ priv->madeDecision = true;
+}
+
+static void webkitGeolocationPermissionRequestDeny(WebKitPermissionRequest* request)
+{
+ ASSERT(WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(request));
+
+ WebKitGeolocationPermissionRequestPrivate* priv = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(request)->priv;
+
+ // Only one decision at a time.
+ if (priv->madeDecision)
+ return;
+
+ WKGeolocationPermissionRequestDeny(priv->wkRequest.get());
+ priv->madeDecision = true;
+}
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface)
+{
+ iface->allow = webkitGeolocationPermissionRequestAllow;
+ iface->deny = webkitGeolocationPermissionRequestDeny;
+}
+
+static void webkit_geolocation_permission_request_init(WebKitGeolocationPermissionRequest* request)
+{
+ request->priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequestPrivate);
+ new (request->priv) WebKitGeolocationPermissionRequestPrivate();
+}
+
+static void webkitGeolocationPermissionRequestFinalize(GObject* object)
+{
+ WebKitGeolocationPermissionRequestPrivate* priv = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(object)->priv;
+
+ // Default behaviour when no decision has been made is denying the request.
+ if (!priv->madeDecision)
+ WKGeolocationPermissionRequestDeny(priv->wkRequest.get());
+
+ priv->~WebKitGeolocationPermissionRequestPrivate();
+ G_OBJECT_CLASS(webkit_geolocation_permission_request_parent_class)->finalize(object);
+}
+
+static void webkit_geolocation_permission_request_class_init(WebKitGeolocationPermissionRequestClass* klass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(klass);
+ objectClass->finalize = webkitGeolocationPermissionRequestFinalize;
+ g_type_class_add_private(klass, sizeof(WebKitGeolocationPermissionRequestPrivate));
+}
+
+WebKitGeolocationPermissionRequest* webkitGeolocationPermissionRequestCreate(WKGeolocationPermissionRequestRef wkRequest)
+{
+ WebKitGeolocationPermissionRequest* geolocationPermissionRequest = WEBKIT_GEOLOCATION_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, NULL));
+ geolocationPermissionRequest->priv->wkRequest = wkRequest;
+ return geolocationPermissionRequest;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h
new file mode 100644
index 000000000..033b63f7e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitGeolocationPermissionRequest_h
+#define WebKitGeolocationPermissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST (webkit_geolocation_permission_request_get_type())
+#define WEBKIT_GEOLOCATION_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequest))
+#define WEBKIT_GEOLOCATION_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequestClass))
+#define WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST))
+#define WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST))
+#define WEBKIT_GEOLOCATION_PERMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST, WebKitGeolocationPermissionRequestClass))
+
+typedef struct _WebKitGeolocationPermissionRequest WebKitGeolocationPermissionRequest;
+typedef struct _WebKitGeolocationPermissionRequestClass WebKitGeolocationPermissionRequestClass;
+typedef struct _WebKitGeolocationPermissionRequestPrivate WebKitGeolocationPermissionRequestPrivate;
+
+struct _WebKitGeolocationPermissionRequest {
+ GObject parent;
+
+ /*< private >*/
+ WebKitGeolocationPermissionRequestPrivate *priv;
+};
+
+struct _WebKitGeolocationPermissionRequestClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_geolocation_permission_request_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.h
new file mode 100644
index 000000000..e6de68753
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequestPrivate.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 WebKitGeolocationPermissionRequestPrivate_h
+#define WebKitGeolocationPermissionRequestPrivate_h
+
+#include "WebKitGeolocationPermissionRequest.h"
+#include "WebKitPrivate.h"
+
+WebKitGeolocationPermissionRequest* webkitGeolocationPermissionRequestCreate(WKGeolocationPermissionRequestRef);
+
+#endif // WebKitGeolocationPermissionRequestPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp
new file mode 100644
index 000000000..648c8093b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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 "WebKitGeolocationProvider.h"
+
+#if ENABLE(GEOLOCATION)
+
+static inline WebKitGeolocationProvider* toGeolocationProvider(const void* clientInfo)
+{
+ return static_cast<WebKitGeolocationProvider*>(const_cast<void*>(clientInfo));
+}
+
+static void startUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
+{
+ toGeolocationProvider(clientInfo)->startUpdating();
+}
+
+static void stopUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
+{
+ toGeolocationProvider(clientInfo)->stopUpdating();
+}
+
+WebKitGeolocationProvider::~WebKitGeolocationProvider()
+{
+ m_provider.stopUpdating();
+}
+
+PassRefPtr<WebKitGeolocationProvider> WebKitGeolocationProvider::create(WKGeolocationManagerRef wkGeolocationManager)
+{
+ return adoptRef(new WebKitGeolocationProvider(wkGeolocationManager));
+}
+
+WebKitGeolocationProvider::WebKitGeolocationProvider(WKGeolocationManagerRef wkGeolocationManager)
+ : m_wkGeolocationManager(wkGeolocationManager)
+ , m_provider(this)
+{
+ ASSERT(wkGeolocationManager);
+
+ WKGeolocationProvider wkGeolocationProvider = {
+ kWKGeolocationProviderCurrentVersion,
+ this, // clientInfo
+ startUpdatingCallback,
+ stopUpdatingCallback
+ };
+ WKGeolocationManagerSetProvider(m_wkGeolocationManager.get(), &wkGeolocationProvider);
+}
+
+void WebKitGeolocationProvider::startUpdating()
+{
+ m_provider.startUpdating();
+}
+
+void WebKitGeolocationProvider::stopUpdating()
+{
+ m_provider.stopUpdating();
+}
+
+void WebKitGeolocationProvider::notifyPositionChanged(int timestamp, double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy)
+{
+ WKRetainPtr<WKGeolocationPositionRef> wkGeolocationPosition(AdoptWK, WKGeolocationPositionCreate(timestamp, latitude, longitude, accuracy));
+ WKGeolocationManagerProviderDidChangePosition(m_wkGeolocationManager.get(), wkGeolocationPosition.get());
+}
+
+void WebKitGeolocationProvider::notifyErrorOccurred(const char* message)
+{
+ WKGeolocationManagerProviderDidFailToDeterminePosition(m_wkGeolocationManager.get());
+}
+
+#endif // ENABLE(GEOLOCATION)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h
new file mode 100644
index 000000000..a02bfcb08
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.h
@@ -0,0 +1,52 @@
+/*
+ * 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 WebKitGeolocationProvider_h
+#define WebKitGeolocationProvider_h
+
+#if ENABLE(GEOLOCATION)
+
+#include "WebKitPrivate.h"
+#include <WebCore/GeolocationProviderGeoclue.h>
+#include <WebCore/GeolocationProviderGeoclueClient.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+class WebKitGeolocationProvider : public RefCounted<WebKitGeolocationProvider>, public WebCore::GeolocationProviderGeoclueClient {
+public:
+ virtual ~WebKitGeolocationProvider();
+ static PassRefPtr<WebKitGeolocationProvider> create(WKGeolocationManagerRef);
+
+ void startUpdating();
+ void stopUpdating();
+
+private:
+ WebKitGeolocationProvider(WKGeolocationManagerRef);
+
+ // GeolocationProviderGeoclueClient interface.
+ virtual void notifyPositionChanged(int, double, double, double, double, double);
+ virtual void notifyErrorOccurred(const char*);
+
+ WKRetainPtr<WKGeolocationManagerRef> m_wkGeolocationManager;
+ WebCore::GeolocationProviderGeoclue m_provider;
+};
+
+#endif // ENABLE(GEOLOCATION)
+
+#endif // WebKitGeolocationProvider_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
index 928b4dc42..034768cb0 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
@@ -253,6 +253,9 @@ WebKitHitTestResult* webkitHitTestResultCreate(WKHitTestResultRef wkHitTestResul
if (!mediaURL.isEmpty())
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
+ if (WKHitTestResultIsContentEditable(wkHitTestResult))
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+
const String& linkTitle = toImpl(wkHitTestResult)->linkTitle();
const String& linkLabel = toImpl(wkHitTestResult)->linkLabel();
@@ -348,6 +351,23 @@ gboolean webkit_hit_test_result_context_is_media(WebKitHitTestResult* hitTestRes
}
/**
+ * webkit_hit_test_result_context_is_editable:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flag is present in
+ * #WebKitHitTestResult:context.
+ *
+ * Returns: %TRUE if there's an editable element at the coordinates of the @hit_test_result,
+ * or %FALSE otherwise
+ */
+gboolean webkit_hit_test_result_context_is_editable(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE);
+
+ return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+}
+
+/**
* webkit_hit_test_result_get_link_uri:
* @hit_test_result: a #WebKitHitTestResult
*
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
index d8916e5f3..01e66c964 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
@@ -46,6 +46,7 @@ typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate;
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element.
* @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: an editable element
*
* Enum values with flags representing the context of a #WebKitHitTestResult.
*/
@@ -54,7 +55,8 @@ typedef enum
WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1,
WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK = 1 << 2,
WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE = 1 << 3,
- WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 5
} WebKitHitTestResultContext;
struct _WebKitHitTestResult {
@@ -82,6 +84,9 @@ webkit_hit_test_result_context_is_image (WebKitHitTestResult *hit_test_resul
WEBKIT_API gboolean
webkit_hit_test_result_context_is_media (WebKitHitTestResult *hit_test_result);
+WEBKIT_API gboolean
+webkit_hit_test_result_context_is_editable (WebKitHitTestResult *hit_test_result);
+
WEBKIT_API const gchar *
webkit_hit_test_result_get_link_uri (WebKitHitTestResult *hit_test_result);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
index 158c7fc42..e30e51d46 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
@@ -149,6 +149,8 @@ void attachLoaderClientToView(WebKitWebView* webView)
0, // willGoToBackForwardListItem
0, // interactionOccurredWhileProcessUnresponsive
0, // pluginDidFail
+ 0, // didReceiveIntentForFrame
+ 0, // registerIntentServiceForFrame
};
WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
WKPageSetPageLoaderClient(wkPage, &wkLoaderClient);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
index b7c537015..7fd5d7861 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
@@ -27,13 +27,18 @@
#define WebKitPrivate_h
#include <WebKit2/WKAPICast.h>
+#include <WebKit2/WKContextSoup.h>
#include <WebKit2/WKDownload.h>
#include <WebKit2/WKFindOptions.h>
#include <WebKit2/WKFullScreenClientGtk.h>
+#include <WebKit2/WKGeolocationManager.h>
+#include <WebKit2/WKGeolocationPermissionRequest.h>
+#include <WebKit2/WKGeolocationPosition.h>
#include <WebKit2/WKInspector.h>
#include <WebKit2/WKInspectorClientGtk.h>
#include <WebKit2/WKRetainPtr.h>
#include <WebKit2/WKSerializedScriptValue.h>
+#include <WebKit2/WKSoupRequestManager.h>
#include <WebKit2/WKString.h>
#include <WebKit2/WebKit2.h>
#include <glib.h>
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp
new file mode 100644
index 000000000..8ea09f200
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitRequestManagerClient.h"
+
+#include "WebKitURISchemeRequestPrivate.h"
+#include "WebKitWebContextPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
+
+using namespace WebKit;
+
+static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, uint64_t requestID, const void* clientInfo)
+{
+ WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(clientInfo);
+ GRefPtr<WebKitURISchemeRequest> request = adoptGRef(webkitURISchemeRequestCreate(webContext, soupRequestManagerRef, urlRef, requestID));
+ webkitWebContextReceivedURIRequest(webContext, request.get());
+}
+
+static void didFailToLoadURIRequest(WKSoupRequestManagerRef, uint64_t requestID, const void* clientInfo)
+{
+ webkitWebContextDidFailToLoadURIRequest(WEBKIT_WEB_CONTEXT(clientInfo), requestID);
+}
+
+void attachRequestManagerClientToContext(WebKitWebContext* webContext)
+{
+ WKSoupRequestManagerClient wkRequestManagerClient = {
+ kWKSoupRequestManagerClientCurrentVersion,
+ webContext, // clientInfo
+ didReceiveURIRequest,
+ didFailToLoadURIRequest
+ };
+ WKSoupRequestManagerSetClient(webkitWebContextGetRequestManager(webContext), &wkRequestManagerClient);
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h
new file mode 100644
index 000000000..a365594f8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.h
@@ -0,0 +1,27 @@
+/*
+ * 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 WebKitRequestManagerClient_h
+#define WebKitRequestManagerClient_h
+
+#include "WebKitWebContext.h"
+
+void attachRequestManagerClientToContext(WebKitWebContext*);
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
index 2548d7b72..7d4eedfb6 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
@@ -21,6 +21,7 @@
#include "WebKitUIClient.h"
#include "WebKitFileChooserRequestPrivate.h"
+#include "WebKitGeolocationPermissionRequestPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitWebViewBasePrivate.h"
#include "WebKitWebViewPrivate.h"
@@ -144,6 +145,12 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters
webkitWebViewRunFileChooserRequest(WEBKIT_WEB_VIEW(clientInfo), request.get());
}
+static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef request, const void* clientInfo)
+{
+ GRefPtr<WebKitGeolocationPermissionRequest> geolocationPermissionRequest = adoptGRef(webkitGeolocationPermissionRequestCreate(request));
+ webkitWebViewMakePermissionRequest(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get()));
+}
+
void attachUIClientToView(WebKitWebView* webView)
{
WKPageUIClient wkUIClient = {
@@ -178,7 +185,7 @@ void attachUIClientToView(WebKitWebView* webView)
0, // pageDidScroll
0, // exceededDatabaseQuota
runOpenPanel,
- 0, // decidePolicyForGeolocationPermissionRequest
+ decidePolicyForGeolocationPermissionRequest,
0, // headerHeight
0, // footerHeight
0, // drawHeader
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp
new file mode 100644
index 000000000..e62c1faf5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitURISchemeRequest.h"
+
+#include "WebKitURISchemeRequestPrivate.h"
+#include "WebKitWebContextPrivate.h"
+#include <WebCore/GOwnPtrSoup.h>
+#include <libsoup/soup.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+static const unsigned int gReadBufferSize = 8192;
+
+G_DEFINE_TYPE(WebKitURISchemeRequest, webkit_uri_scheme_request, G_TYPE_OBJECT)
+
+struct _WebKitURISchemeRequestPrivate {
+ WebKitWebContext* webContext;
+ WKRetainPtr<WKSoupRequestManagerRef> wkRequestManager;
+ uint64_t requestID;
+ CString uri;
+ GOwnPtr<SoupURI> soupURI;
+
+ GRefPtr<GInputStream> stream;
+ uint64_t streamLength;
+ GRefPtr<GCancellable> cancellable;
+ char readBuffer[gReadBufferSize];
+ uint64_t bytesRead;
+ CString mimeType;
+};
+
+static void webkit_uri_scheme_request_init(WebKitURISchemeRequest* request)
+{
+ WebKitURISchemeRequestPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequestPrivate);
+ request->priv = priv;
+ new (priv) WebKitURISchemeRequestPrivate();
+}
+
+static void webkitURISchemeRequestFinalize(GObject* object)
+{
+ WEBKIT_URI_SCHEME_REQUEST(object)->priv->~WebKitURISchemeRequestPrivate();
+ G_OBJECT_CLASS(webkit_uri_scheme_request_parent_class)->finalize(object);
+}
+
+static void webkit_uri_scheme_request_class_init(WebKitURISchemeRequestClass* requestClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+ objectClass->finalize = webkitURISchemeRequestFinalize;
+ g_type_class_add_private(requestClass, sizeof(WebKitURISchemeRequestPrivate));
+}
+
+WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext* webContext, WKSoupRequestManagerRef wkRequestManager, WKURLRef wkURL, uint64_t requestID)
+{
+ WebKitURISchemeRequest* request = WEBKIT_URI_SCHEME_REQUEST(g_object_new(WEBKIT_TYPE_URI_SCHEME_REQUEST, NULL));
+ request->priv->webContext = webContext;
+ request->priv->wkRequestManager = wkRequestManager;
+ request->priv->uri = toImpl(wkURL)->string().utf8();
+ request->priv->requestID = requestID;
+ return request;
+}
+
+uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest* request)
+{
+ return request->priv->requestID;
+}
+
+void webkitURISchemeRequestCancel(WebKitURISchemeRequest* request)
+{
+ if (request->priv->cancellable.get())
+ g_cancellable_cancel(request->priv->cancellable.get());
+}
+
+/**
+ * webkit_uri_scheme_request_get_scheme:
+ * @request: a #WebKitURISchemeRequest
+ *
+ * Get the URI scheme of @request
+ *
+ * Returns: the URI scheme of @request
+ */
+const char* webkit_uri_scheme_request_get_scheme(WebKitURISchemeRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0);
+
+ if (!request->priv->soupURI)
+ request->priv->soupURI.set(soup_uri_new(request->priv->uri.data()));
+ return request->priv->soupURI->scheme;
+}
+
+/**
+ * webkit_uri_scheme_request_get_uri:
+ * @request: a #WebKitURISchemeRequest
+ *
+ * Get the URI of @request
+ *
+ * Returns: the full URI of @request
+ */
+const char* webkit_uri_scheme_request_get_uri(WebKitURISchemeRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0);
+
+ return request->priv->uri.data();
+}
+
+/**
+ * webkit_uri_scheme_request_get_path:
+ * @request: a #WebKitURISchemeRequest
+ *
+ * Get the URI path of @request
+ *
+ * Returns: the URI path of @request
+ */
+const char* webkit_uri_scheme_request_get_path(WebKitURISchemeRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0);
+
+ if (!request->priv->soupURI)
+ request->priv->soupURI.set(soup_uri_new(request->priv->uri.data()));
+ return request->priv->soupURI->path;
+}
+
+static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsyncResult* result, WebKitURISchemeRequest* schemeRequest)
+{
+ GRefPtr<WebKitURISchemeRequest> request = adoptGRef(schemeRequest);
+ gssize bytesRead = g_input_stream_read_finish(inputStream, result, 0);
+ // FIXME: notify the WebProcess that we failed to read from the user stream.
+ if (bytesRead == -1) {
+ webkitWebContextDidFinishURIRequest(request->priv->webContext, request->priv->requestID);
+ return;
+ }
+
+ WebKitURISchemeRequestPrivate* priv = request->priv;
+ WKRetainPtr<WKDataRef> wkData(AdoptWK, WKDataCreate(bytesRead ? reinterpret_cast<const unsigned char*>(priv->readBuffer) : 0, bytesRead));
+ if (!priv->bytesRead) {
+ // First chunk read. In case of empty reply an empty WKDataRef is sent to the WebProcess.
+ WKRetainPtr<WKStringRef> wkMimeType = !priv->mimeType.isNull() ? adoptWK(WKStringCreateWithUTF8CString(priv->mimeType.data())) : 0;
+ WKSoupRequestManagerDidHandleURIRequest(priv->wkRequestManager.get(), wkData.get(), priv->streamLength, wkMimeType.get(), priv->requestID);
+ } else if (bytesRead || (!bytesRead && !priv->streamLength)) {
+ // Subsequent chunk read. We only send an empty WKDataRef to the WebProcess when stream length is unknown.
+ WKSoupRequestManagerDidReceiveURIRequestData(priv->wkRequestManager.get(), wkData.get(), priv->requestID);
+ }
+
+ if (!bytesRead) {
+ webkitWebContextDidFinishURIRequest(request->priv->webContext, request->priv->requestID);
+ return;
+ }
+
+ priv->bytesRead += bytesRead;
+ g_input_stream_read_async(inputStream, priv->readBuffer, gReadBufferSize, G_PRIORITY_DEFAULT, priv->cancellable.get(),
+ reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request.get()));
+}
+
+/**
+ * webkit_uri_scheme_request_finish:
+ * @request: a #WebKitURISchemeRequest
+ * @stream: a #GInputStream to read the contents of the request
+ * @stream_length: the length of the stream or -1 if not known
+ * @mime_type: (allow-none): the content type of the stream or %NULL if not known
+ *
+ * Finish a #WebKitURISchemeRequest by setting the contents of the request and its mime type.
+ */
+void webkit_uri_scheme_request_finish(WebKitURISchemeRequest* request, GInputStream* inputStream, gint64 streamLength, const gchar* mimeType)
+{
+ g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request));
+ g_return_if_fail(G_IS_INPUT_STREAM(inputStream));
+ g_return_if_fail(streamLength == -1 || streamLength >= 0);
+
+ request->priv->stream = inputStream;
+ // We use -1 in the API for consistency with soup when the content length is not known, but 0 internally.
+ request->priv->streamLength = streamLength == -1 ? 0 : streamLength;
+ request->priv->cancellable = adoptGRef(g_cancellable_new());
+ request->priv->bytesRead = 0;
+ request->priv->mimeType = mimeType;
+ g_input_stream_read_async(inputStream, request->priv->readBuffer, gReadBufferSize, G_PRIORITY_DEFAULT, request->priv->cancellable.get(),
+ reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request));
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h
new file mode 100644
index 000000000..34f214489
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitURISchemeRequest_h
+#define WebKitURISchemeRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_URI_SCHEME_REQUEST (webkit_uri_scheme_request_get_type())
+#define WEBKIT_URI_SCHEME_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequest))
+#define WEBKIT_IS_URI_SCHEME_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_SCHEME_REQUEST))
+#define WEBKIT_URI_SCHEME_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequestClass))
+#define WEBKIT_IS_URI_SCHEME_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_URI_SCHEME_REQUEST))
+#define WEBKIT_URI_SCHEME_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_URI_SCHEME_REQUEST, WebKitURISchemeRequestClass))
+
+typedef struct _WebKitURISchemeRequest WebKitURISchemeRequest;
+typedef struct _WebKitURISchemeRequestClass WebKitURISchemeRequestClass;
+typedef struct _WebKitURISchemeRequestPrivate WebKitURISchemeRequestPrivate;
+
+struct _WebKitURISchemeRequest {
+ GObject parent;
+
+ WebKitURISchemeRequestPrivate *priv;
+};
+
+struct _WebKitURISchemeRequestClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_uri_scheme_request_get_type (void);
+
+WEBKIT_API const gchar *
+webkit_uri_scheme_request_get_scheme (WebKitURISchemeRequest *request);
+
+WEBKIT_API const gchar *
+webkit_uri_scheme_request_get_uri (WebKitURISchemeRequest *request);
+
+WEBKIT_API const gchar *
+webkit_uri_scheme_request_get_path (WebKitURISchemeRequest *request);
+
+WEBKIT_API void
+webkit_uri_scheme_request_finish (WebKitURISchemeRequest *request,
+ GInputStream *stream,
+ gint64 stream_length,
+ const gchar *mime_type);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h
new file mode 100644
index 000000000..149813def
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h
@@ -0,0 +1,32 @@
+/*
+ * 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 WebKitURISchemeRequestPrivate_h
+#define WebKitURISchemeRequestPrivate_h
+
+#include "WebKitPrivate.h"
+#include "WebKitURISchemeRequest.h"
+#include "WebKitWebContext.h"
+#include <WebKit2/WKSoupRequestManager.h>
+
+WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext*, WKSoupRequestManagerRef, WKURLRef, uint64_t requestID);
+uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest*);
+void webkitURISchemeRequestCancel(WebKitURISchemeRequest*);
+
+#endif // WebKitURISchemeRequestPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp
new file mode 100644
index 000000000..4ef62e372
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.cpp
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitVersion.h"
+
+/**
+ * webkit_get_major_version:
+ *
+ * Returns the major version number of the WebKit library.
+ * (e.g. in WebKit version 1.8.3 this is 1.)
+ *
+ * This function is in the library, so it represents the WebKit library
+ * your code is running against. Contrast with the #WEBKIT_MAJOR_VERSION
+ * macro, which represents the major version of the WebKit headers you
+ * have included when compiling your code.
+ *
+ * Returns: the major version number of the WebKit library
+ */
+guint webkit_get_major_version(void)
+{
+ return WEBKIT_MAJOR_VERSION;
+}
+
+/**
+ * webkit_get_minor_version:
+ *
+ * Returns the minor version number of the WebKit library.
+ * (e.g. in WebKit version 1.8.3 this is 8.)
+ *
+ * This function is in the library, so it represents the WebKit library
+ * your code is running against. Contrast with the #WEBKIT_MINOR_VERSION
+ * macro, which represents the minor version of the WebKit headers you
+ * have included when compiling your code.
+ *
+ * Returns: the minor version number of the WebKit library
+ */
+guint webkit_get_minor_version(void)
+{
+ return WEBKIT_MINOR_VERSION;
+}
+
+/**
+ * webkit_get_micro_version:
+ *
+ * Returns the micro version number of the WebKit library.
+ * (e.g. in WebKit version 1.8.3 this is 3.)
+ *
+ * This function is in the library, so it represents the WebKit library
+ * your code is running against. Contrast with the #WEBKIT_MICRO_VERSION
+ * macro, which represents the micro version of the WebKit headers you
+ * have included when compiling your code.
+ *
+ * Returns: the micro version number of the WebKit library
+ */
+guint webkit_get_micro_version(void)
+{
+ return WEBKIT_MICRO_VERSION;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in b/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in
new file mode 100644
index 000000000..81ef5179a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitVersion.h.in
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitVersion_h
+#define WebKitVersion_h
+
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+/**
+ * WEBKIT_MAJOR_VERSION:
+ *
+ * Like webkit_get_major_version(), but from the headers used at
+ * application compile time, rather than from the library linked
+ * against at application run time.
+ */
+#define WEBKIT_MAJOR_VERSION (@WEBKIT_MAJOR_VERSION@)
+
+/**
+ * WEBKIT_MINOR_VERSION:
+ *
+ * Like webkit_get_minor_version(), but from the headers used at
+ * application compile time, rather than from the library linked
+ * against at application run time.
+ */
+#define WEBKIT_MINOR_VERSION (@WEBKIT_MINOR_VERSION@)
+
+/**
+ * WEBKIT_MICRO_VERSION:
+ *
+ * Like webkit_get_micro_version(), but from the headers used at
+ * application compile time, rather than from the library linked
+ * against at application run time.
+ */
+#define WEBKIT_MICRO_VERSION (@WEBKIT_MICRO_VERSION@)
+
+/**
+ * WEBKIT_CHECK_VERSION:
+ * @major: major version (e.g. 1 for version 1.2.5)
+ * @minor: minor version (e.g. 2 for version 1.2.5)
+ * @micro: micro version (e.g. 5 for version 1.2.5)
+ *
+ * Returns: %TRUE if the version of the WebKit header files
+ * is the same as or newer than the passed-in version.
+ */
+#define WEBKIT_CHECK_VERSION(major, minor, micro) \
+ (WEBKIT_MAJOR_VERSION > (major) || \
+ (WEBKIT_MAJOR_VERSION == (major) && WEBKIT_MINOR_VERSION > (minor)) || \
+ (WEBKIT_MAJOR_VERSION == (major) && WEBKIT_MINOR_VERSION == (minor) && \
+ WEBKIT_MICRO_VERSION >= (micro)))
+
+WEBKIT_API guint
+webkit_get_major_version (void);
+
+WEBKIT_API guint
+webkit_get_minor_version (void);
+
+WEBKIT_API guint
+webkit_get_micro_version (void);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
index 681c0d12b..372f46637 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
@@ -24,8 +24,11 @@
#include "WebKitCookieManagerPrivate.h"
#include "WebKitDownloadClient.h"
#include "WebKitDownloadPrivate.h"
+#include "WebKitGeolocationProvider.h"
#include "WebKitPluginPrivate.h"
#include "WebKitPrivate.h"
+#include "WebKitRequestManagerClient.h"
+#include "WebKitURISchemeRequestPrivate.h"
#include "WebKitWebContextPrivate.h"
#include <WebCore/FileSystem.h>
#include <wtf/HashMap.h>
@@ -40,10 +43,35 @@ enum {
LAST_SIGNAL
};
+struct WebKitURISchemeHandler {
+ WebKitURISchemeHandler()
+ : callback(0)
+ , userData(0)
+ {
+ }
+ WebKitURISchemeHandler(WebKitURISchemeRequestCallback callback, void* userData)
+ : callback(callback)
+ , userData(userData)
+ {
+ }
+
+ WebKitURISchemeRequestCallback callback;
+ void* userData;
+};
+
+typedef HashMap<String, WebKitURISchemeHandler> URISchemeHandlerMap;
+typedef HashMap<uint64_t, GRefPtr<WebKitURISchemeRequest> > URISchemeRequestMap;
+
struct _WebKitWebContextPrivate {
WKRetainPtr<WKContextRef> context;
GRefPtr<WebKitCookieManager> cookieManager;
+ WKRetainPtr<WKSoupRequestManagerRef> requestManager;
+ URISchemeHandlerMap uriSchemeHandlers;
+ URISchemeRequestMap uriSchemeRequests;
+#if ENABLE(GEOLOCATION)
+ RefPtr<WebKitGeolocationProvider> geolocationProvider;
+#endif
};
static guint signals[LAST_SIGNAL] = { 0, };
@@ -91,8 +119,14 @@ static gpointer createDefaultWebContext(gpointer)
{
static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL)));
webContext->priv->context = WKContextGetSharedProcessContext();
+ webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get());
WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser);
attachDownloadClientToContext(webContext.get());
+ attachRequestManagerClientToContext(webContext.get());
+#if ENABLE(GEOLOCATION)
+ WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get());
+ webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager);
+#endif
return webContext.get();
}
@@ -317,6 +351,59 @@ GList* webkit_web_context_get_plugins_finish(WebKitWebContext* context, GAsyncRe
return plugins;
}
+/**
+ * webkit_web_context_register_uri_scheme:
+ * @context: a #WebKitWebContext
+ * @scheme: the network scheme to register
+ * @callback: a #WebKitURISchemeRequestCallback
+ * @user_data: data to pass to callback function
+ *
+ * Register @scheme in @context, so that when an URI request with @scheme is made in the
+ * #WebKitWebContext, the #WebKitURISchemeRequestCallback registered will be called with a
+ * #WebKitURISchemeRequest.
+ * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the
+ * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later when the data of
+ * the request is available.
+ *
+ * <informalexample><programlisting>
+ * static void
+ * about_uri_scheme_request_cb (WebKitURISchemeRequest *request,
+ * gpointer user_data)
+ * {
+ * GInputStream *stream;
+ * gsize stream_length;
+ * const gchar *path;
+ *
+ * path = webkit_uri_scheme_request_get_path (request);
+ * if (!g_strcmp0 (path, "plugins")) {
+ * /<!-- -->* Create a GInputStream with the contents of plugins about page, and set its length to stream_length *<!-- -->/
+ * } else if (!g_strcmp0 (path, "memory")) {
+ * /<!-- -->* Create a GInputStream with the contents of memory about page, and set its length to stream_length *<!-- -->/
+ * } else if (!g_strcmp0 (path, "applications")) {
+ * /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/
+ * } else {
+ * gchar *contents;
+ *
+ * contents = g_strdup_printf ("&lt;html&gt;&lt;body&gt;&lt;p&gt;Invalid about:%s page&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", path);
+ * stream_length = strlen (contents);
+ * stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free);
+ * }
+ * webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
+ * g_object_unref (stream);
+ * }
+ * </programlisting></informalexample>
+ */
+void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const char* scheme, WebKitURISchemeRequestCallback callback, gpointer userData)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+ g_return_if_fail(scheme);
+ g_return_if_fail(callback);
+
+ context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), WebKitURISchemeHandler(callback, userData));
+ WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme));
+ WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get());
+}
+
WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload)
{
GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload);
@@ -345,3 +432,30 @@ WKContextRef webkitWebContextGetWKContext(WebKitWebContext* context)
return context->priv->context.get();
}
+WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext* context)
+{
+ return context->priv->requestManager.get();
+}
+
+void webkitWebContextReceivedURIRequest(WebKitWebContext* context, WebKitURISchemeRequest* request)
+{
+ WebKitURISchemeHandler handler = context->priv->uriSchemeHandlers.get(webkit_uri_scheme_request_get_scheme(request));
+ if (!handler.callback)
+ return;
+
+ context->priv->uriSchemeRequests.set(webkitURISchemeRequestGetID(request), request);
+ handler.callback(request, handler.userData);
+}
+
+void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext* context, uint64_t requestID)
+{
+ GRefPtr<WebKitURISchemeRequest> request = context->priv->uriSchemeRequests.get(requestID);
+ if (!request.get())
+ return;
+ webkitURISchemeRequestCancel(request.get());
+}
+
+void webkitWebContextDidFinishURIRequest(WebKitWebContext* context, uint64_t requestID)
+{
+ context->priv->uriSchemeRequests.remove(requestID);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
index 02ef73d43..1325017d1 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/WebKitURISchemeRequest.h>
G_BEGIN_DECLS
@@ -58,6 +59,17 @@ typedef enum {
WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER
} WebKitCacheModel;
+/**
+ * WebKitURISchemeRequestCallback:
+ * @request: the #WebKitURISchemeRequest
+ * @user_data: user data passed to the callback
+ *
+ * Type definition for a function that will be called back when an URI request is
+ * made for a user registered URI scheme.
+ */
+typedef void (* WebKitURISchemeRequestCallback) (WebKitURISchemeRequest *request,
+ gpointer user_data);
+
typedef struct _WebKitWebContext WebKitWebContext;
typedef struct _WebKitWebContextClass WebKitWebContextClass;
typedef struct _WebKitWebContextPrivate WebKitWebContextPrivate;
@@ -86,33 +98,37 @@ WEBKIT_API WebKitWebContext *
webkit_web_context_get_default (void);
WEBKIT_API void
-webkit_web_context_set_cache_model (WebKitWebContext *context,
- WebKitCacheModel cache_model);
+webkit_web_context_set_cache_model (WebKitWebContext *context,
+ WebKitCacheModel cache_model);
WEBKIT_API WebKitCacheModel
-webkit_web_context_get_cache_model (WebKitWebContext *context);
+webkit_web_context_get_cache_model (WebKitWebContext *context);
WEBKIT_API WebKitDownload *
-webkit_web_context_download_uri (WebKitWebContext *context,
- const gchar *uri);
+webkit_web_context_download_uri (WebKitWebContext *context,
+ const gchar *uri);
WEBKIT_API WebKitCookieManager *
-webkit_web_context_get_cookie_manager (WebKitWebContext *context);
+webkit_web_context_get_cookie_manager (WebKitWebContext *context);
WEBKIT_API void
-webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context,
- const gchar *directory);
+webkit_web_context_set_additional_plugins_directory (WebKitWebContext *context,
+ const gchar *directory);
WEBKIT_API void
-webkit_web_context_get_plugins (WebKitWebContext *context,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
+webkit_web_context_get_plugins (WebKitWebContext *context,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
WEBKIT_API GList *
-webkit_web_context_get_plugins_finish (WebKitWebContext *context,
- GAsyncResult *result,
- GError **error);
-
+webkit_web_context_get_plugins_finish (WebKitWebContext *context,
+ GAsyncResult *result,
+ GError **error);
+WEBKIT_API void
+webkit_web_context_register_uri_scheme (WebKitWebContext *context,
+ const gchar *scheme,
+ WebKitURISchemeRequestCallback callback,
+ gpointer user_data);
G_END_DECLS
#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
index d2dd81361..9e5536b3a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
@@ -26,16 +26,17 @@
#ifndef WebKitWebContextPrivate_h
#define WebKitWebContextPrivate_h
+#include "WebKitPrivate.h"
+#include "WebKitURISchemeRequest.h"
#include "WebKitWebContext.h"
-#include <WebKit2/WebKit2.h>
-
-G_BEGIN_DECLS
WKContextRef webkitWebContextGetWKContext(WebKitWebContext*);
WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef);
void webkitWebContextRemoveDownload(WKDownloadRef);
void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*);
-
-G_END_DECLS
+WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext*);
+void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*);
+void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID);
+void webkitWebContextDidFinishURIRequest(WebKitWebContext*, uint64_t requestID);
#endif // WebKitWebContextPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index 938f95fd1..7f5764e7d 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -21,7 +21,10 @@
#include "config.h"
#include "WebKitWebView.h"
+#include "WebContextMenuItem.h"
+#include "WebContextMenuItemData.h"
#include "WebKitBackForwardListPrivate.h"
+#include "WebKitContextMenuClient.h"
#include "WebKitEnumTypes.h"
#include "WebKitError.h"
#include "WebKitFullscreenClient.h"
@@ -295,6 +298,7 @@ static void webkitWebViewConstructed(GObject* object)
attachPolicyClientToPage(webView);
attachResourceLoadClientToView(webView);
attachFullScreenClientToView(webView);
+ attachContextMenuClientToView(webView);
WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase);
priv->backForwardList = adoptGRef(webkitBackForwardListCreate(WKPageGetBackForwardList(toAPI(page))));
@@ -1168,6 +1172,54 @@ void webkitWebViewRunFileChooserRequest(WebKitWebView* webView, WebKitFileChoose
g_signal_emit(webView, signals[RUN_FILE_CHOOSER], 0, request, &returnValue);
}
+static void webkitWebViewCreateAndAppendDefaultMenuItems(WebKitWebView* webView, WKArrayRef wkProposedMenu, Vector<ContextMenuItem>& contextMenuItems)
+{
+ for (size_t i = 0; i < WKArrayGetSize(wkProposedMenu); ++i) {
+ WKContextMenuItemRef wkItem = static_cast<WKContextMenuItemRef>(WKArrayGetItemAtIndex(wkProposedMenu, i));
+ contextMenuItems.append(toImpl(wkItem)->data()->core());
+ }
+}
+
+static bool webkitWebViewShouldShowInputMethodsMenu(WebKitWebView* webView)
+{
+ GtkSettings* settings = gtk_widget_get_settings(GTK_WIDGET(webView));
+ if (!settings)
+ return true;
+
+ gboolean showInputMethodMenu;
+ g_object_get(settings, "gtk-show-input-method-menu", &showInputMethodMenu, NULL);
+ return showInputMethodMenu;
+}
+
+static void webkitWebViewCreateAndAppendInputMethodsMenuItem(WebKitWebView* webView, Vector<ContextMenuItem>& contextMenuItems)
+{
+ if (!webkitWebViewShouldShowInputMethodsMenu(webView))
+ return;
+
+ GtkIMContext* imContext = webkitWebViewBaseGetIMContext(WEBKIT_WEB_VIEW_BASE(webView));
+ GtkMenu* imContextMenu = GTK_MENU(gtk_menu_new());
+ gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(imContext), GTK_MENU_SHELL(imContextMenu));
+ ContextMenu subMenu(imContextMenu);
+
+ ContextMenuItem separator(SeparatorType, ContextMenuItemTagNoAction, String());
+ contextMenuItems.append(separator);
+ ContextMenuItem menuItem(SubmenuType, ContextMenuItemTagNoAction, _("Input _Methods"), &subMenu);
+ contextMenuItems.append(menuItem);
+}
+
+void webkitWebViewPopulateContextMenu(WebKitWebView* webView, WKArrayRef wkProposedMenu, WKHitTestResultRef wkHitTestResult)
+{
+ WebContextMenuProxyGtk* contextMenu = webkitWebViewBaseGetActiveContextMenuProxy(WEBKIT_WEB_VIEW_BASE(webView));
+ ASSERT(contextMenu);
+
+ Vector<ContextMenuItem> contextMenuItems;
+ webkitWebViewCreateAndAppendDefaultMenuItems(webView, wkProposedMenu, contextMenuItems);
+ if (WKHitTestResultIsContentEditable(wkHitTestResult))
+ webkitWebViewCreateAndAppendInputMethodsMenuItem(webView, contextMenuItems);
+
+ contextMenu->populate(contextMenuItems);
+}
+
/**
* webkit_web_view_new:
*
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
index f8308aa14..a2cc1d97b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -65,6 +65,10 @@
#include "WebFullScreenManagerProxy.h"
#endif
+#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
+#include <gdk/gdkx.h>
+#endif
+
using namespace WebKit;
using namespace WebCore;
@@ -90,6 +94,7 @@ struct _WebKitWebViewBasePrivate {
#endif
GtkWidget* inspectorView;
unsigned inspectorViewHeight;
+ WebContextMenuProxyGtk* activeContextMenuProxy;
};
G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
@@ -154,6 +159,9 @@ 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);
@@ -339,6 +347,13 @@ 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;
@@ -759,3 +774,13 @@ void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase* webkitWebViewBas
webkitWebViewBase->priv->inspectorViewHeight = height;
gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
}
+
+void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase, WebContextMenuProxyGtk* contextMenuProxy)
+{
+ webkitWebViewBase->priv->activeContextMenuProxy = contextMenuProxy;
+}
+
+WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase)
+{
+ return webkitWebViewBase->priv->activeContextMenuProxy;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
index 5e191971c..45ffbf283 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
@@ -28,6 +28,7 @@
#ifndef WebKitWebViewBasePrivate_h
#define WebKitWebViewBasePrivate_h
+#include "WebContextMenuProxyGtk.h"
#include "WebKitPrivate.h"
#include "WebKitWebViewBase.h"
#include "WebPageProxy.h"
@@ -46,5 +47,7 @@ void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase*);
void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*);
void webkitWebViewBaseInitializeFullScreenClient(WebKitWebViewBase*, const WKFullScreenClientGtk*);
void webkitWebViewBaseSetInspectorViewHeight(WebKitWebViewBase*, unsigned height);
+void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebContextMenuProxyGtk*);
+WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*);
#endif // WebKitWebViewBasePrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
index 6ab374551..aedcdee6e 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -53,5 +53,6 @@ void webkitWebViewRemoveLoadingWebResource(WebKitWebView*, uint64_t resourceIden
WebKitWebResource* webkitWebViewResourceLoadFinished(WebKitWebView*, uint64_t resourceIdentifier);
bool webkitWebViewEnterFullScreen(WebKitWebView*);
bool webkitWebViewLeaveFullScreen(WebKitWebView*);
+void webkitWebViewPopulateContextMenu(WebKitWebView*, WKArrayRef proposedMenu, WKHitTestResultRef);
#endif // WebKitWebViewPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
index 90005acb2..c2eebf36c 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -22,6 +22,7 @@
<xi:include href="xml/WebKitWindowProperties.xml"/>
<xi:include href="xml/WebKitDownload.xml"/>
<xi:include href="xml/WebKitPermissionRequest.xml"/>
+ <xi:include href="xml/WebKitGeolocationPermissionRequest.xml"/>
<xi:include href="xml/WebKitPolicyDecision.xml"/>
<xi:include href="xml/WebKitNavigationPolicyDecision.xml"/>
<xi:include href="xml/WebKitResponsePolicyDecision.xml"/>
@@ -34,6 +35,8 @@
<xi:include href="xml/WebKitCookieManager.xml"/>
<xi:include href="xml/WebKitPlugin.xml"/>
<xi:include href="xml/WebKitWebInspector.xml"/>
+ <xi:include href="xml/WebKitURISchemeRequest.xml"/>
+ <xi:include href="xml/WebKitVersion.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 6dde0866d..1b97de88f 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -33,6 +33,10 @@ webkit_web_context_set_additional_plugins_directory
webkit_web_context_get_plugins
webkit_web_context_get_plugins_finish
+<SUBSECTION URI Scheme>
+WebKitURISchemeRequestCallback
+webkit_web_context_register_uri_scheme
+
<SUBSECTION Standard>
WebKitWebContextClass
WEBKIT_WEB_CONTEXT
@@ -355,6 +359,7 @@ webkit_download_get_response
webkit_download_cancel
webkit_download_get_estimated_progress
webkit_download_get_elapsed_time
+webkit_download_get_received_data_length
<SUBSECTION Standard>
WebKitDownloadClass
@@ -388,6 +393,24 @@ webkit_permission_request_get_type
</SECTION>
<SECTION>
+<FILE>WebKitGeolocationPermissionRequest</FILE>
+WebKitGeolocationPermissionRequest
+
+<SUBSECTION Standard>
+WebKitGeolocationPermissionRequestClass
+WEBKIT_TYPE_GEOLOCATION_PERMISSION_REQUEST
+WEBKIT_GEOLOCATION_PERMISSION_REQUEST
+WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST
+WEBKIT_GEOLOCATION_PERMISSION_REQUEST_CLASS
+WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST_CLASS
+WEBKIT_GEOLOCATION_PERMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitGeolocationPermissionRequestPrivate
+webkit_geolocation_permission_request_get_type
+</SECTION>
+
+<SECTION>
<FILE>WebKitPolicyDecision</FILE>
WebKitPolicyDecision
webkit_policy_decision_download
@@ -460,6 +483,7 @@ webkit_hit_test_result_get_context
webkit_hit_test_result_context_is_link
webkit_hit_test_result_context_is_image
webkit_hit_test_result_context_is_media
+webkit_hit_test_result_context_is_editable
webkit_hit_test_result_get_link_uri
webkit_hit_test_result_get_link_title
webkit_hit_test_result_get_link_label
@@ -685,3 +709,38 @@ WEBKIT_WEB_INSPECTOR_GET_CLASS
webkit_web_inspector_get_type
WebKitWebInspectorPrivate
</SECTION>
+
+<SECTION>
+<FILE>WebKitURISchemeRequest</FILE>
+WebKitURISchemeRequest
+webkit_uri_scheme_request_get_scheme
+webkit_uri_scheme_request_get_uri
+webkit_uri_scheme_request_get_path
+webkit_uri_scheme_request_finish
+
+<SUBSECTION Standard>
+WebKitURISchemeRequestClass
+WEBKIT_TYPE_URI_SCHEME_REQUEST
+WEBKIT_URI_SCHEME_REQUEST
+WEBKIT_IS_URI_SCHEME_REQUEST
+WEBKIT_URI_SCHEME_REQUEST_CLASS
+WEBKIT_IS_URI_SCHEME_REQUEST_CLASS
+WEBKIT_URI_SCHEME_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitURISchemeRequestPrivate
+webkit_uri_scheme_request_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitVersion</FILE>
+webkit_get_major_version
+webkit_get_minor_version
+webkit_get_micro_version
+
+<SUBSECTION>
+WEBKIT_MAJOR_VERSION
+WEBKIT_MINOR_VERSION
+WEBKIT_MICRO_VERSION
+WEBKIT_CHECK_VERSION
+</SECTION>
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
index 92b6fb400..d155982f2 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
@@ -18,3 +18,4 @@ webkit_cookie_manager_get_type
webkit_plugin_get_type
webkit_mime_info_get_type
webkit_web_inspector_get_type
+webkit_uri_scheme_request_get_type
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
index 8fa0cd8d8..7adae8adc 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
@@ -8,6 +8,7 @@ TEST_PROGS += \
Programs/WebKit2APITests/TestLoaderClient \
Programs/WebKit2APITests/TestPrinting \
Programs/WebKit2APITests/TestResources \
+ Programs/WebKit2APITests/TestWebKitVersion \
Programs/WebKit2APITests/TestWebKitFindController \
Programs/WebKit2APITests/TestWebKitPolicyClient \
Programs/WebKit2APITests/TestWebKitSettings \
@@ -160,4 +161,10 @@ Programs_WebKit2APITests_TestInspector_CPPFLAGS = \
Programs_WebKit2APITests_TestInspector_LDADD = $(webkit2_tests_ldadd)
Programs_WebKit2APITests_TestInspector_LDFLAGS = $(webkit2_tests_ldflags)
+Programs_WebKit2APITests_TestWebKitVersion_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp
+Programs_WebKit2APITests_TestWebKitVersion_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebKitVersion_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestWebKitVersion_LDFLAGS = $(webkit2_tests_ldflags)
+
endif # ENABLE_WEBKIT2
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp
index acec9ece1..9c3262b53 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp
@@ -136,6 +136,7 @@ public:
virtual void finished(WebKitDownload* download)
{
+ g_assert_cmpuint(m_downloadSize, ==, webkit_download_get_received_data_length(download));
m_downloadEvents.append(Finished);
g_main_loop_quit(m_mainLoop);
}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp
new file mode 100644
index 000000000..e747ff962
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitVersion.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "TestMain.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+
+static void testWebKitVersion(Test*, gconstpointer)
+{
+ g_assert_cmpuint(webkit_get_major_version(), ==, WEBKIT_MAJOR_VERSION);
+ g_assert_cmpuint(webkit_get_minor_version(), ==, WEBKIT_MINOR_VERSION);
+ g_assert_cmpuint(webkit_get_micro_version(), ==, WEBKIT_MICRO_VERSION);
+}
+
+static void testWebKitCheckVersion(Test*, gconstpointer)
+{
+ g_assert(WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION));
+ g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION + 1, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION));
+ g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION + 1, WEBKIT_MICRO_VERSION));
+ g_assert(!WEBKIT_CHECK_VERSION(WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION + 1));
+}
+
+void beforeAll()
+{
+ Test::add("WebKitVersion", "version", testWebKitVersion);
+ Test::add("WebKitVersion", "check-version", testWebKitCheckVersion);
+}
+
+void afterAll()
+{
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
index 216a5c9f5..e7d43a13d 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
@@ -19,10 +19,13 @@
#include "config.h"
-#include "TestMain.h"
+#include "LoadTrackingTest.h"
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
+#include <wtf/HashMap.h>
+#include <wtf/gobject/GOwnPtr.h>
#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
static void testWebContextDefault(Test* test, gconstpointer)
{
@@ -106,10 +109,133 @@ static void testWebContextGetPlugins(PluginsTest* test, gconstpointer)
g_assert_cmpstr(extensions[0], ==, "testnetscape");
}
+static const char* kBarHTML = "<html><body>Bar</body></html>";
+static const char* kEchoHTMLFormat = "<html><body>%s</body></html>";
+
+class URISchemeTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(URISchemeTest);
+
+ struct URISchemeHandler {
+ URISchemeHandler()
+ : replyLength(0)
+ , replyWithPath(false)
+ {
+ }
+
+ URISchemeHandler(const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false)
+ : reply(reply)
+ , replyLength(replyLength)
+ , mimeType(mimeType)
+ , replyWithPath(replyWithPath)
+ {
+ }
+
+ CString reply;
+ int replyLength;
+ CString mimeType;
+ bool replyWithPath;
+ };
+
+ static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData)
+ {
+ URISchemeTest* test = static_cast<URISchemeTest*>(userData);
+ test->m_uriSchemeRequest = request;
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+ GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get()));
+
+ String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request)));
+ g_assert(!scheme.isEmpty());
+ g_assert(test->m_handlersMap.contains(scheme));
+ const URISchemeHandler& handler = test->m_handlersMap.get(scheme);
+
+ if (handler.replyWithPath) {
+ char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request));
+ g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free);
+ } else if (!handler.reply.isNull())
+ g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0);
+ webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data());
+ }
+
+ void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false)
+ {
+ m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType, replyWithPath));
+ webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this);
+ }
+
+ static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData)
+ {
+ size_t dataSize;
+ GOwnPtr<GError> error;
+ unsigned char* data = webkit_web_resource_get_data_finish(WEBKIT_WEB_RESOURCE(object), result, &dataSize, &error.outPtr());
+ g_assert(data);
+
+ URISchemeTest* test = static_cast<URISchemeTest*>(userData);
+ test->m_resourceData.set(reinterpret_cast<char*>(data));
+ test->m_resourceDataSize = dataSize;
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ const char* mainResourceData(size_t& mainResourceDataSize)
+ {
+ m_resourceDataSize = 0;
+ m_resourceData.clear();
+ WebKitWebResource* resource = webkit_web_view_get_main_resource(m_webView);
+ g_assert(resource);
+
+ webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this);
+ g_main_loop_run(m_mainLoop);
+
+ mainResourceDataSize = m_resourceDataSize;
+ return m_resourceData.get();
+ }
+
+ GOwnPtr<char> m_resourceData;
+ size_t m_resourceDataSize;
+ GRefPtr<WebKitURISchemeRequest> m_uriSchemeRequest;
+ HashMap<String, URISchemeHandler> m_handlersMap;
+};
+
+static void testWebContextURIScheme(URISchemeTest* test, gconstpointer)
+{
+ test->registerURISchemeHandler("foo", kBarHTML, strlen(kBarHTML), "text/html");
+ test->loadURI("foo:blank");
+ test->waitUntilLoadFinished();
+ size_t mainResourceDataSize = 0;
+ const char* mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, strlen(kBarHTML));
+ g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize));
+
+ test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html", true);
+ test->loadURI("echo:hello world");
+ test->waitUntilLoadFinished();
+ GOwnPtr<char> echoHTML(g_strdup_printf(kEchoHTMLFormat, webkit_uri_scheme_request_get_path(test->m_uriSchemeRequest.get())));
+ mainResourceDataSize = 0;
+ mainResourceData = test->mainResourceData(mainResourceDataSize);
+ g_assert_cmpint(mainResourceDataSize, ==, strlen(echoHTML.get()));
+ g_assert(!strncmp(mainResourceData, echoHTML.get(), mainResourceDataSize));
+
+ test->registerURISchemeHandler("nomime", kBarHTML, -1, 0);
+ test->m_loadEvents.clear();
+ test->loadURI("nomime:foo bar");
+ test->waitUntilLoadFinished();
+ g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+
+ test->registerURISchemeHandler("empty", 0, 0, "text/html");
+ test->m_loadEvents.clear();
+ test->loadURI("empty:nothing");
+ test->waitUntilLoadFinished();
+ g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+ g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
+}
+
void beforeAll()
{
Test::add("WebKitWebContext", "default-context", testWebContextDefault);
PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins);
+ URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme);
}
void afterAll()
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
index 6ede533d4..646752974 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
@@ -19,6 +19,8 @@
#include "config.h"
#include "WebViewTest.h"
+#include <JavaScriptCore/JSStringRef.h>
+#include <JavaScriptCore/JSValueRef.h>
#include <wtf/HashSet.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/StringHash.h>
@@ -278,15 +280,30 @@ public:
g_main_loop_quit(test->m_mainLoop);
}
+ static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test)
+ {
+ g_assert(WEBKIT_IS_PERMISSION_REQUEST(request));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+
+ if (test->m_allowPermissionRequests)
+ webkit_permission_request_allow(request);
+ else
+ webkit_permission_request_deny(request);
+
+ return TRUE;
+ }
+
UIClientTest()
: m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT)
, m_scriptDialogConfirmed(true)
+ , m_allowPermissionRequests(false)
, m_mouseTargetModifiers(0)
{
webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
g_signal_connect(m_webView, "create", G_CALLBACK(viewCreate), this);
g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this);
g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
+ g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this);
}
~UIClientTest()
@@ -314,6 +331,7 @@ public:
Vector<WebViewEvents> m_webViewEvents;
WebKitScriptDialogType m_scriptDialogType;
bool m_scriptDialogConfirmed;
+ bool m_allowPermissionRequests;
WindowProperties m_windowProperties;
HashSet<WTF::String> m_windowPropertiesChanged;
GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
@@ -399,6 +417,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
" <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
" <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
" <video style='position:absolute; left:1; top:30' width=10 height=10 controls='controls'><source src='movie.ogg' type='video/ogg' /></video>"
+ " <input style='position:absolute; left:1; top:50' size='10'></input>"
"</body></html>";
test->loadHtml(linksHoveredHTML, "file:///");
@@ -409,6 +428,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
@@ -419,6 +439,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
g_assert(!test->m_mouseTargetModifiers);
// Move over image with GDK_CONTROL_MASK.
@@ -426,6 +447,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
@@ -434,6 +456,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
@@ -445,8 +468,53 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult));
g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
g_assert(!test->m_mouseTargetModifiers);
+
+ // Mover over input.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 55);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_editable(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+}
+
+static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+ static const char* geolocationRequestHTML =
+ "<html>"
+ " <script>"
+ " function runTest()"
+ " {"
+ " navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" },"
+ " function(e) { document.title = e.code });"
+ " }"
+ " </script>"
+ " <body onload='runTest();'></body>"
+ "</html>";
+
+ // Test denying a permission request.
+ test->m_allowPermissionRequests = false;
+ test->loadHtml(geolocationRequestHTML, 0);
+ test->waitUntilTitleChanged();
+
+ // According to the Geolocation API specification, '1' is the
+ // error code returned for the PERMISSION_DENIED error.
+ // http://dev.w3.org/geo/api/spec-source.html#position_error_interface
+ const gchar* result = webkit_web_view_get_title(test->m_webView);
+ g_assert_cmpstr(result, ==, "1");
+
+ // Test allowing a permission request.
+ test->m_allowPermissionRequests = true;
+ test->loadHtml(geolocationRequestHTML, 0);
+ test->waitUntilTitleChanged();
+
+ // Check that we did not get the PERMISSION_DENIED error now.
+ result = webkit_web_view_get_title(test->m_webView);
+ g_assert_cmpstr(result, !=, "1");
}
static void testWebViewZoomLevel(WebViewTest* test, gconstpointer)
@@ -730,6 +798,7 @@ void beforeAll()
UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
+ UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests);
WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript);
FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index cc5c349e2..bf37fcb73 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -33,6 +33,7 @@
#include <webkit2/WebKitError.h>
#include <webkit2/WebKitFileChooserRequest.h>
#include <webkit2/WebKitFindController.h>
+#include <webkit2/WebKitGeolocationPermissionRequest.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
#include <webkit2/WebKitMimeInfo.h>
@@ -45,6 +46,8 @@
#include <webkit2/WebKitSettings.h>
#include <webkit2/WebKitURIRequest.h>
#include <webkit2/WebKitURIResponse.h>
+#include <webkit2/WebKitURISchemeRequest.h>
+#include <webkit2/WebKitVersion.h>
#include <webkit2/WebKitWebContext.h>
#include <webkit2/WebKitWebInspector.h>
#include <webkit2/WebKitWebResource.h>