Changeset 148005 in webkit


Ignore:
Timestamp:
Apr 9, 2013 4:13:44 AM (11 years ago)
Author:
michael.bruning@digia.com
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):

Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r148000 r148005  
     12013-04-09  Michael Brüning  <michael.bruning@digia.com>
     2
     3        [WK2] Add C API to copy selected files from WebOpenPanelParameters.
     4        https://bugs.webkit.org/show_bug.cgi?id=112339
     5
     6        Reviewed by Andreas Kling.
     7
     8        Replaces the existing WebOpenPanelParameters::selectedFileNames() method
     9        to return a copy of the selected file names and exposes it through the
     10        C API. This is done in order to reduce the direct use of WebKit2 internal
     11        classes. The implementation is very similar to the one in
     12        WebOpenPanelParameters::acceptMIMETypes().
     13
     14        This also updates the GTK port, which is the other user of selectedFileNames.
     15
     16        * Shared/WebOpenPanelParameters.cpp:
     17        (WebKit::WebOpenPanelParameters::selectedFileNames):
     18        (WebKit):
     19        * Shared/WebOpenPanelParameters.h:
     20        (WebOpenPanelParameters):
     21        * UIProcess/API/C/WKOpenPanelParameters.cpp:
     22        (WKOpenPanelParametersCopySelectedFileNames):
     23        * UIProcess/API/C/WKOpenPanelParameters.h:
     24        * UIProcess/API/gtk/WebKitFileChooserRequest.cpp:
     25        (webkit_file_chooser_request_get_selected_files):
     26        * UIProcess/qt/QtWebPageUIClient.cpp:
     27        (WebKit::QtWebPageUIClient::runOpenPanel):
     28
    1292013-04-09  Jinwoo Song  <jinwoo7.song@samsung.com>
    230
  • trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp

    r125512 r148005  
    6969#endif
    7070
     71PassRefPtr<ImmutableArray> WebOpenPanelParameters::selectedFileNames() const
     72{   
     73    size_t size = m_settings.selectedFiles.size();
     74
     75    Vector<RefPtr<APIObject> > vector;
     76    vector.reserveInitialCapacity(size);
     77
     78    for (size_t i = 0; i < size; ++i)
     79        vector.uncheckedAppend(WebString::create(m_settings.selectedFiles[i]));
     80    return ImmutableArray::adopt(vector);
     81}
     82
    7183
    7284} // namespace WebCore
  • trunk/Source/WebKit2/Shared/WebOpenPanelParameters.h

    r147403 r148005  
    4444    bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
    4545    PassRefPtr<ImmutableArray> acceptMIMETypes() const;
    46     Vector<String> selectedFileNames() const { return m_settings.selectedFiles; }
     46    PassRefPtr<ImmutableArray> selectedFileNames() const;
    4747#if ENABLE(MEDIA_CAPTURE)
    4848    String capture() const;
  • trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp

    r125512 r148005  
    5757#endif
    5858}
     59
     60WKArrayRef WKOpenPanelParametersCopySelectedFileNames(WKOpenPanelParametersRef parametersRef)
     61{
     62    return toAPI(toImpl(parametersRef)->selectedFileNames().leakRef());
     63}
  • trunk/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h

    r125512 r148005  
    4646WK_EXPORT WKStringRef WKOpenPanelParametersCopyCapture(WKOpenPanelParametersRef parameters);
    4747
     48WK_EXPORT WKArrayRef WKOpenPanelParametersCopySelectedFileNames(WKOpenPanelParametersRef parametersRef);
     49
    4850#ifdef __cplusplus
    4951}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp

    r135565 r148005  
    346346        return reinterpret_cast<gchar**>(request->priv->selectedFiles->pdata);
    347347
    348     const Vector<String> selectedFileNames = request->priv->parameters->selectedFileNames();
    349     size_t numOfFiles = selectedFileNames.size();
     348    RefPtr<ImmutableArray> selectedFileNames = request->priv->parameters->selectedFileNames();
     349    size_t numOfFiles = selectedFileNames->size();
    350350    if (!numOfFiles)
    351351        return 0;
     
    353353    request->priv->selectedFiles = adoptGRef(g_ptr_array_new_with_free_func(g_free));
    354354    for (size_t i = 0; i < numOfFiles; ++i) {
    355         if (selectedFileNames[i].isEmpty())
     355        WebString* webFileName = static_cast<WebString*>(selectedFileNames->at(i));
     356        if (webFileName->isEmpty())
    356357            continue;
    357358        CString filename = fileSystemRepresentation(selectedFileNames[i]);
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp

    r122478 r148005  
    2727#include "qquickwebview_p_p.h"
    2828#include "qwebpermissionrequest_p.h"
    29 #include <WKAPICast.h>
     29#include <WKArray.h>
    3030#include <WKHitTestResult.h>
    3131#include <WKOpenPanelParameters.h>
     
    137137void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
    138138{
    139     Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
     139    WKRetainPtr<WKArrayRef> wkSelectedFileNames = adoptWK(WKOpenPanelParametersCopySelectedFileNames(parameters));
     140    QStringList selectedFileNames;
     141    size_t selectedFilesSize = WKArrayGetSize(wkSelectedFileNames.get());
     142    selectedFileNames.reserve(selectedFilesSize);
    140143
    141     QStringList selectedFileNames;
    142     for (size_t i = 0; i < wkSelectedFileNames.size(); ++i)
    143         selectedFileNames += wkSelectedFileNames.at(i);
     144    for (size_t i = 0; i < selectedFilesSize; ++i)
     145        selectedFileNames += WKStringCopyQString(static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSelectedFileNames.get(), i)));
    144146
    145147    FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? MultipleFilesSelection : SingleFileSelection;
Note: See TracChangeset for help on using the changeset viewer.