1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

WebPage: Always build nonblock js dialogs support

Can be enabled with QUPZILLA_ENABLE_JS_NONBLOCK_DIALOGS environment variable.
This commit is contained in:
David Rosca 2018-01-06 20:33:13 +01:00
parent 642d835d55
commit f87c6897a0
3 changed files with 25 additions and 50 deletions

View File

@ -66,28 +66,13 @@ Available Defines
$ export NAME="value"
General:
PORTABLE_BUILD Falkon won't write any data outside of path of execution.
PORTABLE_BUILD Falkon won't write any data outside of path of execution.
It will also disable plugins by default.
(disabled by default)
example:
$ export PORTABLE_BUILD="true"
NONBLOCK_JS_DIALOGS Enable non-blocking JavaScript dialogs from alert() prompt()
and confirm() functions. They are shown inside page and are not
blocking application window.
However, due to synchronous API, there is a possible crash when
closing browser windows with opened dialogs.
If you can take this risk and/or make sure you aren't closing browser
with opened dialogs, you may enable this option.
These dialogs are much more beautiful than normal QDialogs.
(disabled by default)
example:
$ export NONBLOCK_JS_DIALOGS="true"
Windows specific defines:
W7API Enable Windows 7 API support

View File

@ -55,10 +55,6 @@ option(PORTABLE_BUILD "TODO" OFF)
if (PORTABLE_BUILD)
add_definitions(-DPORTABLE_BUILD)
endif()
option(NONBLOCK_JS_DIALOGS "TODO" OFF)
if (NONBLOCK_JS_DIALOGS)
add_definitions(-DNONBLOCK_JS_DIALOGS)
endif()
option(DISABLE_DBUS "TODO" OFF)
if (DISABLE_DBUS)
add_definitions(-DDISABLE_DBUS)

View File

@ -39,15 +39,10 @@
#include "networkmanager.h"
#include "webhittestresult.h"
#include "adblock/adblockmanager.h"
#ifdef NONBLOCK_JS_DIALOGS
#include "ui_jsconfirm.h"
#include "ui_jsalert.h"
#include "ui_jsprompt.h"
#include <QPushButton>
#endif
#include <iostream>
#include <QDir>
@ -60,12 +55,14 @@
#include <QMessageBox>
#include <QFileDialog>
#include <QAuthenticator>
#include <QPushButton>
QString WebPage::s_lastUploadLocation = QDir::homePath();
QUrl WebPage::s_lastUnsupportedUrl;
QTime WebPage::s_lastUnsupportedUrlTime;
static const bool kEnableJsOutput = qEnvironmentVariableIsSet("QUPZILLA_ENABLE_JS_OUTPUT");
static const bool kEnableJsNonBlockDialogs = qEnvironmentVariableIsSet("QUPZILLA_ENABLE_JS_NONBLOCK_DIALOGS");
WebPage::WebPage(QObject* parent)
: QWebEnginePage(mApp->webProfile(), parent)
@ -429,11 +426,10 @@ QVector<PasswordEntry> WebPage::autoFillData() const
bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result)
{
Q_UNUSED(securityOrigin)
if (!kEnableJsNonBlockDialogs) {
return QWebEnginePage::javaScriptPrompt(securityOrigin, msg, defaultValue, result);
}
#ifndef NONBLOCK_JS_DIALOGS
return QWebEnginePage::javaScriptPrompt(securityOrigin, msg, defaultValue, result);
#else
if (m_runningLoop) {
return false;
}
@ -469,16 +465,14 @@ bool WebPage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, c
view()->setFocus();
return _result;
#endif
}
bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
{
Q_UNUSED(securityOrigin)
if (!kEnableJsNonBlockDialogs) {
return QWebEnginePage::javaScriptConfirm(securityOrigin, msg);
}
#ifndef NONBLOCK_JS_DIALOGS
return QWebEnginePage::javaScriptConfirm(securityOrigin, msg);
#else
if (m_runningLoop) {
return false;
}
@ -510,7 +504,6 @@ bool WebPage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
view()->setFocus();
return result;
#endif
}
void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
@ -521,22 +514,24 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
return;
}
#ifndef NONBLOCK_JS_DIALOGS
QString title = tr("JavaScript alert");
if (!url().host().isEmpty()) {
title.append(QString(" - %1").arg(url().host()));
if (!kEnableJsNonBlockDialogs) {
QString title = tr("JavaScript alert");
if (!url().host().isEmpty()) {
title.append(QString(" - %1").arg(url().host()));
}
CheckBoxDialog dialog(QMessageBox::Ok, view());
dialog.setDefaultButton(QMessageBox::Ok);
dialog.setWindowTitle(title);
dialog.setText(msg);
dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs"));
dialog.setIcon(QMessageBox::Information);
dialog.exec();
m_blockAlerts = dialog.isChecked();
return;
}
CheckBoxDialog dialog(QMessageBox::Ok, view());
dialog.setDefaultButton(QMessageBox::Ok);
dialog.setWindowTitle(title);
dialog.setText(msg);
dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs"));
dialog.setIcon(QMessageBox::Information);
dialog.exec();
m_blockAlerts = dialog.isChecked();
#else
ResizableFrame* widget = new ResizableFrame(view()->overlayWidget());
widget->setObjectName("jsFrame");
@ -563,7 +558,6 @@ void WebPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
delete widget;
view()->setFocus();
#endif
}
void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)