1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Workaround error handling in scheme handlers

This commit is contained in:
David Rosca 2015-10-05 19:16:12 +02:00
parent 5829318774
commit a6c9ca7b4c
2 changed files with 15 additions and 14 deletions

View File

@ -19,6 +19,7 @@
#include "adblockmanager.h"
#include "emptynetworkreply.h"
#include <QBuffer>
#include <QUrlQuery>
#include <QMessageBox>
#include <QWebEngineUrlRequestJob>
@ -30,6 +31,10 @@ AdBlockSchemeHandler::AdBlockSchemeHandler(QObject *parent)
void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
{
// Ignore the request
job->setReply(QByteArray(), new QBuffer());
//job->setError(QWebEngineUrlRequestJob::RequestAborted);
const QUrl url = job->requestUrl();
const QList<QPair<QString, QString> > queryItems = QUrlQuery(url).queryItems();
@ -47,7 +52,6 @@ void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
}
if (subscriptionTitle.isEmpty() || subscriptionUrl.isEmpty()) {
job->setError(QWebEngineUrlRequestJob::RequestAborted);
return;
}
@ -58,6 +62,4 @@ void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
AdBlockManager::instance()->addSubscription(subscriptionTitle, subscriptionUrl);
AdBlockManager::instance()->showDialog();
}
job->setError(QWebEngineUrlRequestJob::RequestAborted);
}

View File

@ -44,7 +44,14 @@ QupZillaSchemeHandler::QupZillaSchemeHandler(QObject *parent)
void QupZillaSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
{
job->setReply(QByteArrayLiteral("text/html"), new QupZillaSchemeReply(job));
QStringList knownPages;
knownPages << "about" << "reportbug" << "start" << "speeddial" << "config" << "restore";
if (knownPages.contains(job->requestUrl().path()))
job->setReply(QByteArrayLiteral("text/html"), new QupZillaSchemeReply(job));
else
job->setReply(QByteArray(), new QBuffer());
//m_job->setError(QWebEngineUrlRequestJob::UrlNotFound);
}
QupZillaSchemeReply::QupZillaSchemeReply(QWebEngineUrlRequestJob *job, QObject *parent)
@ -54,16 +61,8 @@ QupZillaSchemeReply::QupZillaSchemeReply(QWebEngineUrlRequestJob *job, QObject *
{
m_pageName = m_job->requestUrl().path();
QStringList knownPages;
knownPages << "about" << "reportbug" << "start" << "speeddial" << "config" << "restore";
if (knownPages.contains(m_pageName)) {
open(QIODevice::ReadOnly);
m_buffer.open(QIODevice::ReadWrite);
}
else {
//m_job->setError(QWebEngineUrlRequestJob::UrlNotFound);
}
open(QIODevice::ReadOnly);
m_buffer.open(QIODevice::ReadWrite);
}
void QupZillaSchemeReply::loadPage()