mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Workaround error handling in scheme handlers
This commit is contained in:
parent
5829318774
commit
a6c9ca7b4c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,14 @@ QupZillaSchemeHandler::QupZillaSchemeHandler(QObject *parent)
|
|||
|
||||
void QupZillaSchemeHandler::requestStarted(QWebEngineUrlRequestJob *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);
|
||||
}
|
||||
}
|
||||
|
||||
void QupZillaSchemeReply::loadPage()
|
||||
|
|
Loading…
Reference in New Issue
Block a user