Title: [123597] trunk/Source/WebKit
Revision
123597
Author
commit-qu...@webkit.org
Date
2012-07-25 03:00:48 -0700 (Wed, 25 Jul 2012)

Log Message

[EFL] Add File Chooser API
https://bugs.webkit.org/show_bug.cgi?id=91957

Patch by Kihong Kwon <kihong.k...@samsung.com> on 2012-07-25
Reviewed by Hajime Morita.

Source/WebKit:

Add ewk_file_chooser source and header.

* PlatformEfl.cmake:

Source/WebKit/efl:

Add APIs for file chooser. These APIs allow an application(like a browser) queries informations
about multiple files allowed, directory upload allowed, accept mimetypes list,
accept file extentions list, selected files list and capture to support HTML media capture.

* ewk/EWebKit.h:
* ewk/ewk_file_chooser.cpp: Added.
(_Ewk_File_Chooser):
(ewk_file_chooser_allows_multiple_files_get):
(ewk_file_chooser_allows_directory_upload_get):
(ewk_file_chooser_accept_mimetypes_get):
(ewk_file_chooser_accept_file_extentions_get):
(ewk_file_chooser_selected_files_get):
(ewk_file_chooser_capture_get):
(ewk_file_chooser_new):
(ewk_file_chooser_free):
* ewk/ewk_file_chooser.h: Added.
* ewk/ewk_file_chooser_private.h: Added.
(WebCore):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (123596 => 123597)


--- trunk/Source/WebKit/ChangeLog	2012-07-25 09:54:11 UTC (rev 123596)
+++ trunk/Source/WebKit/ChangeLog	2012-07-25 10:00:48 UTC (rev 123597)
@@ -1,3 +1,14 @@
+2012-07-25  Kihong Kwon  <kihong.k...@samsung.com>
+
+        [EFL] Add File Chooser API
+        https://bugs.webkit.org/show_bug.cgi?id=91957
+
+        Reviewed by Hajime Morita.
+
+        Add ewk_file_chooser source and header.
+
+        * PlatformEfl.cmake:
+
 2012-07-22  Kent Tamura  <tk...@chromium.org>
 
         Rename ENABLE_METER_TAG and ENABLE_PROGRESS_TAG to ENABLE_METER_ELEMENT and ENABLE_PROGRESS_ELEMENT respectively

Modified: trunk/Source/WebKit/PlatformEfl.cmake (123596 => 123597)


--- trunk/Source/WebKit/PlatformEfl.cmake	2012-07-25 09:54:11 UTC (rev 123596)
+++ trunk/Source/WebKit/PlatformEfl.cmake	2012-07-25 10:00:48 UTC (rev 123597)
@@ -132,6 +132,7 @@
     efl/ewk/ewk_contextmenu.cpp
     efl/ewk/ewk_cookies.cpp
     efl/ewk/ewk_custom_handler.cpp
+    efl/ewk/ewk_file_chooser.cpp
     efl/ewk/ewk_frame.cpp
     efl/ewk/ewk_history.cpp
     efl/ewk/ewk_intent.cpp
@@ -274,6 +275,7 @@
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_auth.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_contextmenu.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_cookies.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_file_chooser.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_frame.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_history.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_intent.h

Modified: trunk/Source/WebKit/efl/ChangeLog (123596 => 123597)


--- trunk/Source/WebKit/efl/ChangeLog	2012-07-25 09:54:11 UTC (rev 123596)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-07-25 10:00:48 UTC (rev 123597)
@@ -1,3 +1,29 @@
+2012-07-25  Kihong Kwon  <kihong.k...@samsung.com>
+
+        [EFL] Add File Chooser API
+        https://bugs.webkit.org/show_bug.cgi?id=91957
+
+        Reviewed by Hajime Morita.
+
+        Add APIs for file chooser. These APIs allow an application(like a browser) queries informations
+        about multiple files allowed, directory upload allowed, accept mimetypes list,
+        accept file extentions list, selected files list and capture to support HTML media capture.
+
+        * ewk/EWebKit.h:
+        * ewk/ewk_file_chooser.cpp: Added.
+        (_Ewk_File_Chooser):
+        (ewk_file_chooser_allows_multiple_files_get):
+        (ewk_file_chooser_allows_directory_upload_get):
+        (ewk_file_chooser_accept_mimetypes_get):
+        (ewk_file_chooser_accept_file_extentions_get):
+        (ewk_file_chooser_selected_files_get):
+        (ewk_file_chooser_capture_get):
+        (ewk_file_chooser_new):
+        (ewk_file_chooser_free):
+        * ewk/ewk_file_chooser.h: Added.
+        * ewk/ewk_file_chooser_private.h: Added.
+        (WebCore):
+
 2012-07-23  Pierre Rossi  <pierre.ro...@gmail.com>
 
         Unify numTouchEventHandlersChanged and needTouchEvents in the chrome client

Modified: trunk/Source/WebKit/efl/ewk/EWebKit.h (123596 => 123597)


--- trunk/Source/WebKit/efl/ewk/EWebKit.h	2012-07-25 09:54:11 UTC (rev 123596)
+++ trunk/Source/WebKit/efl/ewk/EWebKit.h	2012-07-25 10:00:48 UTC (rev 123597)
@@ -32,6 +32,7 @@
 #include "ewk_auth.h"
 #include "ewk_contextmenu.h"
 #include "ewk_cookies.h"
+#include "ewk_file_chooser.h"
 #include "ewk_frame.h"
 #include "ewk_history.h"
 #include "ewk_intent.h"

Added: trunk/Source/WebKit/efl/ewk/ewk_file_chooser.cpp (0 => 123597)


--- trunk/Source/WebKit/efl/ewk/ewk_file_chooser.cpp	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_file_chooser.cpp	2012-07-25 10:00:48 UTC (rev 123597)
@@ -0,0 +1,117 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    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 "ewk_file_chooser.h"
+
+#include "FileChooser.h"
+#include "ewk_file_chooser_private.h"
+#include <wtf/text/CString.h>
+
+struct _Ewk_File_Chooser {
+    RefPtr<WebCore::FileChooser> fileChooser;
+};
+
+Eina_Bool ewk_file_chooser_allows_multiple_files_get(const Ewk_File_Chooser* chooser)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(chooser, false);
+    return chooser->fileChooser->settings().allowsMultipleFiles;
+}
+
+Eina_Bool ewk_file_chooser_allows_directory_upload_get(const Ewk_File_Chooser* chooser)
+{
+#if ENABLE(DIRECTORY_UPLOAD)
+    EINA_SAFETY_ON_NULL_RETURN_VAL(chooser, false);
+    return chooser->fileChooser->settings().allowsDirectoryUpload;
+#else
+    return false;
+#endif
+}
+
+Eina_List* ewk_file_chooser_accept_mimetypes_get(const Ewk_File_Chooser* chooser)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(chooser, 0);
+
+    Eina_List* mimetypes = 0;
+    size_t count = chooser->fileChooser->settings().acceptMIMETypes.size();
+    for (size_t i = 0; i < count; ++i)
+        mimetypes = eina_list_append(mimetypes, eina_stringshare_add(chooser->fileChooser->settings().acceptMIMETypes[i].utf8().data()));
+
+    return mimetypes;
+}
+
+Eina_List* ewk_file_chooser_accept_file_extentions_get(const Ewk_File_Chooser* chooser)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(chooser, 0);
+
+    Eina_List* fileExtentions = 0;
+    size_t count = chooser->fileChooser->settings().acceptFileExtensions.size();
+    for (size_t i = 0; i < count; ++i)
+        fileExtentions = eina_list_append(fileExtentions, eina_stringshare_add(chooser->fileChooser->settings().acceptFileExtensions[i].utf8().data()));
+
+    return fileExtentions;
+}
+
+Eina_List* ewk_file_chooser_selected_files_get(const Ewk_File_Chooser* chooser)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(chooser, 0);
+
+    Eina_List* files = 0;
+    size_t count = chooser->fileChooser->settings().selectedFiles.size();
+    for (size_t i = 0; i < count; ++i)
+        files = eina_list_append(files, eina_stringshare_add(chooser->fileChooser->settings().selectedFiles[i].utf8().data()));
+
+    return files;
+}
+
+Ewk_File_Chooser_Capture_Type ewk_file_chooser_capture_get(const Ewk_File_Chooser* chooser)
+{
+#if ENABLE(MEDIA_CAPTURE)
+    EINA_SAFETY_ON_NULL_RETURN_VAL(chooser, EWK_FILE_CHOOSER_CAPTURE_TYPE_INVALID);
+
+    String capture = chooser->fileChooser->settings().capture;
+
+    if (capture == "camera")
+        return EWK_FILE_CHOOSER_CAPTURE_TYPE_CAMERA;
+
+    if (capture == "camcorder")
+        return EWK_FILE_CHOOSER_CAPTURE_TYPE_CAMCORDER;
+
+    if (capture == "microphone")
+        return EWK_FILE_CHOOSER_CAPTURE_TYPE_MICROPHONE;
+
+    return EWK_FILE_CHOOSER_CAPTURE_TYPE_FILESYSTEM;
+#else
+    return EWK_FILE_CHOOSER_CAPTURE_TYPE_INVALID;
+#endif
+}
+
+Ewk_File_Chooser* ewk_file_chooser_new(WebCore::FileChooser* fileChooser)
+{
+    Ewk_File_Chooser* ewkFileChooser = new Ewk_File_Chooser;
+    ewkFileChooser->fileChooser = fileChooser;
+    return ewkFileChooser;
+}
+
+void ewk_file_chooser_free(Ewk_File_Chooser* chooser)
+{
+    chooser->fileChooser = 0;
+    delete chooser;
+}
+

Added: trunk/Source/WebKit/efl/ewk/ewk_file_chooser.h (0 => 123597)


--- trunk/Source/WebKit/efl/ewk/ewk_file_chooser.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_file_chooser.h	2012-07-25 10:00:48 UTC (rev 123597)
@@ -0,0 +1,132 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    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.
+*/
+
+/**
+ * @file    ewk_file_chooser.h
+ * @brief   File Chooser API.
+ *
+ * File Chooser supports APIs for file selection dialog.
+ * This support attributes of file chooser regarding:
+ * - allowance of multiple files selection
+ * - allowance of upload directory
+ * - list of accepted mime types
+ * - list of accepted file extensions
+ * - list of initial selected file names
+ * - capture attribute for HTML media capture
+ */
+
+#ifndef ewk_file_chooser_h
+#define ewk_file_chooser_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _Ewk_File_Chooser Ewk_File_Chooser;
+
+/**
+ * \enum    _Ewk_File_Chooser_Capture_Type
+ * @brief   Types of capture attribute of file chooser to support the HTML media capture.
+ */
+enum _Ewk_File_Chooser_Capture_Type {
+    EWK_FILE_CHOOSER_CAPTURE_TYPE_INVALID,
+    EWK_FILE_CHOOSER_CAPTURE_TYPE_FILESYSTEM,
+    EWK_FILE_CHOOSER_CAPTURE_TYPE_CAMERA,
+    EWK_FILE_CHOOSER_CAPTURE_TYPE_CAMCORDER,
+    EWK_FILE_CHOOSER_CAPTURE_TYPE_MICROPHONE
+};
+typedef enum _Ewk_File_Chooser_Capture_Type Ewk_File_Chooser_Capture_Type;
+
+/**
+ * Query if multiple files are supported by file chooser.
+ *
+ * @param f file chooser object.
+ *
+ * It returns a boolean value which indicates if multiple file is supported or not.
+ *
+ * @return @c EINA_TRUE on support multiple files or @c EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool ewk_file_chooser_allows_multiple_files_get(const Ewk_File_Chooser *f);
+
+/**
+ * Query if directory upload is supported by file chooser.
+ *
+ * @param f file chooser object.
+ *
+ * It returns a boolean value which indicates if directory upload is supported or not.
+ *
+ * @return @c EINA_TRUE on support directory upload or @c EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool ewk_file_chooser_allows_directory_upload_get(const Ewk_File_Chooser *f);
+
+/**
+ * Returns the list of accepted mimetypes of the file chooser.
+ *
+ * @param f file chooser object.
+ *
+ * @return Eina_List of accepted mimetypes on success, or @c NULL on failure,
+ *         the Eina_List and its items should be freed after use. Use eina_stringshare_del()
+ *         to free the items.
+ */
+EAPI Eina_List *ewk_file_chooser_accept_mimetypes_get(const Ewk_File_Chooser *f);
+
+/**
+ * Returns the list of accepted file extensions of the file chooser.
+ *
+ * @param f file chooser object.
+ *
+ * @return @c Eina_List of accepted file extensions on success, or @c NULL on failure,
+ *         the Eina_List and its items should be freed after use. Use eina_stringshare_del()
+ *         to free the items.
+ */
+EAPI Eina_List *ewk_file_chooser_accept_file_extentions_get(const Ewk_File_Chooser *f);
+
+/**
+ * Returns the list of selected file names of the file chooser.
+ *
+ * This list indicates previously selected file names of the file chooser.
+ * These can be used by initial values of the file dialog.
+ *
+ * @param f file chooser object.
+ *
+ * @return @c Eina_List of selected file names on success, or @c NULL on failure,
+ *         the Eina_List and its items should be freed after use. Use eina_stringshare_del()
+ *         to free the items.
+ */
+EAPI Eina_List *ewk_file_chooser_selected_files_get(const Ewk_File_Chooser *f);
+
+/**
+ * Returns the capture attribute of the file chooser to support HTML media capture.
+ *
+ * @see http://www.w3.org/TR/html-media-capture/ for the semantics of the capture attribute.
+ *
+ * @param f file chooser object.
+ *
+ * @return @c Ewk_File_Chooser_Capture_Type on supporting HTML media capture or
+ *         @c EWK_FILE_CHOOSER_CAPTURE_TYPE_INVALID on failure.
+ */
+EAPI Ewk_File_Chooser_Capture_Type ewk_file_chooser_capture_get(const Ewk_File_Chooser *f);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_file_chooser_h

Added: trunk/Source/WebKit/efl/ewk/ewk_file_chooser_private.h (0 => 123597)


--- trunk/Source/WebKit/efl/ewk/ewk_file_chooser_private.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_file_chooser_private.h	2012-07-25 10:00:48 UTC (rev 123597)
@@ -0,0 +1,31 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+
+    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 ewk_file_chooser_private_h
+#define ewk_file_chooser_private_h
+
+namespace WebCore {
+class FileChooser;
+}
+
+Ewk_File_Chooser* ewk_file_chooser_new(WebCore::FileChooser* fileChooser);
+void ewk_file_chooser_free(Ewk_File_Chooser* chooser);
+
+#endif // ewk_file_chooser_private_h
+
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to