Ejemplo n.º 1
0
WKStringRef QtWebPageUIClient::runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
{
    QString qMessage = WKStringCopyQString(message);
    QString qDefaultValue = WKStringCopyQString(defaultValue);
    bool ok = false;
    QString result = toQtWebPageUIClient(clientInfo)->runJavaScriptPrompt(qMessage, qDefaultValue, ok);
    if (!ok)
        return createNullWKString();
    return WKStringCreateWithQString(result);
}
    QWebPermissionRequestPrivate(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef geo = 0, WKNotificationPermissionRequestRef notify = 0, QWebPermissionRequest::RequestType reqType = QWebPermissionRequest::Geolocation)
        : origin(securityOrigin)
        , geolocationRequest(geo)
        , notificationRequest(notify)
        , type(reqType)
        , allow(false)
    {
        WKRetainPtr<WKStringRef> url = adoptWK(WKSecurityOriginCopyProtocol(origin.get()));
        securityInfo.setScheme(WKStringCopyQString(url.get()));

        WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(origin.get()));
        securityInfo.setHost(WKStringCopyQString(host.get()));

        securityInfo.setPort(static_cast<int>(WKSecurityOriginGetPort(origin.get())));
    }
Ejemplo n.º 3
0
void QtWebPageLoadClient::didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef frame, WKTypeRef, const void* clientInfo)
{
    if (!WKFrameIsMainFrame(frame))
        return;
    QString qTitle = WKStringCopyQString(title);
    toQtWebPageLoadClient(clientInfo)->didReceiveTitleForFrame(qTitle);
}
void QtDownloadManager::didCreateDestination(WKContextRef, WKDownloadRef download, WKStringRef path, const void* clientInfo)
{
    QtDownloadManager* q = toQtDownloadManager(clientInfo);

    QWebDownloadItem* downloadItem = q->m_downloads.value(WKDownloadGetID(download));
    ASSERT(downloadItem);
    downloadItem->d->destinationPath = WKStringCopyQString(path);
    emit downloadItem->destinationFileCreated(downloadItem->d->destinationPath);
}
Ejemplo n.º 5
0
QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily which) const
{
    switch (which) {
    case StandardFont: {
        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(preferencesRef()));
        return WKStringCopyQString(stringRef.get());
    }
    case FixedFont: {
        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFixedFontFamily(preferencesRef()));
        return WKStringCopyQString(stringRef.get());
    }
    case SerifFont: {
        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySerifFontFamily(preferencesRef()));
        return WKStringCopyQString(stringRef.get());
    }
    case SansSerifFont: {
        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySansSerifFontFamily(preferencesRef()));
        return WKStringCopyQString(stringRef.get());
    }
    case CursiveFont: {
        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyCursiveFontFamily(preferencesRef()));
        return WKStringCopyQString(stringRef.get());
    }
    case FantasyFont: {
        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFantasyFontFamily(preferencesRef()));
        return WKStringCopyQString(stringRef.get());
    }
    default:
        return QString();
    }
}
Ejemplo n.º 6
0
void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
{
    WKRetainPtr<WKArrayRef> wkSelectedFileNames = adoptWK(WKOpenPanelParametersCopySelectedFileNames(parameters));
    QStringList selectedFileNames;
    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);
}
void QtDownloadManager::didReceiveResponse(WKContextRef, WKDownloadRef download, WKURLResponseRef response, const void* clientInfo)
{
    QtDownloadManager* q = toQtDownloadManager(clientInfo);

    // Will be called when the headers are read by WebProcess.
    QWebDownloadItem* downloadItem = q->m_downloads.value(WKDownloadGetID(download));
    ASSERT(downloadItem);

    downloadItem->d->sourceUrl = adoptToQUrl(WKURLResponseCopyURL(response));
    downloadItem->d->mimeType = adoptToQString(WKURLResponseCopyMIMEType(response));
    downloadItem->d->expectedContentLength = WKURLResponseGetExpectedContentLength(response);
    downloadItem->d->suggestedFilename = WKStringCopyQString(adoptWK(WKURLResponseCopySuggestedFilename(response)).get());

    downloadItem->d->didReceiveResponse(downloadItem);
}
Ejemplo n.º 8
0
void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers modifiersRef, unsigned location)
{
    const QString key = WKStringCopyQString(keyRef);
    QString keyText = key;

    Qt::KeyboardModifiers modifiers = getModifiers(modifiersRef);

    if (location == 3)
        modifiers |= Qt::KeypadModifier;
    int code = 0;
    if (key.length() == 1) {
        code = key.unicode()->unicode();
        // map special keycodes used by the tests to something that works for Qt/X11
        if (code == '\r') {
            code = Qt::Key_Return;
        } else if (code == '\t') {
            code = Qt::Key_Tab;
            if (modifiers == Qt::ShiftModifier)
                code = Qt::Key_Backtab;
            keyText = QString();
        } else if (code == KEYCODE_DEL || code == KEYCODE_BACKSPACE) {
            code = Qt::Key_Backspace;
            if (modifiers == Qt::AltModifier)
                modifiers = Qt::ControlModifier;
            keyText = QString();
        } else if (code == 'o' && modifiers == Qt::ControlModifier) {
            // Mimic the emacs ctrl-o binding on Mac by inserting a paragraph
            // separator and then putting the cursor back to its original
            // position. Allows us to pass emacs-ctrl-o.html
            keyText = QLatin1String("\n");
            code = '\n';
            modifiers = 0;
            QKeyEvent event(QEvent::KeyPress, code, modifiers, keyText);
            m_testController->mainWebView()->sendEvent(&event);
            QKeyEvent event2(QEvent::KeyRelease, code, modifiers, keyText);
            m_testController->mainWebView()->sendEvent(&event2);
            keyText = QString();
            code = Qt::Key_Left;
        } else if (code == 'y' && modifiers == Qt::ControlModifier) {
            keyText = QLatin1String("c");
            code = 'c';
        } else if (code == 'k' && modifiers == Qt::ControlModifier) {
            keyText = QLatin1String("x");
            code = 'x';
        } else if (code == 'a' && modifiers == Qt::ControlModifier) {
            keyText = QString();
            code = Qt::Key_Home;
            modifiers = 0;
        } else if (code == KEYCODE_LEFTARROW) {
            keyText = QString();
            code = Qt::Key_Left;
            if (modifiers & Qt::MetaModifier) {
                code = Qt::Key_Home;
                modifiers &= ~Qt::MetaModifier;
            }
        } else if (code == KEYCODE_RIGHTARROW) {
            keyText = QString();
            code = Qt::Key_Right;
            if (modifiers & Qt::MetaModifier) {
                code = Qt::Key_End;
                modifiers &= ~Qt::MetaModifier;
            }
        } else if (code == KEYCODE_UPARROW) {
            keyText = QString();
            code = Qt::Key_Up;
            if (modifiers & Qt::MetaModifier) {
                code = Qt::Key_PageUp;
                modifiers &= ~Qt::MetaModifier;
            }
        } else if (code == KEYCODE_DOWNARROW) {
            keyText = QString();
            code = Qt::Key_Down;
            if (modifiers & Qt::MetaModifier) {
                code = Qt::Key_PageDown;
                modifiers &= ~Qt::MetaModifier;
            }
        } else if (code == 'a' && modifiers == Qt::ControlModifier) {
            keyText = QString();
            code = Qt::Key_Home;
            modifiers = 0;
        } else
            code = key.unicode()->toUpper().unicode();
    } else {
        if (key.startsWith(QLatin1Char('F')) && key.count() <= 3) {
            keyText = keyText.mid(1);
            int functionKey = keyText.toInt();
            Q_ASSERT(functionKey >= 1 && functionKey <= 35);
            code = Qt::Key_F1 + (functionKey - 1);
        // map special keycode strings used by the tests to something that works for Qt/X11
        } else if (key == QLatin1String("leftArrow")) {
            keyText = QString();
            code = Qt::Key_Left;
        } else if (key == QLatin1String("rightArrow")) {
            keyText = QString();
            code = Qt::Key_Right;
        } else if (key == QLatin1String("upArrow")) {
            keyText = QString();
            code = Qt::Key_Up;
        } else if (key == QLatin1String("downArrow")) {
            keyText = QString();
            code = Qt::Key_Down;
        } else if (key == QLatin1String("pageUp")) {
            keyText = QString();
            code = Qt::Key_PageUp;
        } else if (key == QLatin1String("pageDown")) {
            keyText = QString();
            code = Qt::Key_PageDown;
        } else if (key == QLatin1String("home")) {
            keyText = QString();
            code = Qt::Key_Home;
        } else if (key == QLatin1String("end")) {
            keyText = QString();
            code = Qt::Key_End;
        } else if (key == QLatin1String("insert")) {
            keyText = QString();
            code = Qt::Key_Insert;
        } else if (key == QLatin1String("delete")) {
            keyText = QString();
            code = Qt::Key_Delete;
        } else if (key == QLatin1String("printScreen")) {
            keyText = QString();
            code = Qt::Key_Print;
        } else if (key == QLatin1String("menu")) {
            keyText = QString();
            code = Qt::Key_Menu;
        }
    }
    QKeyEvent event(QEvent::KeyPress, code, modifiers, keyText);
    m_testController->mainWebView()->sendEvent(&event);
    QKeyEvent event2(QEvent::KeyRelease, code, modifiers, keyText);
    m_testController->mainWebView()->sendEvent(&event2);
}
Ejemplo n.º 9
0
void QtWebPageUIClient::mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
{
    const QUrl absoluteLinkUrl = WKURLCopyQUrl(adoptWK(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult)).get());
    const QString linkTitle = WKStringCopyQString(adoptWK(WKHitTestResultCopyLinkTitle(hitTestResult)).get());
    toQtWebPageUIClient(clientInfo)->mouseDidMoveOverElement(absoluteLinkUrl, linkTitle);
}
Ejemplo n.º 10
0
bool QtWebPageUIClient::runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
{
    QString qMessage = WKStringCopyQString(message);
    return toQtWebPageUIClient(clientInfo)->runJavaScriptConfirm(qMessage);
}
Ejemplo n.º 11
0
void QtWebPageUIClient::runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo)
{
    QString qAlertText = WKStringCopyQString(alertText);
    toQtWebPageUIClient(clientInfo)->runJavaScriptAlert(qAlertText);
}
Ejemplo n.º 12
0
unsigned long long QtWebPageUIClient::exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef securityOrigin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo)
{
    QString qDisplayName = WKStringCopyQString(displayName);
    QString qDatabaseName = WKStringCopyQString(databaseName);
    return toQtWebPageUIClient(clientInfo)->exceededDatabaseQuota(qDatabaseName, qDisplayName, securityOrigin, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
}
Ejemplo n.º 13
0
QString QtWebError::description() const
{
    return WKStringCopyQString(WKErrorCopyLocalizedDescription(error.get()));
}
Ejemplo n.º 14
0
QString QtWebError::url() const
{
    return WKStringCopyQString(WKURLCopyString(WKErrorCopyFailingURL(error.get())));
}