2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 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
|
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QWebPage>
|
|
|
|
#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
|
|
|
|
2013-01-31 11:54:42 +01:00
|
|
|
class QWebSecurityOrigin;
|
2012-02-29 18:33:50 +01:00
|
|
|
class QEventLoop;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
class BrowserWindow;
|
2012-07-01 18:13:49 +02:00
|
|
|
class AdBlockRule;
|
2012-01-21 20:20:48 +01:00
|
|
|
class TabbedWebView;
|
2011-12-02 23:25:27 +01:00
|
|
|
class SpeedDial;
|
2012-01-21 20:20:48 +01:00
|
|
|
class NetworkManagerProxy;
|
2013-04-02 13:14:19 +02:00
|
|
|
class DelayedFileWatcher;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT WebPage : public QWebPage
|
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();
|
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
QUrl url() const;
|
|
|
|
|
|
|
|
void setWebView(TabbedWebView* view);
|
|
|
|
void populateNetworkRequest(QNetworkRequest &request);
|
|
|
|
|
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
|
|
|
|
|
|
|
bool javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg, const QString &defaultValue, QString* result);
|
|
|
|
bool javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg);
|
|
|
|
void javaScriptAlert(QWebFrame* originatingFrame, const QString &msg);
|
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
|
|
|
bool loadingError() const;
|
|
|
|
|
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
|
|
|
|
2013-04-07 20:19:21 +02:00
|
|
|
QWebElement activeElement() const;
|
2012-01-06 17:31:44 +01:00
|
|
|
QString userAgentForUrl(const QUrl &url) const;
|
2011-12-11 19:37:16 +01:00
|
|
|
|
2012-04-02 19:33:05 +02:00
|
|
|
static bool isPointerSafeToUse(WebPage* page);
|
2012-01-14 11:46:06 +01:00
|
|
|
|
2011-07-11 20:30:49 +02:00
|
|
|
signals:
|
|
|
|
void privacyChanged(bool status);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
protected slots:
|
|
|
|
void handleUnsupportedContent(QNetworkReply* url);
|
2012-01-21 20:20:48 +01:00
|
|
|
|
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-02 23:25:27 +01:00
|
|
|
void addJavaScriptObject();
|
2011-10-09 14:51:25 +02:00
|
|
|
|
2011-12-15 19:08:33 +01:00
|
|
|
void watchedFileChanged(const QString &file);
|
2012-01-04 19:02:33 +01:00
|
|
|
void printFrame(QWebFrame* frame);
|
2012-01-21 20:20:48 +01:00
|
|
|
void downloadRequested(const QNetworkRequest &request);
|
2012-03-04 14:25:52 +01:00
|
|
|
void windowCloseRequested();
|
2011-12-15 19:08:33 +01:00
|
|
|
|
2013-01-23 18:48:51 +01:00
|
|
|
void dbQuotaExceeded(QWebFrame* frame);
|
2014-06-06 23:29:49 +02:00
|
|
|
void doWebSearch(const QString &text);
|
2013-01-23 18:48:51 +01:00
|
|
|
|
2012-03-16 13:53:49 +01:00
|
|
|
#ifdef USE_QTWEBKIT_2_2
|
2013-01-31 11:54:42 +01:00
|
|
|
void appCacheQuotaExceeded(QWebSecurityOrigin* origin, quint64 originalQuota);
|
2012-03-15 19:35:37 +01:00
|
|
|
void featurePermissionRequested(QWebFrame* frame, const QWebPage::Feature &feature);
|
|
|
|
#endif
|
|
|
|
|
2012-03-16 13:53:49 +01:00
|
|
|
protected:
|
2012-03-16 15:55:34 +01:00
|
|
|
bool event(QEvent* event);
|
2012-03-16 13:53:49 +01:00
|
|
|
QWebPage* createWindow(QWebPage::WebWindowType type);
|
2012-04-15 15:44:08 +02:00
|
|
|
QObject* createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues);
|
2012-03-16 13:53:49 +01:00
|
|
|
|
2011-05-22 10:47:03 +02:00
|
|
|
private:
|
2012-04-13 13:26:32 +02:00
|
|
|
bool supportsExtension(Extension extension) const;
|
|
|
|
bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
2011-03-17 17:03:04 +01:00
|
|
|
bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type);
|
2011-11-06 17:01:23 +01:00
|
|
|
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
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;
|
2012-04-17 18:26:01 +02:00
|
|
|
static QList<WebPage*> s_livingPages;
|
2011-05-22 11:05:36 +02:00
|
|
|
|
2012-01-21 20:20:48 +01:00
|
|
|
NetworkManagerProxy* m_networkProxy;
|
|
|
|
TabbedWebView* m_view;
|
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
|
|
|
QWebPage::NavigationType m_lastRequestType;
|
|
|
|
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;
|
2014-01-25 17:48:30 +01:00
|
|
|
bool m_javaScriptEnabled;
|
2011-10-30 16:32:36 +01:00
|
|
|
bool m_adjustingScheduled;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WEBPAGE_H
|