2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2016-04-06 17:22:44 +02:00
|
|
|
* Copyright (C) 2010-2016 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>
|
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"
|
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;
|
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
|
|
|
|
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:
|
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;
|
|
|
|
|
2015-09-30 11:01:10 +02:00
|
|
|
QVariant execJavaScript(const QString &scriptSource, int timeout = 500);
|
2015-09-29 21:53:56 +02:00
|
|
|
|
2016-04-06 17:22:44 +02:00
|
|
|
QPoint mapToViewport(const QPoint &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);
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
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);
|
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:
|
2015-06-09 18:36:57 +02:00
|
|
|
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE;
|
2015-09-29 11:37:17 +02:00
|
|
|
bool certificateError(const QWebEngineCertificateError &error) 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;
|
|
|
|
|
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;
|
|
|
|
|
2013-05-14 17:25:55 +02:00
|
|
|
QVector<PasswordEntry> m_passwordEntries;
|
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;
|
2011-10-30 16:32:36 +01:00
|
|
|
bool m_adjustingScheduled;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBPAGE_H
|