2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
2017-08-25 17:11:29 +02:00
|
|
|
* Falkon - Qt web browser
|
2018-01-06 13:01:31 +01:00
|
|
|
* Copyright (C) 2010-2018 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>
|
2016-05-10 10:47:35 +02:00
|
|
|
#include <QWebEngineScript>
|
2015-12-08 11:27:06 +01:00
|
|
|
#include <QWebEngineFullScreenRequest>
|
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"
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QEventLoop;
|
2015-05-24 19:22:32 +02:00
|
|
|
class QWebEngineDownloadItem;
|
2019-01-28 17:52:11 +01:00
|
|
|
class QWebEngineRegisterProtocolHandlerRequest;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2015-09-24 23:00:27 +02:00
|
|
|
class WebView;
|
2015-09-29 21:53:56 +02:00
|
|
|
class WebHitTestResult;
|
2013-04-02 13:14:19 +02:00
|
|
|
class DelayedFileWatcher;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2017-08-25 17:11:29 +02:00
|
|
|
class FALKON_EXPORT WebPage : public QWebEnginePage
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2016-12-26 16:45:25 +01:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
public:
|
2016-05-10 10:47:35 +02:00
|
|
|
enum JsWorld {
|
2018-01-10 12:36:41 +01:00
|
|
|
UnsafeJsWorld = QWebEngineScript::MainWorld,
|
2016-12-26 16:45:25 +01:00
|
|
|
SafeJsWorld = QWebEngineScript::ApplicationWorld
|
2016-05-10 10:47:35 +02:00
|
|
|
};
|
|
|
|
|
2015-10-05 20:23:10 +02:00
|
|
|
explicit WebPage(QObject* parent = 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
~WebPage();
|
|
|
|
|
2015-09-24 23:00:27 +02:00
|
|
|
WebView *view() const;
|
|
|
|
|
2017-02-06 20:39:57 +01:00
|
|
|
bool execPrintPage(QPrinter *printer, int timeout = 1000);
|
2018-01-10 12:36:41 +01:00
|
|
|
QVariant execJavaScript(const QString &scriptSource, quint32 worldId = UnsafeJsWorld, int timeout = 500);
|
2016-05-10 10:47:35 +02:00
|
|
|
|
2016-12-27 11:58:10 +01:00
|
|
|
QPointF mapToViewport(const QPointF &pos) const;
|
2015-09-29 21:53:56 +02:00
|
|
|
WebHitTestResult hitTestContent(const QPoint &pos) const;
|
|
|
|
|
2015-10-02 15:23:59 +02:00
|
|
|
void scroll(int x, int y);
|
2016-12-26 12:38:51 +01:00
|
|
|
void setScrollPosition(const QPointF &pos);
|
2015-10-02 15:23:59 +02:00
|
|
|
|
2019-03-01 17:08:50 +01:00
|
|
|
bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result) override;
|
|
|
|
bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) override;
|
|
|
|
void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) override;
|
2018-01-06 20:23:42 +01:00
|
|
|
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2018-01-28 12:24:19 +01:00
|
|
|
QStringList autoFillUsernames() const;
|
2011-03-29 20:30:05 +02:00
|
|
|
|
2019-01-28 17:52:11 +01:00
|
|
|
QUrl registerProtocolHandlerRequestUrl() const;
|
|
|
|
QString registerProtocolHandlerRequestScheme() const;
|
|
|
|
|
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
|
|
|
|
2018-03-16 15:31:07 +01:00
|
|
|
static QStringList internalSchemes();
|
|
|
|
static QStringList supportedSchemes();
|
|
|
|
static void addSupportedScheme(const QString &scheme);
|
|
|
|
static void removeSupportedScheme(const QString &scheme);
|
|
|
|
|
2018-02-25 13:33:07 +01:00
|
|
|
Q_SIGNALS:
|
2011-07-11 20:30:49 +02:00
|
|
|
void privacyChanged(bool status);
|
2018-01-13 11:22:29 +01:00
|
|
|
void printRequested();
|
2018-01-22 14:47:44 +01:00
|
|
|
void navigationRequestAccepted(const QUrl &url, NavigationType type, bool isMainFrame);
|
2011-07-11 20:30:49 +02:00
|
|
|
|
2018-02-25 13:33:07 +01:00
|
|
|
protected Q_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
|
|
|
|
2018-02-25 13:33:07 +01:00
|
|
|
private Q_SLOTS:
|
2011-10-09 14:51:25 +02:00
|
|
|
void urlChanged(const QUrl &url);
|
2011-12-15 19:08:33 +01:00
|
|
|
void watchedFileChanged(const QString &file);
|
2015-09-29 16:18:21 +02:00
|
|
|
void windowCloseRequested();
|
2015-12-08 11:27:06 +01:00
|
|
|
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
|
2015-05-22 23:18:25 +02:00
|
|
|
void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature);
|
2015-10-14 16:19:54 +02:00
|
|
|
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode);
|
2013-01-23 18:48:51 +01:00
|
|
|
|
2011-05-22 10:47:03 +02:00
|
|
|
private:
|
2019-03-01 17:08:50 +01:00
|
|
|
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override;
|
|
|
|
bool certificateError(const QWebEngineCertificateError &error) override;
|
|
|
|
QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) override;
|
|
|
|
QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) override;
|
2015-06-09 18:01:17 +02: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;
|
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;
|
|
|
|
|
2018-01-28 12:24:19 +01:00
|
|
|
QStringList m_autoFillUsernames;
|
2019-01-28 17:52:11 +01:00
|
|
|
QWebEngineRegisterProtocolHandlerRequest *m_registerProtocolHandlerRequest = nullptr;
|
2011-07-11 20:30:49 +02: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;
|
2017-03-15 13:11:27 +01:00
|
|
|
|
|
|
|
QMetaObject::Connection m_contentsResizedConnection;
|
2018-01-13 10:12:54 +01:00
|
|
|
|
|
|
|
friend class WebView;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBPAGE_H
|