Diff
Modified: trunk/Source/WebKit2/ChangeLog (133056 => 133057)
--- trunk/Source/WebKit2/ChangeLog 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-31 19:17:16 UTC (rev 133057)
@@ -1,3 +1,54 @@
+2012-10-31 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Add Ewk_File_Chooser_Request API
+ https://bugs.webkit.org/show_bug.cgi?id=100818
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Add Ewk_File_Chooser_Request API so that the client
+ can handle file chooser requests (e.g. Show a file
+ picker dialog) when the user clicks on an input
+ element of type "file".
+
+ * PlatformEfl.cmake:
+ * UIProcess/API/efl/EWebKit2.h:
+ * UIProcess/API/efl/EwkViewCallbacks.h:
+ (EwkViewCallbacks):
+ * UIProcess/API/efl/ewk_file_chooser_request.cpp: Added.
+ (Ewk_File_Chooser_Request::Ewk_File_Chooser_Request):
+ (Ewk_File_Chooser_Request::~Ewk_File_Chooser_Request):
+ (Ewk_File_Chooser_Request::allowMultipleFiles):
+ (Ewk_File_Chooser_Request::acceptedMIMETypes):
+ (Ewk_File_Chooser_Request::cancel):
+ (Ewk_File_Chooser_Request::chooseFiles):
+ (ewk_file_chooser_request_ref):
+ (ewk_file_chooser_request_unref):
+ (ewk_file_chooser_request_allow_multiple_files_get):
+ (ewk_file_chooser_request_accepted_mimetypes_get):
+ (ewk_file_chooser_request_cancel):
+ (ewk_file_chooser_request_files_choose):
+ (ewk_file_chooser_request_file_choose):
+ * UIProcess/API/efl/ewk_file_chooser_request.h: Added.
+ * UIProcess/API/efl/ewk_file_chooser_request_private.h: Added.
+ (WebKit):
+ (Ewk_File_Chooser_Request):
+ (Ewk_File_Chooser_Request::create):
+ (Ewk_File_Chooser_Request::wasHandled):
+ * UIProcess/API/efl/ewk_view.h:
+ * UIProcess/API/efl/tests/resources/file_chooser.html: Added.
+ * UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp: Added corresponding
+ unit tests.
+ (onFileChooserRequest):
+ (compareStrings):
+ (freeStringList):
+ (TEST_F):
+ * UIProcess/efl/PageUIClientEfl.cpp:
+ (WebKit::PageUIClientEfl::runOpenPanel):
+ (WebKit):
+ (WebKit::PageUIClientEfl::PageUIClientEfl):
+ * UIProcess/efl/PageUIClientEfl.h:
+ (PageUIClientEfl):
+
2012-10-31 Noam Rosenthal <[email protected]>
[Texmap] Enable filter animations in GraphicsLayerAnimation
Modified: trunk/Source/WebKit2/PlatformEfl.cmake (133056 => 133057)
--- trunk/Source/WebKit2/PlatformEfl.cmake 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/PlatformEfl.cmake 2012-10-31 19:17:16 UTC (rev 133057)
@@ -52,6 +52,7 @@
UIProcess/API/efl/ewk_download_job.cpp
UIProcess/API/efl/ewk_error.cpp
UIProcess/API/efl/ewk_favicon_database.cpp
+ UIProcess/API/efl/ewk_file_chooser_request.cpp
UIProcess/API/efl/ewk_form_submission_request.cpp
UIProcess/API/efl/ewk_intent.cpp
UIProcess/API/efl/ewk_intent_service.cpp
@@ -249,6 +250,7 @@
"${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_download_job.h"
"${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_error.h"
"${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_favicon_database.h"
+ "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_file_chooser_request.h"
"${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_form_submission_request.h"
"${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_intent.h"
"${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_intent_service.h"
@@ -351,6 +353,7 @@
test_ewk2_download_job
test_ewk2_eina_shared_string
test_ewk2_favicon_database
+ test_ewk2_file_chooser_request
test_ewk2_refptr_evas_object
test_ewk2_intents
test_ewk2_popup_menu
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h (133056 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h 2012-10-31 19:17:16 UTC (rev 133057)
@@ -36,6 +36,7 @@
#include "ewk_download_job.h"
#include "ewk_error.h"
#include "ewk_favicon_database.h"
+#include "ewk_file_chooser_request.h"
#include "ewk_form_submission_request.h"
#include "ewk_intent.h"
#include "ewk_intent_service.h"
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h (133056 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h 2012-10-31 19:17:16 UTC (rev 133057)
@@ -33,6 +33,7 @@
struct Ewk_Download_Job;
struct Ewk_Download_Job_Error;
+struct Ewk_File_Chooser_Request;
struct Ewk_Form_Submission_Request;
struct Ewk_Error;
struct Ewk_Resource_Request;
@@ -55,6 +56,7 @@
DownloadJobFailed,
DownloadJobFinished,
DownloadJobRequested,
+ FileChooserRequest,
NewFormSubmissionRequest,
LoadError,
LoadFinished,
@@ -149,6 +151,7 @@
DECLARE_EWK_VIEW_CALLBACK(DownloadJobFailed, "download,failed", Ewk_Download_Job_Error);
DECLARE_EWK_VIEW_CALLBACK(DownloadJobFinished, "download,finished", Ewk_Download_Job);
DECLARE_EWK_VIEW_CALLBACK(DownloadJobRequested, "download,request", Ewk_Download_Job);
+DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request);
DECLARE_EWK_VIEW_CALLBACK(NewFormSubmissionRequest, "form,submission,request", Ewk_Form_Submission_Request);
DECLARE_EWK_VIEW_CALLBACK(LoadError, "load,error", Ewk_Error);
DECLARE_EWK_VIEW_CALLBACK(LoadFinished, "load,finished", void);
Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.cpp (0 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.cpp 2012-10-31 19:17:16 UTC (rev 133057)
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * 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 "ewk_file_chooser_request.h"
+
+#include "ImmutableArray.h"
+#include "MutableArray.h"
+#include "WebOpenPanelParameters.h"
+#include "WebOpenPanelResultListenerProxy.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "ewk_file_chooser_request_private.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+Ewk_File_Chooser_Request::Ewk_File_Chooser_Request(WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
+ : m_parameters(parameters)
+ , m_listener(listener)
+ , m_wasRequestHandled(false)
+{
+ ASSERT(parameters);
+ ASSERT(listener);
+}
+
+Ewk_File_Chooser_Request::~Ewk_File_Chooser_Request()
+{
+ if (!m_wasRequestHandled)
+ m_listener->cancel();
+}
+
+bool Ewk_File_Chooser_Request::allowMultipleFiles() const
+{
+ return m_parameters->allowMultipleFiles();
+}
+
+PassRefPtr<ImmutableArray> Ewk_File_Chooser_Request::acceptedMIMETypes() const
+{
+ return m_parameters->acceptMIMETypes();
+}
+
+void Ewk_File_Chooser_Request::cancel()
+{
+ m_wasRequestHandled = true;
+
+ return m_listener->cancel();
+}
+
+void Ewk_File_Chooser_Request::chooseFiles(Vector< RefPtr<APIObject> >& fileURLs)
+{
+ ASSERT(!fileURLs.isEmpty());
+ ASSERT(fileURLs.size() == 1 || m_parameters->allowMultipleFiles());
+
+ m_wasRequestHandled = true;
+ m_listener->chooseFiles(ImmutableArray::adopt(fileURLs).get());
+}
+
+Ewk_File_Chooser_Request* ewk_file_chooser_request_ref(Ewk_File_Chooser_Request* request)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0);
+
+ request->ref();
+
+ return request;
+}
+
+void ewk_file_chooser_request_unref(Ewk_File_Chooser_Request* request)
+{
+ EINA_SAFETY_ON_NULL_RETURN(request);
+
+ request->deref();
+}
+
+Eina_Bool ewk_file_chooser_request_allow_multiple_files_get(const Ewk_File_Chooser_Request* request)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(request, false);
+
+ return request->allowMultipleFiles();
+}
+
+Eina_List* ewk_file_chooser_request_accepted_mimetypes_get(const Ewk_File_Chooser_Request* request)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0);
+
+ Eina_List* mimeTypeList = 0;
+ RefPtr<ImmutableArray> mimeTypes = request->acceptedMIMETypes();
+
+ const size_t size = mimeTypes->size();
+ for (size_t i = 0; i < size; ++i) {
+ String mimeTypeString = static_cast<WebString*>(mimeTypes->at(i))->string();
+ if (mimeTypeString.isEmpty())
+ continue;
+ mimeTypeList = eina_list_append(mimeTypeList, eina_stringshare_add(mimeTypeString.utf8().data()));
+ }
+
+ return mimeTypeList;
+}
+
+Eina_Bool ewk_file_chooser_request_cancel(Ewk_File_Chooser_Request* request)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(request, false);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(request->wasHandled(), false);
+
+ request->cancel();
+
+ return true;
+}
+
+Eina_Bool ewk_file_chooser_request_files_choose(Ewk_File_Chooser_Request* request, const Eina_List* chosenFiles)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(request, false);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(chosenFiles, false);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_list_count(chosenFiles) == 1 || request->allowMultipleFiles(), false);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(request->wasHandled(), false);
+
+ Vector< RefPtr<APIObject> > fileURLs;
+
+ const Eina_List* l;
+ void* data;
+ EINA_LIST_FOREACH(chosenFiles, l, data) {
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, false);
+ String fileURL = "file://" + String::fromUTF8(static_cast<char*>(data));
+ fileURLs.append(WebURL::create(fileURL));
+ }
+
+ request->chooseFiles(fileURLs);
+
+ return true;
+}
+
+Eina_Bool ewk_file_chooser_request_file_choose(Ewk_File_Chooser_Request* request, const char* chosenFile)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(request, false);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(chosenFile, false);
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(request->wasHandled(), false);
+
+ Vector< RefPtr<APIObject> > fileURLs;
+ String fileURL = "file://" + String::fromUTF8(chosenFile);
+ fileURLs.append(WebURL::create(fileURL));
+
+ request->chooseFiles(fileURLs);
+
+ return true;
+}
Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.h (0 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.h 2012-10-31 19:17:16 UTC (rev 133057)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ewk_file_chooser_request.h
+ * @brief Describes the Ewk File Chooser API.
+ */
+
+#ifndef ewk_file_chooser_request_h
+#define ewk_file_chooser_request_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for Ewk_File_Chooser_Request */
+typedef struct Ewk_File_Chooser_Request Ewk_File_Chooser_Request;
+
+/**
+ * Increases the reference count of the given object.
+ *
+ * @param request the request object to increase the reference count
+ *
+ * @return a pointer to the object on success, @c NULL otherwise
+ */
+EAPI Ewk_File_Chooser_Request *ewk_file_chooser_request_ref(Ewk_File_Chooser_Request *request);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count reaches 0, the file chooser request is freed. The request
+ * will be cancelled by default if the client did not act on it.
+ *
+ * @param request the request object to decrease the reference count
+ */
+EAPI void ewk_file_chooser_request_unref(Ewk_File_Chooser_Request *request);
+
+/**
+ * Queries if it is allowed to select multiple files or not.
+ *
+ * @param request request object to query
+ *
+ * @return @c EINA_TRUE if it is allowed to select multiple files,
+ * @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_file_chooser_request_allow_multiple_files_get(const Ewk_File_Chooser_Request *request);
+
+/**
+ * Queries the list of accepted MIME types.
+ *
+ * Possible MIME types are:
+ * - "audio\/\*": All sound files are accepted
+ * - "video\/\*": All video files are accepted
+ * - "image\/\*": All image files are accepted
+ * - standard IANA MIME type (see http://www.iana.org/assignments/media-types/ for a complete list)
+ *
+ * @param request request object to query
+ *
+ * @return The list of accepted MIME types. The list items are guaranteed to be stringshared.
+ * The caller needs to free the list and its items after use
+ */
+EAPI Eina_List *ewk_file_chooser_request_accepted_mimetypes_get(const Ewk_File_Chooser_Request *request);
+
+/**
+ * Cancels the file chooser request.
+ *
+ * @param request request object to cancel
+ *
+ * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_file_chooser_request_cancel(Ewk_File_Chooser_Request *request);
+
+/**
+ * Sets the files chosen by the user.
+ *
+ * @param request request object to update
+ *
+ * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
+ *
+ * @see ewk_file_chooser_request_file_choose()
+ */
+EAPI Eina_Bool ewk_file_chooser_request_files_choose(Ewk_File_Chooser_Request *request, const Eina_List *chosen_files);
+
+/**
+ * Sets the file chosen by the user.
+ *
+ * This is a convenience function in case only one file needs to be set.
+ *
+ * @param request request object to update
+ *
+ * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
+ *
+ * @see ewk_file_chooser_request_files_choose()
+ */
+EAPI Eina_Bool ewk_file_chooser_request_file_choose(Ewk_File_Chooser_Request *request, const char *chosen_file);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ewk_file_chooser_request_h */
Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request_private.h (0 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request_private.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request_private.h 2012-10-31 19:17:16 UTC (rev 133057)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef ewk_file_chooser_request_private_h
+#define ewk_file_chooser_request_private_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+class ImmutableArray;
+class WebOpenPanelParameters;
+class WebOpenPanelResultListenerProxy;
+}
+
+class Ewk_File_Chooser_Request : public RefCounted<Ewk_File_Chooser_Request> {
+public:
+ static PassRefPtr<Ewk_File_Chooser_Request> create(WebKit::WebOpenPanelParameters* parameters, WebKit::WebOpenPanelResultListenerProxy* listener)
+ {
+ return adoptRef(new Ewk_File_Chooser_Request(parameters, listener));
+ }
+
+ ~Ewk_File_Chooser_Request();
+
+ bool allowMultipleFiles() const;
+ PassRefPtr<WebKit::ImmutableArray> acceptedMIMETypes() const;
+ inline bool wasHandled() const { return m_wasRequestHandled; }
+ void cancel();
+ void chooseFiles(Vector< RefPtr<WebKit::APIObject> >& fileURLs);
+
+private:
+ Ewk_File_Chooser_Request(WebKit::WebOpenPanelParameters* parameters, WebKit::WebOpenPanelResultListenerProxy* listener);
+
+ RefPtr<WebKit::WebOpenPanelParameters> m_parameters;
+ RefPtr<WebKit::WebOpenPanelResultListenerProxy> m_listener;
+ bool m_wasRequestHandled;
+};
+
+#endif // ewk_file_chooser_request_private_h
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (133056 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-10-31 19:17:16 UTC (rev 133057)
@@ -34,6 +34,9 @@
* - "download,finished", Ewk_Download_Job*: reports that a download completed successfully.
* - "download,request", Ewk_Download_Job*: reports that a new download has been requested. The client should set the
* destination path by calling ewk_download_job_destination_set() or the download will fail.
+ * - "file,chooser,request", Ewk_File_Chooser_Request*: reports that a request has been made for the user to choose
+ * a file (or several) on the file system. Call ewk_file_chooser_request_ref() on the request object to process it
+ * asynchronously.
* - "form,submission,request", Ewk_Form_Submission_Request*: Reports that a form request is about to be submitted.
* The Ewk_Form_Submission_Request passed contains information about the text fields of the form. This
* is typically used to store login information that can be used later to pre-fill the form.
Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/resources/file_chooser.html (0 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/resources/file_chooser.html (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/resources/file_chooser.html 2012-10-31 19:17:16 UTC (rev 133057)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<title>File chooser test</title>
+<script>
+function updateTitle()
+{
+ var myinput = document.getElementById('myInput');
+ var title = ""
+ for (var i = 0; i < myinput.files.length; i++) {
+ title += myinput.files[i].name;
+ if (i < (myinput.files.length - 1))
+ title += "|";
+ }
+ document.title = title;
+}
+</script>
+</head>
+<body>
+<input type="file" id="myInput" name="Upload media" accept="image/*,video/*" multiple="multiple" _onchange_="updateTitle()" style="top: 10; left: 10;"/>
+</body>
+</html>
Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp (0 => 133057)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp 2012-10-31 19:17:16 UTC (rev 133057)
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * 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 "UnitTestUtils/EWK2UnitTestBase.h"
+#include "UnitTestUtils/EWK2UnitTestEnvironment.h"
+#include "UnitTestUtils/EWK2UnitTestServer.h"
+#include <EWebKit2.h>
+#include <Ecore.h>
+
+using namespace EWK2UnitTest;
+
+extern EWK2UnitTestEnvironment* environment;
+
+static void onFileChooserRequest(void* userData, Evas_Object*, void* eventInfo)
+{
+ Ewk_File_Chooser_Request** returnRequest = static_cast<Ewk_File_Chooser_Request**>(userData);
+ ASSERT_TRUE(returnRequest);
+ Ewk_File_Chooser_Request* request = static_cast<Ewk_File_Chooser_Request*>(eventInfo);
+ ASSERT_TRUE(request);
+
+ // Ref the request to process asynchronously.
+ *returnRequest = ewk_file_chooser_request_ref(request);
+}
+
+static int compareStrings(const void* string1, const void* string2)
+{
+ ASSERT(string1);
+ ASSERT(string2);
+
+ return strcmp(static_cast<const char*>(string1), static_cast<const char*>(string2));
+}
+
+static void freeStringList(Eina_List** list)
+{
+ void* data;
+ EINA_LIST_FREE(*list, data) {
+ eina_stringshare_del(static_cast<char*>(data));
+ }
+}
+
+TEST_F(EWK2UnitTestBase, ewk_file_chooser_request_files_choose)
+{
+ Ewk_File_Chooser_Request* request = 0;
+ evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request);
+ ASSERT_TRUE(loadUrlSync(environment->urlForResource("file_chooser.html").data()));
+
+ // Click on the file input.
+ mouseClick(15, 15);
+
+ // Wait for the file chooser request.
+ while (!request)
+ ecore_main_loop_iterate();
+
+ evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest);
+ ASSERT_TRUE(request);
+ // Validate file chooser request.
+ EXPECT_TRUE(ewk_file_chooser_request_allow_multiple_files_get(request));
+ Eina_List* mimeTypes = ewk_file_chooser_request_accepted_mimetypes_get(request);
+ mimeTypes = eina_list_sort(mimeTypes, eina_list_count(mimeTypes), compareStrings);
+
+ ASSERT_EQ(2, eina_list_count(mimeTypes));
+ EXPECT_STREQ("image/*", static_cast<char*>(eina_list_nth(mimeTypes, 0)));
+ EXPECT_STREQ("video/*", static_cast<char*>(eina_list_nth(mimeTypes, 1)));
+ freeStringList(&mimeTypes);
+
+ ASSERT_FALSE(ewk_file_chooser_request_files_choose(request, 0));
+ Eina_List* files = 0;
+ files = eina_list_append(files, eina_stringshare_add("/tmp/file1.png"));
+ files = eina_list_append(files, eina_stringshare_add("/tmp/file2.png"));
+ ASSERT_TRUE(ewk_file_chooser_request_files_choose(request, files));
+ ASSERT_FALSE(ewk_file_chooser_request_files_choose(request, files));
+ freeStringList(&files);
+
+ ewk_file_chooser_request_unref(request);
+
+ // Check that the JS side received the files.
+ EXPECT_TRUE(waitUntilTitleChangedTo("file1.png|file2.png"));
+}
+
+TEST_F(EWK2UnitTestBase, ewk_file_chooser_request_file_choose)
+{
+ Ewk_File_Chooser_Request* request = 0;
+ evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request);
+ ASSERT_TRUE(loadUrlSync(environment->urlForResource("file_chooser.html").data()));
+
+ // Click on the file input.
+ mouseClick(15, 15);
+
+ // Wait for the file chooser request.
+ while (!request)
+ ecore_main_loop_iterate();
+
+ evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest);
+ ASSERT_TRUE(request);
+
+ ASSERT_FALSE(ewk_file_chooser_request_file_choose(request, 0));
+ ASSERT_TRUE(ewk_file_chooser_request_file_choose(request, "/tmp/file3.png"));
+ ASSERT_FALSE(ewk_file_chooser_request_file_choose(request, "/tmp/file3.png"));
+
+ ewk_file_chooser_request_unref(request);
+
+ // Check that the JS side received the file.
+ EXPECT_TRUE(waitUntilTitleChangedTo("file3.png"));
+}
+
+TEST_F(EWK2UnitTestBase, ewk_file_chooser_request_file_cancel)
+{
+ Ewk_File_Chooser_Request* request = 0;
+ evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request);
+ ASSERT_TRUE(loadUrlSync(environment->urlForResource("file_chooser.html").data()));
+
+ // Click on the file input.
+ mouseClick(15, 15);
+
+ // Wait for the file chooser request.
+ while (!request)
+ ecore_main_loop_iterate();
+
+ evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest);
+ ASSERT_TRUE(request);
+
+ ASSERT_TRUE(ewk_file_chooser_request_cancel(request));
+ ASSERT_FALSE(ewk_file_chooser_request_cancel(request));
+
+ ewk_file_chooser_request_unref(request);
+
+ ecore_main_loop_iterate();
+ EXPECT_STREQ("File chooser test", ewk_view_title_get(webView()));
+
+ // Default behavior is to cancel if the client does not act on the request.
+ request = 0;
+ evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request);
+ // Click on the file input.
+ mouseClick(15, 15);
+
+ // Wait for the file chooser request.
+ while (!request)
+ ecore_main_loop_iterate();
+
+ evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest);
+ ASSERT_TRUE(request);
+
+ ewk_file_chooser_request_unref(request);
+
+ ecore_main_loop_iterate();
+ EXPECT_STREQ("File chooser test", ewk_view_title_get(webView()));
+}
Modified: trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp (133056 => 133057)
--- trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp 2012-10-31 19:17:16 UTC (rev 133057)
@@ -31,9 +31,12 @@
#include "WKAPICast.h"
#include "WKEvent.h"
#include "WKString.h"
+#include "ewk_file_chooser_request_private.h"
#include <Ecore_Evas.h>
#include <WebCore/Color.h>
+using namespace EwkViewCallbacks;
+
namespace WebKit {
static inline PageUIClientEfl* toPageUIClientEfl(const void* clientInfo)
@@ -122,6 +125,13 @@
ecore_evas_move_resize(ee, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
}
+void PageUIClientEfl::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
+{
+ EwkViewImpl* viewImpl = toPageUIClientEfl(clientInfo)->m_viewImpl;
+ RefPtr<Ewk_File_Chooser_Request> fileChooserRequest = Ewk_File_Chooser_Request::create(toImpl(parameters), toImpl(listener));
+ viewImpl->smartCallback<FileChooserRequest>().call(fileChooserRequest.get());
+}
+
PageUIClientEfl::PageUIClientEfl(EwkViewImpl* viewImpl)
: m_viewImpl(viewImpl)
{
@@ -142,6 +152,7 @@
uiClient.unfocus = unfocus;
uiClient.getWindowFrame = getWindowFrame;
uiClient.setWindowFrame = setWindowFrame;
+ uiClient.runOpenPanel = runOpenPanel;
#if ENABLE(SQL_DATABASE)
uiClient.exceededDatabaseQuota = exceededDatabaseQuota;
#endif
Modified: trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h (133056 => 133057)
--- trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h 2012-10-31 19:01:40 UTC (rev 133056)
+++ trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h 2012-10-31 19:17:16 UTC (rev 133057)
@@ -62,6 +62,7 @@
static void takeFocus(WKPageRef, WKFocusDirection, const void*);
static WKRect getWindowFrame(WKPageRef, const void*);
static void setWindowFrame(WKPageRef, WKRect, const void*);
+ static void runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef, WKOpenPanelResultListenerRef, const void*);
EwkViewImpl* m_viewImpl;
};