Example #1
0
QWebPage::LinkDelegationPolicy QWebPageProto::linkDelegationPolicy() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->linkDelegationPolicy();
  return QWebPage::LinkDelegationPolicy();
}
QList<webFileUtils::webFile> webFileUtils::getWebFiles(QUrl url)
{
    QList<webFileUtils::webFile> list;
    QWebPage *webPage = new QWebPage(this);
    QEventLoop loop;
    connect(webPage->mainFrame(), SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
    webPage->mainFrame()->load(url);
    loop.exec();
    QUrl baseUrl = webPage->mainFrame()->baseUrl();

    QWebElementCollection collection = webPage->mainFrame()->findAllElements("a");
    foreach (QWebElement element, collection)
    {
        QString href = element.attribute("href");
        if (!href.isEmpty())
        {
            QUrl relativeUrl(href);
            QUrl absoluteUrl = baseUrl.resolved(relativeUrl);
            if(element.toPlainText().contains("exe") | element.toPlainText().contains("tar.xz") | element.toPlainText().contains("zip")) {
                webFile file;
                file.name = element.toPlainText();
                file.url = absoluteUrl;
                list.append(file);
            }
        }
    }
void GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame(QWebFrame* webFrame, Geolocation* listener)
{
    m_pendingPermissionRequests.remove(webFrame);

    QWebPage* page = webFrame->page();
    emit page->featurePermissionRequestCanceled(webFrame, QWebPage::Geolocation);
}
Example #4
0
void FrameLoaderClientQt::callErrorPageExtension(const WebCore::ResourceError& error)
{
    QWebPage* page = m_webFrame->page();
    if (page->supportsExtension(QWebPage::ErrorPageExtension)) {
        QWebPage::ErrorPageExtensionOption option;

        if (error.domain() == "QtNetwork")
            option.domain = QWebPage::QtNetwork;
        else if (error.domain() == "HTTP")
            option.domain = QWebPage::Http;
        else if (error.domain() == "WebKit")
            option.domain = QWebPage::WebKit;
        else
            return;

        option.url = QUrl(error.failingURL());
        option.frame = m_webFrame;
        option.error = error.errorCode();
        option.errorString = error.localizedDescription();

        QWebPage::ErrorPageExtensionReturn output;
        if (!page->extension(QWebPage::ErrorPageExtension, &option, &output))
            return;

        KURL baseUrl(output.baseUrl);
        KURL failingUrl(option.url);

        WebCore::ResourceRequest request(baseUrl);
        WTF::RefPtr<WebCore::SharedBuffer> buffer = WebCore::SharedBuffer::create(output.content.constData(), output.content.length());
        WebCore::SubstituteData substituteData(buffer, output.contentType, output.encoding, failingUrl);
        m_frame->loader()->load(request, substituteData, false);
    }
}
Example #5
0
void MyTextBrowser::htmlOrSvgDump(const char *filename)
{
#ifdef NO_WEBKIT
  FILE *fout = fopen(filename,"w");
  if(fout == NULL)
  {
    printf("could not write %s\n", filename);
    return;
  }
  QString xml = toHtml();
  fputs(xml.toUtf8(), fout);
  fclose(fout);
#else
  QWebPage *p = page();
  if(p == NULL) return;
  QWebFrame *f = p->currentFrame();
  if(f == NULL) return;

  FILE *fout = fopen(filename,"w");
  if(fout == NULL)
  {
    printf("could not write %s\n", filename);
    return;
  }
  QString xml = f->toHtml();
  fputs(xml.toUtf8(), fout);
  fclose(fout);
#endif  
}
Example #6
0
QSize QWebPageProto::viewportSize() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->viewportSize();
  return QSize();
}
Example #7
0
// Reimplemented Public Functions
bool QWebPageProto::event(QEvent * ev)
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->event(ev);
  return false;
}
Example #8
0
QString QWebPageProto::selectedText() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->selectedText();
  return QString();
}
Example #9
0
QWebSettings* QWebPageProto::settings() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->settings();
  return 0;
}
Example #10
0
QWebPluginFactory* QWebPageProto::pluginFactory() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->pluginFactory();
  return 0;
}
Example #11
0
QSize QWebPageProto::preferredContentsSize() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->preferredContentsSize();
  return QSize();
}
Example #12
0
QPalette QWebPageProto::palette() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->palette();
  return QPalette();
}
Example #13
0
QNetworkAccessManager* QWebPageProto::networkAccessManager() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->networkAccessManager();
  return 0;
}
Example #14
0
QWebFrame* QWebPageProto::mainFrame() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->mainFrame();
  return 0;
}
Example #15
0
QWidget* QWebPageProto::view() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->view();
  return 0;
}
Example #16
0
bool QWebPageProto::shouldInterruptJavaScript()
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->shouldInterruptJavaScript();
  return false;
}
Example #17
0
QWebPage::ViewportAttributes QWebPageProto::viewportAttributesForSize(const QSize & availableSize) const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->viewportAttributesForSize(availableSize);
  return QWebPage::ViewportAttributes();
}
Example #18
0
QStringList QWebPageProto::supportedContentTypes() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->supportedContentTypes();
  return QStringList();
}
Example #19
0
QWebPage::VisibilityState QWebPageProto::visibilityState() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->visibilityState();
  return QWebPage::VisibilityStateVisible; // don't know the best default
}
Example #20
0
bool QWebPageProto::supportsContentType(const QString & mimeType) const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->supportsContentType(mimeType);
  return false;
}
Example #21
0
void Widget::invalidateRect(const IntRect& r)
{
    if (data->m_widget) //plugins
        return data->m_widget->update(r);

    IntRect windowRect = convertToContainingWindow(r);

    // Get our clip rect and intersect with it to ensure we don't invalidate too much.
    IntRect clipRect = windowClipRect();
    windowRect.intersect(clipRect);

    QWidget *canvas = qwidget(); //regular frameview
    if (!canvas && parent())
        canvas = parent()->qwidget(); //scrollbars

    if (!canvas)  // not visible anymore
        return;

    bool painting = canvas->testAttribute(Qt::WA_WState_InPaintEvent);
    if (painting) {
        QWebPage *page = qobject_cast<QWebPage*>(canvas);
        QPainter p(page);
        page->mainFrame()->render(&p, windowRect);
    } else {
        canvas->update(windowRect);
    }
}
Example #22
0
bool QWebPageProto::supportsExtension(QWebPage::Extension extension) const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->supportsExtension(extension);
  return false;
}
Example #23
0
ShibbolethWebView::ShibbolethWebView(Account* account, QWidget* parent)
    : QWebView(parent)
    , _account(account)
    , _accepted(false)
    , _cursorOverriden(false)
{
    // no minimize
    setWindowFlags(Qt::Dialog);
    setAttribute(Qt::WA_DeleteOnClose);
    QWebPage* page = new QWebPage(this);
    page->setNetworkAccessManager(account->networkAccessManager());
    connect(page, SIGNAL(loadStarted()),
            this, SLOT(slotLoadStarted()));
    connect(page, SIGNAL(loadFinished(bool)),
            this, SLOT(slotLoadFinished(bool)));


    connect(page->networkAccessManager()->cookieJar(),
            SIGNAL(newCookiesForUrl (QList<QNetworkCookie>, QUrl)),
            this, SLOT(onNewCookiesForUrl (QList<QNetworkCookie>, QUrl)));
    page->mainFrame()->load(account->url());
    this->setPage(page);
    setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI()));

    // If we have a valid cookie, it's most likely expired. We can use this as
    // as a criteria to tell the user why the browser window pops up
    QNetworkCookie shibCookie = ShibbolethCredentials::findShibCookie(_account, ShibbolethCredentials::accountCookies(_account));
    if (shibCookie != QNetworkCookie()) {
        Logger::instance()->postOptionalGuiLog(tr("Reauthentication required"), tr("Your session has expired. You need to re-login to continue to use the client."));
    }
}
Example #24
0
bool QWebPageProto::swallowContextMenuEvent(QContextMenuEvent * event)
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->swallowContextMenuEvent(event);
  return false;
}
Example #25
0
void QWebViewPrivate::detachCurrentPage()
{
    if (!page)
        return;

    page->d->view.clear();

    // if the page client is the special client constructed for
    // delegating the responsibilities to a QWidget, we need
    // to destroy it.

    if (page->d->client && page->d->client->isQWidgetClient())
        page->d->client.clear();

    page->d->client.release();

    // if the page was created by us, we own it and need to
    // destroy it as well.

    if (page->parent() == view)
        delete page;
    else
        page->disconnect(view);

    page = 0;
}
Example #26
0
quint64 QWebPageProto::totalBytes() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->totalBytes();
  return 0;
}
void GeolocationPermissionClientQt::requestGeolocationPermissionForFrame(QWebFrame* webFrame, Geolocation* listener)
{
    m_pendingPermissionRequests.insert(webFrame, listener);

    QWebPage* page = webFrame->page();
    emit page->featurePermissionRequested(webFrame, QWebPage::Geolocation);
}
Example #28
0
QUndoStack* QWebPageProto::undoStack() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->undoStack();
  return 0;
}
Example #29
0
void Config::loadJsonFile(const QString &filePath)
{
    QString jsonConfig;
    QFile f(filePath);

    // Check file exists and is readable
    if (!f.exists() || !f.open(QFile::ReadOnly | QFile::Text)) {
        Terminal::instance()->cerr("Unable to open config: \"" + filePath + "\"");
        return;
    }

    // Read content
    jsonConfig = QString::fromUtf8(f.readAll().trimmed());
    f.close();

    // Check it's a valid JSON format
    if (jsonConfig.isEmpty() || !jsonConfig.startsWith('{') || !jsonConfig.endsWith('}')) {
        Terminal::instance()->cerr("Config file MUST be in JSON format!");
        return;
    }

    // Load configurator
    QString configurator = Utils::readResourceFileUtf8(":/configurator.js");

    // Use a temporary QWebPage to load the JSON configuration in this Object using the 'configurator' above
    QWebPage webPage;
    // Add this object to the global scope
    webPage.mainFrame()->addToJavaScriptWindowObject("config", this);
    // Apply the JSON config settings to this very object
    webPage.mainFrame()->evaluateJavaScript(configurator.arg(jsonConfig), QString());
}
Example #30
0
bool QWebPageProto::isModified() const
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    return item->isModified();
  return false;
}