Title: [148005] trunk/Source/WebKit2
- Revision
- 148005
- Author
- [email protected]
- Date
- 2013-04-09 04:13:44 -0700 (Tue, 09 Apr 2013)
Log Message
[WK2] Add C API to copy selected files from WebOpenPanelParameters.
https://bugs.webkit.org/show_bug.cgi?id=112339
Reviewed by Andreas Kling.
Replaces the existing WebOpenPanelParameters::selectedFileNames() method
to return a copy of the selected file names and exposes it through the
C API. This is done in order to reduce the direct use of WebKit2 internal
classes. The implementation is very similar to the one in
WebOpenPanelParameters::acceptMIMETypes().
This also updates the GTK port, which is the other user of selectedFileNames.
* Shared/WebOpenPanelParameters.cpp:
(WebKit::WebOpenPanelParameters::selectedFileNames):
(WebKit):
* Shared/WebOpenPanelParameters.h:
(WebOpenPanelParameters):
* UIProcess/API/C/WKOpenPanelParameters.cpp:
(WKOpenPanelParametersCopySelectedFileNames):
* UIProcess/API/C/WKOpenPanelParameters.h:
* UIProcess/API/gtk/WebKitFileChooserRequest.cpp:
(webkit_file_chooser_request_get_selected_files):
* UIProcess/qt/QtWebPageUIClient.cpp:
(WebKit::QtWebPageUIClient::runOpenPanel):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (148004 => 148005)
--- trunk/Source/WebKit2/ChangeLog 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-09 11:13:44 UTC (rev 148005)
@@ -1,3 +1,31 @@
+2013-04-09 Michael BrĂ¼ning <[email protected]>
+
+ [WK2] Add C API to copy selected files from WebOpenPanelParameters.
+ https://bugs.webkit.org/show_bug.cgi?id=112339
+
+ Reviewed by Andreas Kling.
+
+ Replaces the existing WebOpenPanelParameters::selectedFileNames() method
+ to return a copy of the selected file names and exposes it through the
+ C API. This is done in order to reduce the direct use of WebKit2 internal
+ classes. The implementation is very similar to the one in
+ WebOpenPanelParameters::acceptMIMETypes().
+
+ This also updates the GTK port, which is the other user of selectedFileNames.
+
+ * Shared/WebOpenPanelParameters.cpp:
+ (WebKit::WebOpenPanelParameters::selectedFileNames):
+ (WebKit):
+ * Shared/WebOpenPanelParameters.h:
+ (WebOpenPanelParameters):
+ * UIProcess/API/C/WKOpenPanelParameters.cpp:
+ (WKOpenPanelParametersCopySelectedFileNames):
+ * UIProcess/API/C/WKOpenPanelParameters.h:
+ * UIProcess/API/gtk/WebKitFileChooserRequest.cpp:
+ (webkit_file_chooser_request_get_selected_files):
+ * UIProcess/qt/QtWebPageUIClient.cpp:
+ (WebKit::QtWebPageUIClient::runOpenPanel):
+
2013-04-09 Jinwoo Song <[email protected]>
[WK2] Remove build warnings for unused parameters
Modified: trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp (148004 => 148005)
--- trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp 2013-04-09 11:13:44 UTC (rev 148005)
@@ -68,5 +68,17 @@
}
#endif
+PassRefPtr<ImmutableArray> WebOpenPanelParameters::selectedFileNames() const
+{
+ size_t size = m_settings.selectedFiles.size();
+ Vector<RefPtr<APIObject> > vector;
+ vector.reserveInitialCapacity(size);
+
+ for (size_t i = 0; i < size; ++i)
+ vector.uncheckedAppend(WebString::create(m_settings.selectedFiles[i]));
+ return ImmutableArray::adopt(vector);
+}
+
+
} // namespace WebCore
Modified: trunk/Source/WebKit2/Shared/WebOpenPanelParameters.h (148004 => 148005)
--- trunk/Source/WebKit2/Shared/WebOpenPanelParameters.h 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/Shared/WebOpenPanelParameters.h 2013-04-09 11:13:44 UTC (rev 148005)
@@ -43,7 +43,7 @@
bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
PassRefPtr<ImmutableArray> acceptMIMETypes() const;
- Vector<String> selectedFileNames() const { return m_settings.selectedFiles; }
+ PassRefPtr<ImmutableArray> selectedFileNames() const;
#if ENABLE(MEDIA_CAPTURE)
String capture() const;
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp (148004 => 148005)
--- trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp 2013-04-09 11:13:44 UTC (rev 148005)
@@ -56,3 +56,8 @@
return 0;
#endif
}
+
+WKArrayRef WKOpenPanelParametersCopySelectedFileNames(WKOpenPanelParametersRef parametersRef)
+{
+ return toAPI(toImpl(parametersRef)->selectedFileNames().leakRef());
+}
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h (148004 => 148005)
--- trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h 2013-04-09 11:13:44 UTC (rev 148005)
@@ -45,6 +45,8 @@
WK_EXPORT WKStringRef WKOpenPanelParametersCopyCapture(WKOpenPanelParametersRef parameters);
+WK_EXPORT WKArrayRef WKOpenPanelParametersCopySelectedFileNames(WKOpenPanelParametersRef parametersRef);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp (148004 => 148005)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp 2013-04-09 11:13:44 UTC (rev 148005)
@@ -345,14 +345,15 @@
if (request->priv->selectedFiles)
return reinterpret_cast<gchar**>(request->priv->selectedFiles->pdata);
- const Vector<String> selectedFileNames = request->priv->parameters->selectedFileNames();
- size_t numOfFiles = selectedFileNames.size();
+ RefPtr<ImmutableArray> selectedFileNames = request->priv->parameters->selectedFileNames();
+ size_t numOfFiles = selectedFileNames->size();
if (!numOfFiles)
return 0;
request->priv->selectedFiles = adoptGRef(g_ptr_array_new_with_free_func(g_free));
for (size_t i = 0; i < numOfFiles; ++i) {
- if (selectedFileNames[i].isEmpty())
+ WebString* webFileName = static_cast<WebString*>(selectedFileNames->at(i));
+ if (webFileName->isEmpty())
continue;
CString filename = fileSystemRepresentation(selectedFileNames[i]);
g_ptr_array_add(request->priv->selectedFiles.get(), g_strdup(filename.data()));
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp (148004 => 148005)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp 2013-04-09 11:01:32 UTC (rev 148004)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp 2013-04-09 11:13:44 UTC (rev 148005)
@@ -26,7 +26,7 @@
#include "qquickwebview_p.h"
#include "qquickwebview_p_p.h"
#include "qwebpermissionrequest_p.h"
-#include <WKAPICast.h>
+#include <WKArray.h>
#include <WKHitTestResult.h>
#include <WKOpenPanelParameters.h>
#include <WKOpenPanelResultListener.h>
@@ -136,12 +136,14 @@
void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
{
- Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
-
+ WKRetainPtr<WKArrayRef> wkSelectedFileNames = adoptWK(WKOpenPanelParametersCopySelectedFileNames(parameters));
QStringList selectedFileNames;
- for (size_t i = 0; i < wkSelectedFileNames.size(); ++i)
- selectedFileNames += wkSelectedFileNames.at(i);
+ size_t selectedFilesSize = WKArrayGetSize(wkSelectedFileNames.get());
+ selectedFileNames.reserve(selectedFilesSize);
+ for (size_t i = 0; i < selectedFilesSize; ++i)
+ selectedFileNames += WKStringCopyQString(static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSelectedFileNames.get(), i)));
+
FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? MultipleFilesSelection : SingleFileSelection;
toQtWebPageUIClient(clientInfo)->runOpenPanel(listener, selectedFileNames, allowMultipleFiles);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes