2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2015-05-22 23:18:25 +02:00
|
|
|
* Copyright (C) 2010-2015 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#ifndef WEBPAGE_H
|
|
|
|
#define WEBPAGE_H
|
|
|
|
|
2015-01-27 11:01:52 +01:00
|
|
|
#include <QWebEnginePage>
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QSslCertificate>
|
2013-02-26 12:56:11 +01:00
|
|
|
#include <QVector>
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2013-05-14 17:25:55 +02:00
|
|
|
#include "passwordmanager.h"
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QEventLoop;
|
2015-05-24 19:22:32 +02:00
|
|
|
class QWebEngineDownloadItem;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2015-09-24 23:00:27 +02:00
|
|
|
class WebView;
|
2012-07-01 18:13:49 +02:00
|
|
|
class AdBlockRule;
|
2013-04-02 13:14:19 +02:00
|
|
|
class DelayedFileWatcher;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2015-01-27 11:01:52 +01:00
|
|
|
class QUPZILLA_EXPORT WebPage : public QWebEnginePage
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-03-29 20:30:05 +02:00
|
|
|
struct AdBlockedEntry {
|
2012-07-01 18:13:49 +02:00
|
|
|
const AdBlockRule* rule;
|
2011-03-29 20:30:05 +02:00
|
|
|
QUrl url;
|
2011-10-09 14:51:25 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
bool operator==(const AdBlockedEntry &other) const {
|
2011-10-09 14:51:25 +02:00
|
|
|
return (this->rule == other.rule && this->url == other.url);
|
|
|
|
}
|
2011-03-29 20:30:05 +02:00
|
|
|
};
|
|
|
|
|
2013-05-12 22:55:53 +02:00
|
|
|
WebPage(QObject* parent = 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
~WebPage();
|
|
|
|
|
2015-09-24 23:00:27 +02:00
|
|
|
WebView *view() const;
|
|
|
|
|
2011-04-24 09:08:53 +02:00
|
|
|
void setSSLCertificate(const QSslCertificate &cert);
|
2011-04-04 16:00:27 +02:00
|
|
|
QSslCertificate sslCertificate();
|
2011-05-22 10:47:03 +02:00
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result) Q_DECL_OVERRIDE;
|
|
|
|
bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE;
|
|
|
|
void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-01-25 17:48:30 +01:00
|
|
|
void setJavaScriptEnabled(bool enabled);
|
|
|
|
|
2012-07-01 18:13:49 +02:00
|
|
|
void addAdBlockRule(const AdBlockRule* rule, const QUrl &url);
|
2013-02-26 12:56:11 +01:00
|
|
|
QVector<AdBlockedEntry> adBlockedEntries() const;
|
2013-02-08 18:44:26 +01:00
|
|
|
|
|
|
|
bool hasMultipleUsernames() const;
|
2013-05-14 17:25:55 +02:00
|
|
|
QVector<PasswordEntry> autoFillData() const;
|
2011-03-29 20:30:05 +02:00
|
|
|
|
2011-11-12 09:45:32 +01:00
|
|
|
void scheduleAdjustPage();
|
2012-01-21 20:20:48 +01:00
|
|
|
bool isRunningLoop();
|
2011-10-30 16:32:36 +01:00
|
|
|
|
2012-07-03 15:22:42 +02:00
|
|
|
bool isLoading() const;
|
2012-04-04 14:45:45 +02:00
|
|
|
|
2012-07-03 15:22:42 +02:00
|
|
|
void addRejectedCerts(const QList<QSslCertificate> &certs);
|
2012-07-03 21:54:04 +02:00
|
|
|
bool containsRejectedCerts(const QList<QSslCertificate> &certs);
|
2012-07-03 15:22:42 +02:00
|
|
|
|
2015-08-29 19:15:33 +02:00
|
|
|
void setupWebChannel();
|
|
|
|
|
2011-07-11 20:30:49 +02:00
|
|
|
signals:
|
|
|
|
void privacyChanged(bool status);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
protected slots:
|
2011-07-11 20:30:49 +02:00
|
|
|
void progress(int prog);
|
2011-07-11 22:53:32 +02:00
|
|
|
void finished();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-09 14:51:25 +02:00
|
|
|
private slots:
|
|
|
|
void cleanBlockedObjects();
|
|
|
|
void urlChanged(const QUrl &url);
|
|
|
|
|
2011-12-15 19:08:33 +01:00
|
|
|
void watchedFileChanged(const QString &file);
|
2012-03-04 14:25:52 +01:00
|
|
|
void windowCloseRequested();
|
2015-01-27 11:01:52 +01:00
|
|
|
void authentication(const QUrl &requestUrl, QAuthenticator* auth);
|
|
|
|
void proxyAuthentication(const QUrl &requestUrl, QAuthenticator* auth, const QString &proxyHost);
|
2011-12-15 19:08:33 +01:00
|
|
|
|
2014-06-06 23:29:49 +02:00
|
|
|
void doWebSearch(const QString &text);
|
2015-05-22 23:18:25 +02:00
|
|
|
void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature);
|
2013-01-23 18:48:51 +01:00
|
|
|
|
2011-05-22 10:47:03 +02:00
|
|
|
private:
|
2015-06-09 18:36:57 +02:00
|
|
|
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE;
|
|
|
|
bool certificateError(const QWebEngineCertificateError &certificateError) Q_DECL_OVERRIDE;
|
2015-06-09 18:01:17 +02:00
|
|
|
QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE;
|
|
|
|
QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) Q_DECL_OVERRIDE;
|
|
|
|
|
2015-01-27 11:01:52 +01:00
|
|
|
#if QTWEBENGINE_DISABLED
|
2012-04-13 13:26:32 +02:00
|
|
|
bool supportsExtension(Extension extension) const;
|
|
|
|
bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
2015-01-27 11:01:52 +01:00
|
|
|
#endif
|
2012-01-21 20:20:48 +01:00
|
|
|
|
2012-04-13 13:26:32 +02:00
|
|
|
void handleUnknownProtocol(const QUrl &url);
|
2012-08-09 19:09:52 +02:00
|
|
|
void desktopServicesOpen(const QUrl &url);
|
2012-04-13 13:26:32 +02:00
|
|
|
|
2012-04-17 18:26:01 +02:00
|
|
|
static QString s_lastUploadLocation;
|
|
|
|
static QUrl s_lastUnsupportedUrl;
|
2012-08-09 19:09:52 +02:00
|
|
|
static QTime s_lastUnsupportedUrlTime;
|
2015-06-09 18:36:57 +02:00
|
|
|
static QStringList s_ignoredSslErrors;
|
2011-05-22 11:05:36 +02:00
|
|
|
|
2013-04-02 13:14:19 +02:00
|
|
|
DelayedFileWatcher* m_fileWatcher;
|
2012-07-13 11:04:14 +02:00
|
|
|
QEventLoop* m_runningLoop;
|
|
|
|
|
2012-07-03 21:54:04 +02:00
|
|
|
QSslCertificate m_sslCert;
|
2013-02-26 12:56:11 +01:00
|
|
|
QVector<QSslCertificate> m_rejectedSslCerts;
|
|
|
|
QVector<AdBlockedEntry> m_adBlockedEntries;
|
2013-05-14 17:25:55 +02:00
|
|
|
QVector<PasswordEntry> m_passwordEntries;
|
2011-07-11 20:30:49 +02:00
|
|
|
|
2012-07-13 11:04:14 +02:00
|
|
|
QUrl m_lastRequestUrl;
|
2011-12-13 15:38:09 +01:00
|
|
|
|
2012-07-03 15:22:42 +02:00
|
|
|
int m_loadProgress;
|
2011-10-26 19:23:50 +02:00
|
|
|
bool m_blockAlerts;
|
2011-07-11 20:30:49 +02:00
|
|
|
bool m_secureStatus;
|
2011-10-30 16:32:36 +01:00
|
|
|
bool m_adjustingScheduled;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBPAGE_H
|