summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp72
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h58
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp78
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h3
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml1
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt17
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h1
8 files changed, 231 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp
new file mode 100644
index 000000000..92235cef1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp
@@ -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);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h
new file mode 100644
index 000000000..a62f1f1a5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h
@@ -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
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index 65dab6ec2..77ef6c1de 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -65,6 +65,7 @@ enum {
SCRIPT_DIALOG,
DECIDE_POLICY,
+ PERMISSION_REQUEST,
MOUSE_TARGET_CHANGED,
@@ -195,6 +196,12 @@ static gboolean webkitWebViewDecidePolicy(WebKitWebView*, WebKitPolicyDecision*
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 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
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 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
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 @@ void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisio
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;
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
index 4f5fe1869..7f9fb9e36 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -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 @@ struct _WebKitWebViewClass {
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);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
index 717d2c344..6ab374551 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -42,6 +42,7 @@ void webkitWebViewClosePage(WebKitWebView*);
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);
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
index b6b9aa0b1..90005acb2 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -21,6 +21,7 @@
<xi:include href="xml/WebKitURIResponse.xml"/>
<xi:include href="xml/WebKitWindowProperties.xml"/>
<xi:include href="xml/WebKitDownload.xml"/>
+ <xi:include href="xml/WebKitPermissionRequest.xml"/>
<xi:include href="xml/WebKitPolicyDecision.xml"/>
<xi:include href="xml/WebKitNavigationPolicyDecision.xml"/>
<xi:include href="xml/WebKitResponsePolicyDecision.xml"/>
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
index 05bdeeb51..4251cc4a6 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -368,6 +368,23 @@ webkit_download_get_type
</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
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index 23dbd9903..b58210a80 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -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>