Diff
Modified: trunk/Source/WebKit2/ChangeLog (118521 => 118522)
--- trunk/Source/WebKit2/ChangeLog 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/ChangeLog 2012-05-25 13:45:26 UTC (rev 118522)
@@ -1,3 +1,46 @@
+2012-05-25 Mario Sanchez Prada <[email protected]>
+
+ [GTK][WK2] Implement API for generic permission requests
+ https://bugs.webkit.org/show_bug.cgi?id=84018
+
+ Reviewed by Martin Robinson.
+
+ Added new 'permission-request' signal to WebKitWebView, to be
+ fired when WebKit needs confirmation from the user on whether to
+ allow or deny certain operations, such as sharing the user's
+ location with web site through the Geolocation API.
+
+ New WebKitPermissionRequest interface, providing allow() and
+ deny() operations, to be called over the objects implementing it
+ when emitted along with the new 'permission-request' signal.
+
+ * UIProcess/API/gtk/WebKitPermissionRequest.cpp: Added.
+ (webkit_permission_request_default_init):
+ (webkit_permission_request_allow):
+ (webkit_permission_request_deny):
+ * UIProcess/API/gtk/WebKitPermissionRequest.h: Added.
+ (_WebKitPermissionRequestIface):
+ * GNUmakefile.am: Added new files.
+
+ Added the new signal to WebKitWebView, providing a default handler
+ that will just deny the request when the signal is not handled.
+
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewDecidePermissionRequest): Default handler.
+ (webkit_web_view_class_init): Declare the new signal and connect
+ to the default handler.
+ (webkitWebViewMakePermissionRequest): Helper function to create a
+ make a new permission request and emit the new signal signal.
+ * UIProcess/API/gtk/WebKitWebView.h:
+ (_WebKitWebViewClass):
+ * UIProcess/API/gtk/WebKitWebViewPrivate.h: Declare the creational
+ function webkitWebViewMakePermissionRequest for internal use only.
+
+ Updated documentation files.
+
+ * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
+
2012-05-25 Grzegorz Czajkowski <[email protected]>
[WK2] Fix client interface size for WKPageContextMenuClient.
Modified: trunk/Source/WebKit2/GNUmakefile.list.am (118521 => 118522)
--- trunk/Source/WebKit2/GNUmakefile.list.am 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/GNUmakefile.list.am 2012-05-25 13:45:26 UTC (rev 118522)
@@ -99,6 +99,7 @@
$(WebKit2)/UIProcess/API/gtk/WebKitJavascriptResult.h \
$(WebKit2)/UIProcess/API/gtk/WebKitMimeInfo.h \
$(WebKit2)/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \
+ $(WebKit2)/UIProcess/API/gtk/WebKitPermissionRequest.h \
$(WebKit2)/UIProcess/API/gtk/WebKitPlugin.h \
$(WebKit2)/UIProcess/API/gtk/WebKitPolicyDecision.h \
$(WebKit2)/UIProcess/API/gtk/WebKitPrintOperation.h \
@@ -596,6 +597,8 @@
Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp \
Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \
Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecisionPrivate.h \
+ Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp \
+ Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h \
Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.cpp \
Source/WebKit2/UIProcess/API/gtk/WebKitPlugin.h \
Source/WebKit2/UIProcess/API/gtk/WebKitPluginPrivate.h \
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp (0 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp 2012-05-25 13:45:26 UTC (rev 118522)
@@ -0,0 +1,72 @@
+/*
+ * 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 "WebKitPermissionRequest.h"
+
+/**
+ * SECTION: WebKitPermissionRequest
+ * @Short_description: A permission request
+ * @Title: WebKitPermissionRequest
+ * @See_also: #WebKitWebView
+ *
+ * There are situations where an embedder would need to ask the user
+ * for permission to do certain types of operations, such as switching
+ * to fullscreen mode or reporting the user's location through the
+ * standard Geolocation API. In those cases, WebKit will emit a
+ * #WebKitWebView::permission-request signal with a
+ * #WebKitPermissionRequest object attached to it.
+ */
+
+typedef WebKitPermissionRequestIface WebKitPermissionRequestInterface;
+G_DEFINE_INTERFACE(WebKitPermissionRequest, webkit_permission_request, G_TYPE_OBJECT)
+
+static void webkit_permission_request_default_init(WebKitPermissionRequestIface*)
+{
+}
+
+/**
+ * webkit_permission_request_allow:
+ * @request: a #WebKitPermissionRequest
+ *
+ * Allow the action which triggered this request.
+ */
+void webkit_permission_request_allow(WebKitPermissionRequest* request)
+{
+ g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request));
+
+ WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request);
+ if (iface->allow)
+ iface->allow(request);
+}
+
+/**
+ * webkit_permission_request_deny:
+ * @request: a #WebKitPermissionRequest
+ *
+ * Deny the action which triggered this request.
+ */
+void webkit_permission_request_deny(WebKitPermissionRequest* request)
+{
+ g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request));
+
+ WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request);
+ if (iface->deny)
+ iface->deny(request);
+}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h (0 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h 2012-05-25 13:45:26 UTC (rev 118522)
@@ -0,0 +1,58 @@
+/*
+ * 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 WebKitPermissionRequest_h
+#define WebKitPermissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_PERMISSION_REQUEST (webkit_permission_request_get_type())
+#define WEBKIT_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PERMISSION_REQUEST, WebKitPermissionRequest))
+#define WEBKIT_IS_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PERMISSION_REQUEST))
+#define WEBKIT_PERMISSION_REQUEST_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), WEBKIT_TYPE_PERMISSION_REQUEST, WebKitPermissionRequestIface))
+
+typedef struct _WebKitPermissionRequest WebKitPermissionRequest;
+typedef struct _WebKitPermissionRequestIface WebKitPermissionRequestIface;
+
+struct _WebKitPermissionRequestIface {
+ GTypeInterface parent_interface;
+
+ void (* allow) (WebKitPermissionRequest *request);
+ void (* deny) (WebKitPermissionRequest *request);
+};
+
+WEBKIT_API GType
+webkit_permission_request_get_type (void);
+
+WEBKIT_API void
+webkit_permission_request_allow (WebKitPermissionRequest *request);
+
+WEBKIT_API void
+webkit_permission_request_deny (WebKitPermissionRequest *request);
+
+G_END_DECLS
+
+#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (118521 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-05-25 13:45:26 UTC (rev 118522)
@@ -65,6 +65,7 @@
SCRIPT_DIALOG,
DECIDE_POLICY,
+ PERMISSION_REQUEST,
MOUSE_TARGET_CHANGED,
@@ -195,6 +196,12 @@
return TRUE;
}
+static gboolean webkitWebViewPermissionRequest(WebKitWebView*, WebKitPermissionRequest* request)
+{
+ webkit_permission_request_deny(request);
+ return TRUE;
+}
+
static void zoomTextOnlyChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
{
WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
@@ -361,6 +368,7 @@
webViewClass->create = webkitWebViewCreate;
webViewClass->script_dialog = webkitWebViewScriptDialog;
webViewClass->decide_policy = webkitWebViewDecidePolicy;
+ webViewClass->permission_request = webkitWebViewPermissionRequest;
webViewClass->run_file_chooser = webkitWebViewRunFileChooser;
g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
@@ -687,6 +695,70 @@
WEBKIT_TYPE_POLICY_DECISION_TYPE);
/**
+ * WebKitWebView::permission-request:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @request: the #WebKitPermissionRequest
+ *
+ * This signal is emitted when WebKit is requesting the client to
+ * decide about a permission request, such as allowing the browser
+ * to switch to fullscreen mode, sharing its location or similar
+ * operations.
+ *
+ * A possible way to use this signal could be through a dialog
+ * allowing the user decide what to do with the request:
+ *
+ * <informalexample><programlisting>
+ * static gboolean permission_request_cb (WebKitWebView *web_view,
+ * WebKitPermissionRequest *request,
+ * GtkWindow *parent_window)
+ * {
+ * GtkWidget *dialog = gtk_message_dialog_new (parent_window,
+ * GTK_DIALOG_MODAL,
+ * GTK_MESSAGE_QUESTION,
+ * GTK_BUTTONS_YES_NO,
+ * "Allow Permission Request?");
+ * gtk_widget_show (dialog);
+ * gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+ *
+ * switch (result) {
+ * case GTK_RESPONSE_YES:
+ * webkit_permission_request_allow (request);
+ * break;
+ * default:
+ * webkit_permission_request_deny (request);
+ * break;
+ * }
+ * gtk_widget_destroy (dialog);
+ *
+ * return TRUE;
+ * }
+ * </programlisting></informalexample>
+ *
+ * It is possible to handle permission requests asynchronously, by
+ * simply calling g_object_ref() on the @request argument and
+ * returning %TRUE to block the default signal handler. If the
+ * last reference is removed on a #WebKitPermissionRequest and the
+ * request has not been handled, webkit_permission_request_deny()
+ * will be the default action.
+ *
+ * By default, if the signal is not handled,
+ * webkit_permission_request_deny() will be called over the
+ * #WebKitPermissionRequest.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ *
+ */
+ signals[PERMISSION_REQUEST] =
+ g_signal_new("permission-request",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, permission_request),
+ g_signal_accumulator_true_handled, 0 /* accumulator data */,
+ webkit_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1, /* number of parameters */
+ WEBKIT_TYPE_PERMISSION_REQUEST);
+ /**
* WebKitWebView::mouse-target-changed:
* @web_view: the #WebKitWebView on which the signal is emitted
* @hit_test_result: a #WebKitHitTestResult
@@ -971,6 +1043,12 @@
g_signal_emit(webView, signals[DECIDE_POLICY], 0, decision, type, &returnValue);
}
+void webkitWebViewMakePermissionRequest(WebKitWebView* webView, WebKitPermissionRequest* request)
+{
+ gboolean returnValue;
+ g_signal_emit(webView, signals[PERMISSION_REQUEST], 0, request, &returnValue);
+}
+
void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WKHitTestResultRef wkHitTestResult, unsigned modifiers)
{
WebKitWebViewPrivate* priv = webView->priv;
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (118521 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2012-05-25 13:45:26 UTC (rev 118522)
@@ -35,6 +35,7 @@
#include <webkit2/WebKitFindController.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
+#include <webkit2/WebKitPermissionRequest.h>
#include <webkit2/WebKitPolicyDecision.h>
#include <webkit2/WebKitScriptDialog.h>
#include <webkit2/WebKitSettings.h>
@@ -143,6 +144,8 @@
gboolean (* decide_policy) (WebKitWebView *web_view,
WebKitPolicyDecision *decision,
WebKitPolicyDecisionType type);
+ gboolean (* permission_request) (WebKitWebView *web_view,
+ WebKitPermissionRequest *permission_request);
void (* mouse_target_changed) (WebKitWebView *web_view,
WebKitHitTestResult *hit_test_result,
guint modifiers);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (118521 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2012-05-25 13:45:26 UTC (rev 118522)
@@ -42,6 +42,7 @@
void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message);
bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message);
WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText);
+void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*);
void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*);
void webkitWebViewMouseTargetChanged(WebKitWebView*, WKHitTestResultRef, unsigned modifiers);
void webkitWebViewPrintFrame(WebKitWebView*, WKFrameRef);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (118521 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2012-05-25 13:45:26 UTC (rev 118522)
@@ -21,6 +21,7 @@
<xi:include href=""
<xi:include href=""
<xi:include href=""
+ <xi:include href=""
<xi:include href=""
<xi:include href=""
<xi:include href=""
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (118521 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2012-05-25 13:45:26 UTC (rev 118522)
@@ -368,6 +368,23 @@
</SECTION>
<SECTION>
+<FILE>WebKitPermissionRequest</FILE>
+WebKitPermissionRequest
+webkit_permission_request_allow
+webkit_permission_request_deny
+
+<SUBSECTION Standard>
+WebKitPermissionRequestIface
+WEBKIT_TYPE_PERMISSION_REQUEST
+WEBKIT_PERMISSION_REQUEST
+WEBKIT_IS_PERMISSION_REQUEST
+WEBKIT_PERMISSION_REQUEST_GET_IFACE
+
+<SUBSECTION Private>
+webkit_permission_request_get_type
+</SECTION>
+
+<SECTION>
<FILE>WebKitPolicyDecision</FILE>
WebKitPolicyDecision
webkit_policy_decision_download
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h (118521 => 118522)
--- trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h 2012-05-25 13:42:41 UTC (rev 118521)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h 2012-05-25 13:45:26 UTC (rev 118522)
@@ -36,6 +36,7 @@
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
#include <webkit2/WebKitMimeInfo.h>
+#include <webkit2/WebKitPermissionRequest.h>
#include <webkit2/WebKitPlugin.h>
#include <webkit2/WebKitPrintOperation.h>
#include <webkit2/WebKitScriptDialog.h>