On Mon, 2012-02-13 at 11:12 -0200, Gustavo Noronha Silva wrote:
> +1 on Carlos' API suggestions

Thank you for all the provided feedback (including Martin's here as
well). I have already incorporated all of these suggestions in my local
branch and have filed a new bug to properly tracking work done on this:

https://bugs.webkit.org/show_bug.cgi?id=78491

If everything goes fine, tomorrow I'll work on properly documenting (and
polishing) the code, as well as writing unit tests for this new API,
which at the moment is looking like this:

>From WebKitFileChooserRequest.h:
================================
gboolean
webkit_file_chooser_request_allows_multiple_files(WebKitFileChooserRequest*);

gchar**
webkit_file_chooser_request_accepted_mime_types(WebKitFileChooserRequest*);

GtkFileFilter*
webkit_file_chooser_request_get_file_filter(WebKitFileChooserRequest*);

void
webkit_file_chooser_request_choose_files(WebKitFileChooserRequest*, 
                                         GSList*);
gchar**
webkit_file_chooser_request_selected_files(WebKitFileChooserRequest*);

void
webkit_file_chooser_request_cancel(WebKitFileChooserRequest*);


>From WebKitWebView.h:
=====================

[...]
gboolean (* run_file_chooser) (WebKitWebView            *web_view,
                               WebKitFileChooserRequest *request);
[...]


As you can see I added an _accepted_mime_types() function besides the
one suggested by Carlos (_get_file_filter()), because I thought under
some scenarios it could be interesting to have easy access to the list
of accepted mime types (as in an array of char*), and extracting that
list from a GtkFileFilter instance is not trivial at all.

Again, attaching the new patch together with this mail for you to be
able to take a look if interested, just bear in mind is not a final one
(new functions not even tested, will do while writing the unit tests).

Thanks,
Mario
diff --git a/Source/WebKit2/GNUmakefile.am b/Source/WebKit2/GNUmakefile.am
index 3b8e7bd..cd3a6c4 100644
--- a/Source/WebKit2/GNUmakefile.am
+++ b/Source/WebKit2/GNUmakefile.am
@@ -90,6 +90,7 @@ libwebkit2gtkinclude_HEADERS = \
 	$(WebKit2)/UIProcess/API/gtk/WebKitError.h \
 	$(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \
 	$(WebKit2)/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \
+	$(WebKit2)/UIProcess/API/gtk/WebKitFileChooserRequest.h \
 	$(WebKit2)/UIProcess/API/gtk/WebKitPolicyDecision.h \
 	$(WebKit2)/UIProcess/API/gtk/WebKitResponsePolicyDecision.h \
 	$(WebKit2)/UIProcess/API/gtk/WebKitSettings.h \
@@ -548,6 +549,9 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
 	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/WebKitFileChooserRequest.cpp \
+	Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h \
+	Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h \
 	Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.cpp \
 	Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecision.h \
 	Source/WebKit2/UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h \
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp
new file mode 100644
index 0000000..1f8fd78
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp
@@ -0,0 +1,155 @@
+/*
+ * 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 "WebOpenPanelParameters.h"
+#include "WebKitFileChooserRequest.h"
+#include "WebKitFileChooserRequestPrivate.h"
+#include "WebKitPrivate.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+/**
+ * SECTION: WebKitFileChooserRequest
+ * @Short_description: A request to open a file chooser.
+ * @Title: WebKitFileChooserRequest
+ * @See_also: #WebKitWebView
+ */
+G_DEFINE_TYPE(WebKitFileChooserRequest, webkit_file_chooser_request, G_TYPE_OBJECT)
+
+struct _WebKitFileChooserRequestPrivate {
+    WKRetainPtr<WKOpenPanelParametersRef> wkParameters;
+    WKRetainPtr<WKOpenPanelResultListenerRef> wkListener;
+    gboolean handledRequest;
+};
+
+static void webkit_file_chooser_request_init(WebKitFileChooserRequest* request)
+{
+    request->priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequestPrivate);
+    new (request->priv) WebKitFileChooserRequestPrivate();
+    request->priv->handledRequest = false;
+}
+
+static void webkitFileChooserRequestFinalize(GObject* object)
+{
+    WebKitFileChooserRequest* request = WEBKIT_FILE_CHOOSER_REQUEST(object);
+
+    // Make sure the request is always handled before finalizing.
+    if (!request->priv->handledRequest)
+        webkit_file_chooser_request_cancel(request);
+
+    request->priv->~WebKitFileChooserRequestPrivate();
+    G_OBJECT_CLASS(webkit_file_chooser_request_parent_class)->finalize(object);
+}
+
+static void webkit_file_chooser_request_class_init(WebKitFileChooserRequestClass* requestClass)
+{
+    GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+    objectClass->finalize = webkitFileChooserRequestFinalize;
+    g_type_class_add_private(requestClass, sizeof(WebKitFileChooserRequestPrivate));
+}
+
+WebKitFileChooserRequest* webkitFileChooserRequestCreate(WKOpenPanelParametersRef wkParameters, WKOpenPanelResultListenerRef wkListener)
+{
+    WebKitFileChooserRequest* request = WEBKIT_FILE_CHOOSER_REQUEST(g_object_new(WEBKIT_TYPE_FILE_CHOOSER_REQUEST, NULL));
+    request->priv->wkParameters = wkParameters;
+    request->priv->wkListener = wkListener;
+    return request;
+}
+
+gboolean webkit_file_chooser_request_allows_multiple_files(WebKitFileChooserRequest* request)
+{
+    g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), FALSE);
+    return WKOpenPanelParametersGetAllowsMultipleFiles(request->priv->wkParameters.get());
+}
+
+gchar** webkit_file_chooser_request_accepted_mime_types(WebKitFileChooserRequest* request)
+{
+    g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0);
+    WKRetainPtr<WKArrayRef> wkMimeTypes(WKOpenPanelParametersCopyAcceptedMIMETypes(request->priv->wkParameters.get()));
+
+    size_t numOfMimeTypes = WKArrayGetSize(wkMimeTypes.get());
+    gchar** returnArray = g_new0(gchar*, numOfMimeTypes + 1);
+    for (size_t i = 0; i < numOfMimeTypes; ++i) {
+        WKStringRef wkMimeType = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkMimeTypes.get(), i));
+        String mimeTypeString = toImpl(wkMimeType)->string();
+        if (mimeTypeString.isEmpty())
+            continue;
+
+        returnArray[i] = g_strdup(mimeTypeString.utf8().data());
+    }
+
+    return returnArray;
+}
+
+GtkFileFilter* webkit_file_chooser_request_get_file_filter(WebKitFileChooserRequest* request)
+{
+    g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0);
+
+    gchar** acceptedMimeTypes = webkit_file_chooser_request_accepted_mime_types(request);
+    if (!acceptedMimeTypes || !acceptedMimeTypes[0])
+        return 0;
+
+    GtkFileFilter* returnFilter = gtk_file_filter_new();
+    for (size_t i = 0; acceptedMimeTypes[i]; ++i)
+        gtk_file_filter_add_mime_type (returnFilter, const_cast<gchar*>(acceptedMimeTypes[i]));
+
+    return returnFilter;
+}
+
+void webkit_file_chooser_request_choose_files(WebKitFileChooserRequest* request, GSList* fileURIs)
+{
+    g_return_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request));
+
+    WKRetainPtr<WKMutableArrayRef> wkSelectedURIs(AdoptWK, WKMutableArrayCreate());
+    for (GSList* item = fileURIs ; item ; item = g_slist_next(item)) {
+        if (!item->data)
+            continue;
+        WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKURLCreateWithUTF8CString(static_cast<gchar*>(item->data)));
+        WKArrayAppendItem(wkSelectedURIs.get(), wkURL.get());
+    }
+
+    WKOpenPanelResultListenerChooseFiles(request->priv->wkListener.get(), wkSelectedURIs.get());
+    request->priv->handledRequest = true;
+}
+
+gchar** webkit_file_chooser_request_selected_files(WebKitFileChooserRequest* request)
+{
+    g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0);
+
+    Vector<String> selectedFileNames = toImpl(request->priv->wkParameters.get())->selectedFileNames();
+    size_t numOfFiles = selectedFileNames.size();
+    gchar** returnArray = g_new0(gchar*, numOfFiles + 1);
+    for (size_t i = 0; i < numOfFiles; ++i) {
+        if (selectedFileNames[i].isEmpty())
+            continue;
+
+        returnArray[i] = g_strdup(selectedFileNames[i].utf8().data());
+    }
+
+    return returnArray;
+}
+
+void webkit_file_chooser_request_cancel(WebKitFileChooserRequest* request)
+{
+    g_return_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request));
+    WKOpenPanelResultListenerCancel(request->priv->wkListener.get());
+    request->priv->handledRequest = true;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h
new file mode 100644
index 0000000..2c49ade
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h
@@ -0,0 +1,77 @@
+/*
+ * 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 WebKitFileChooserRequest_h
+#define WebKitFileChooserRequest_h
+
+#include <gtk/gtk.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_FILE_CHOOSER_REQUEST            (webkit_file_chooser_request_get_type())
+#define WEBKIT_FILE_CHOOSER_REQUEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequest))
+#define WEBKIT_FILE_CHOOSER_REQUEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequestClass))
+#define WEBKIT_IS_FILE_CHOOSER_REQUEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FILE_CHOOSER_REQUEST))
+#define WEBKIT_IS_FILE_CHOOSER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_FILE_CHOOSER_REQUEST))
+#define WEBKIT_FILE_CHOOSER_REQUEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_FILE_CHOOSER_REQUEST, WebKitFileChooserRequestClass))
+
+typedef struct _WebKitFileChooserRequest        WebKitFileChooserRequest;
+typedef struct _WebKitFileChooserRequestClass   WebKitFileChooserRequestClass;
+typedef struct _WebKitFileChooserRequestPrivate WebKitFileChooserRequestPrivate;
+
+struct _WebKitFileChooserRequest {
+    GObject parent;
+
+    /*< private >*/
+    WebKitFileChooserRequestPrivate *priv;
+};
+
+struct _WebKitFileChooserRequestClass {
+    GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_file_chooser_request_get_type              (void);
+
+WEBKIT_API gboolean
+webkit_file_chooser_request_allows_multiple_files (WebKitFileChooserRequest*);
+
+WEBKIT_API gchar**
+webkit_file_chooser_request_accepted_mime_types   (WebKitFileChooserRequest*);
+
+WEBKIT_API GtkFileFilter*
+webkit_file_chooser_request_get_file_filter       (WebKitFileChooserRequest*);
+
+WEBKIT_API void
+webkit_file_chooser_request_choose_files          (WebKitFileChooserRequest*, GSList*);
+
+WEBKIT_API gchar**
+webkit_file_chooser_request_selected_files        (WebKitFileChooserRequest*);
+
+WEBKIT_API void
+webkit_file_chooser_request_cancel                (WebKitFileChooserRequest*);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h
new file mode 100644
index 0000000..d86bd50
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.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 WebKitFileChooserRequestPrivate_h
+#define WebKitFileChooserRequestPrivate_h
+
+#include "WebKitFileChooserRequest.h"
+#include <WebKit2/WebKit2.h>
+
+WebKitFileChooserRequest* webkitFileChooserRequestCreate(WKOpenPanelParametersRef, WKOpenPanelResultListenerRef);
+
+#endif // WebKitFileChooserRequestPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
index e76212d..825e4ae 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
@@ -20,12 +20,16 @@
 #include "config.h"
 #include "WebKitUIClient.h"
 
+#include "WebKitFileChooserRequest.h"
+#include "WebKitFileChooserRequestPrivate.h"
 #include "WebKitPrivate.h"
 #include "WebKitWebViewBasePrivate.h"
 #include "WebKitWebViewPrivate.h"
 #include "WebKitWindowPropertiesPrivate.h"
 #include "WebPageProxy.h"
 #include <WebCore/GtkUtilities.h>
+#include <glib/gi18n-lib.h>
+#include <wtf/gobject/GRefPtr.h>
 
 using namespace WebKit;
 
@@ -131,6 +135,12 @@ static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestRe
     webkitWebViewMouseTargetChanged(WEBKIT_WEB_VIEW(clientInfo), hitTestResult, wkEventModifiersToGdkModifiers(modifiers));
 }
 
+static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo)
+{
+    GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(parameters, listener));
+    webkitWebViewMakeFileChooserRequest(WEBKIT_WEB_VIEW(clientInfo), request.get());
+}
+
 void attachUIClientToView(WebKitWebView* webView)
 {
     WKPageUIClient wkUIClient = {
@@ -164,7 +174,7 @@ void attachUIClientToView(WebKitWebView* webView)
         0, // didDraw
         0, // pageDidScroll
         0, // exceededDatabaseQuota
-        0, // runOpenPanel
+        runOpenPanel,
         0, // decidePolicyForGeolocationPermissionRequest
         0, // headerHeight
         0, // footerHeight
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index af79935..108c068 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -59,6 +59,7 @@ enum {
     SCRIPT_PROMPT,
 
     DECIDE_POLICY,
+    RUN_FILE_CHOOSER,
 
     MOUSE_TARGET_CHANGED,
 
@@ -160,6 +161,42 @@ static gboolean webkitWebViewDecidePolicy(WebKitWebView*, WebKitPolicyDecision*
     return TRUE;
 }
 
+static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request)
+{
+    GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request);
+    if (responseID != GTK_RESPONSE_ACCEPT) {
+        webkit_file_chooser_request_cancel(adoptedRequest.get());
+        gtk_widget_destroy(GTK_WIDGET(dialog));
+        return;
+    }
+
+    GOwnPtr<GSList> fileUris (gtk_file_chooser_get_uris(GTK_FILE_CHOOSER(dialog)));
+    webkit_file_chooser_request_choose_files(adoptedRequest.get(), fileUris.get());
+    g_slist_foreach(fileUris.get(), reinterpret_cast<GFunc>(g_free), 0);
+
+    gtk_widget_destroy(GTK_WIDGET(dialog));
+}
+
+static gboolean webkitWebViewRunFileChooser(WebKitWebView* webView, WebKitFileChooserRequest* request)
+{
+    GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webView));
+    if (!widgetIsOnscreenToplevelWindow(toplevel))
+        toplevel = 0;
+
+    GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
+                                                    toplevel ? GTK_WINDOW(toplevel) : 0,
+                                                    GTK_FILE_CHOOSER_ACTION_OPEN,
+                                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+                                                    NULL);
+
+    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), webkit_file_chooser_request_allows_multiple_files(request));
+    g_signal_connect(dialog, "response", G_CALLBACK(fileChooserDialogResponseCallback), g_object_ref(request));
+    gtk_widget_show(dialog);
+
+    return TRUE;
+}
+
 static void webkitWebViewConstructed(GObject* object)
 {
     if (G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed)
@@ -263,6 +300,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
     webViewClass->script_confirm = webkitWebViewScriptConfirm;
     webViewClass->script_prompt = webkitWebViewScriptPrompt;
     webViewClass->decide_policy = webkitWebViewDecidePolicy;
+    webViewClass->run_file_chooser = webkitWebViewRunFileChooser;
 
     g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
 
@@ -622,6 +660,17 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
                      WEBKIT_TYPE_POLICY_DECISION,
                      WEBKIT_TYPE_POLICY_DECISION_TYPE);
 
+    /* TODO: Describe the signal. */
+    signals[RUN_FILE_CHOOSER] =
+        g_signal_new("decide-open-panel",
+                     G_TYPE_FROM_CLASS(webViewClass),
+                     G_SIGNAL_RUN_LAST,
+                     G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser),
+                     g_signal_accumulator_true_handled, 0 /* accumulator data */,
+                     webkit_marshal_BOOLEAN__OBJECT,
+                     G_TYPE_BOOLEAN, 1, /* number of parameters */
+                     WEBKIT_TYPE_FILE_CHOOSER_REQUEST);
+
     /**
      * WebKitWebView::mouse-target-changed:
      * @web_view: the #WebKitWebView on which the signal is emitted
@@ -771,6 +820,12 @@ void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WKHitTestResultRef
     g_signal_emit(webView, signals[MOUSE_TARGET_CHANGED], 0, priv->mouseTargetHitTestResult.get(), modifiers);
 }
 
+void webkitWebViewMakeFileChooserRequest(WebKitWebView* webView, WebKitFileChooserRequest* request)
+{
+    gboolean returnValue;
+    g_signal_emit(webView, signals[RUN_FILE_CHOOSER], 0, request, &returnValue);
+}
+
 /**
  * webkit_web_view_new:
  *
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
index 0081be3..f8cdb95 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -36,6 +36,7 @@
 #include <webkit2/WebKitURIRequest.h>
 #include <webkit2/WebKitWebViewBase.h>
 #include <webkit2/WebKitWindowProperties.h>
+#include <webkit2/WebKitFileChooserRequest.h>
 #include <webkit2/WebKitPolicyDecision.h>
 
 G_BEGIN_DECLS
@@ -140,6 +141,10 @@ struct _WebKitWebViewClass {
     gboolean   (* decide_policy)        (WebKitWebView             *web_view,
                                          WebKitPolicyDecision      *decision,
                                          WebKitPolicyDecisionType  type);
+
+    gboolean   (* run_file_chooser)     (WebKitWebView             *web_view,
+                                         WebKitFileChooserRequest  *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 768a620..b316d1c 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -43,6 +43,7 @@ void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message);
 bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message);
 WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText);
 void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*);
+void webkitWebViewMakeFileChooserRequest(WebKitWebView*, WebKitFileChooserRequest*);
 void webkitWebViewMouseTargetChanged(WebKitWebView*, WKHitTestResultRef, unsigned modifiers);
 
 #endif // WebKitWebViewPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index 3af9904..de03098 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -30,13 +30,14 @@
 #include <webkit2/WebKitEditingCommands.h>
 #include <webkit2/WebKitEnumTypes.h>
 #include <webkit2/WebKitError.h>
+#include <webkit2/WebKitFileChooserRequest.h>
 #include <webkit2/WebKitHitTestResult.h>
 #include <webkit2/WebKitSettings.h>
 #include <webkit2/WebKitURIRequest.h>
 #include <webkit2/WebKitURIResponse.h>
 #include <webkit2/WebKitWebContext.h>
-#include <webkit2/WebKitWebViewBase.h>
 #include <webkit2/WebKitWebView.h>
+#include <webkit2/WebKitWebViewBase.h>
 #include <webkit2/WebKitWindowProperties.h>
 
 #undef __WEBKIT2_H_INSIDE__
_______________________________________________
webkit-gtk mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-gtk

Reply via email to