1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56: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 "adblockmanager.h"
#include "emptynetworkreply.h" #include "emptynetworkreply.h"
#include <QBuffer>
#include <QUrlQuery> #include <QUrlQuery>
#include <QMessageBox> #include <QMessageBox>
#include <QWebEngineUrlRequestJob> #include <QWebEngineUrlRequestJob>
@ -30,6 +31,10 @@ AdBlockSchemeHandler::AdBlockSchemeHandler(QObject *parent)
void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job) void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
{ {
// Ignore the request
job->setReply(QByteArray(), new QBuffer());
//job->setError(QWebEngineUrlRequestJob::RequestAborted);
const QUrl url = job->requestUrl(); const QUrl url = job->requestUrl();
const QList<QPair<QString, QString> > queryItems = QUrlQuery(url).queryItems(); const QList<QPair<QString, QString> > queryItems = QUrlQuery(url).queryItems();
@ -47,7 +52,6 @@ void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
} }
if (subscriptionTitle.isEmpty() || subscriptionUrl.isEmpty()) { if (subscriptionTitle.isEmpty() || subscriptionUrl.isEmpty()) {
job->setError(QWebEngineUrlRequestJob::RequestAborted);
return; return;
} }
@ -58,6 +62,4 @@ void AdBlockSchemeHandler::requestStarted(QWebEngineUrlRequestJob *job)
AdBlockManager::instance()->addSubscription(subscriptionTitle, subscriptionUrl); AdBlockManager::instance()->addSubscription(subscriptionTitle, subscriptionUrl);
AdBlockManager::instance()->showDialog(); AdBlockManager::instance()->showDialog();
} }
job->setError(QWebEngineUrlRequestJob::RequestAborted);
} }

View File

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