void ChromeClientBlackBerry::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
{
    SharedArray<WebString> initialFiles;
    unsigned int initialFileSize = chooser->settings().selectedFiles.size();
    if (initialFileSize > 0)
        initialFiles.reset(new WebString[initialFileSize]);
    for (unsigned i = 0; i < initialFileSize; ++i)
        initialFiles[i] = chooser->settings().selectedFiles[i];

    SharedArray<WebString> chosenFiles;
    unsigned int chosenFileSize;

    {
        PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
        TimerBase::fireTimersInNestedEventLoop();

        // FIXME: Use chooser->settings().acceptMIMETypes instead of WebString() for the second parameter.
        if (!m_webPagePrivate->m_client->chooseFilenames(chooser->settings().allowsMultipleFiles, WebString(), initialFiles, initialFileSize, chosenFiles, chosenFileSize))
            return;
    }

    Vector<String> files(chosenFileSize);
    for (unsigned i = 0; i < chosenFileSize; ++i)
        files[i] = chosenFiles[i];
    chooser->chooseFiles(files);
}
Exemple #2
0
void ChromeClient::runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser> chooser)
{
    //cexer 实现文件选择
    wchar_t* pathList = new wchar_t[10 * MAX_PATH];
    memset(pathList, 0, 10 * MAX_PATH * sizeof(wchar_t));

    OPENFILENAMEW ofn = { 0 };
    ofn.Flags = OFN_DONTADDTORECENT|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_NONETWORKBUTTON|OFN_PATHMUSTEXIST;
    if (chooser->settings().allowsMultipleFiles)
        ofn.Flags |= OFN_ALLOWMULTISELECT;

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.lpstrFilter = L"*.*\0*.*\0\0";
    ofn.lpstrFile = pathList;
    ofn.nMaxFile = 10 * MAX_PATH;
    ofn.lpstrInitialDir = NULL;
    ofn.lpstrTitle = NULL;
    if (0 != GetOpenFileNameW(&ofn))
    {
        Vector<String> chosenFiles;

        wchar_t* path = pathList;
        while (*path)
        {
            size_t pathLen = wcslen(path);

            String pathString((const UChar*)path, pathLen);
            chosenFiles.append(pathString);

            path += pathLen + 1;
        }

        if (!chosenFiles.isEmpty())
            chooser->chooseFiles(chosenFiles);
    }

    delete [] pathList;
}
Exemple #3
0
void ChromeClientBlackBerry::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
{
    SharedArray<BlackBerry::Platform::String> initialFiles;
    unsigned numberOfInitialFiles = chooser->settings().selectedFiles.size();
    if (numberOfInitialFiles > 0)
        initialFiles.reset(new BlackBerry::Platform::String[numberOfInitialFiles], numberOfInitialFiles);
    for (unsigned i = 0; i < numberOfInitialFiles; ++i)
        initialFiles[i] = chooser->settings().selectedFiles[i];

    SharedArray<BlackBerry::Platform::String> acceptMIMETypes;
    unsigned numberOfTypes = chooser->settings().acceptMIMETypes.size();
    if (numberOfTypes > 0)
        acceptMIMETypes.reset(new BlackBerry::Platform::String[numberOfTypes], numberOfTypes);
    for (unsigned i = 0; i < numberOfTypes; ++i)
        acceptMIMETypes[i] = chooser->settings().acceptMIMETypes[i];

    BlackBerry::Platform::String capture;
#if ENABLE(MEDIA_CAPTURE)
    capture = chooser->settings().capture;
#endif

    SharedArray<BlackBerry::Platform::String> chosenFiles;

    {
        PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
        TimerBase::fireTimersInNestedEventLoop();

        if (!m_webPagePrivate->m_client->chooseFilenames(chooser->settings().allowsMultipleFiles, acceptMIMETypes, initialFiles, capture, chosenFiles))
            return;
    }

    Vector<String> files(chosenFiles.length());
    for (unsigned i = 0; i < chosenFiles.length(); ++i)
        files[i] = chosenFiles[i];
    chooser->chooseFiles(files);
}