2012-03-26 18:41:33 -04:00
|
|
|
#ifndef _WEBPAGE_H
|
|
|
|
#define _WEBPAGE_H
|
2013-01-06 22:05:41 -05:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
#include <QtWebKitWidgets>
|
|
|
|
#else
|
2011-02-18 22:53:06 -05:00
|
|
|
#include <QtWebKit>
|
2013-01-06 22:05:41 -05:00
|
|
|
#endif
|
2013-02-14 14:19:17 -05:00
|
|
|
#include <QtNetwork>
|
2011-02-18 22:53:06 -05:00
|
|
|
|
2012-03-28 23:05:24 -04:00
|
|
|
class WebPageManager;
|
2013-01-20 18:57:04 -05:00
|
|
|
class InvocationResult;
|
2012-11-18 02:48:12 -05:00
|
|
|
class NetworkReplyProxy;
|
2014-06-18 18:00:34 -04:00
|
|
|
class QWebView;
|
2012-03-28 23:05:24 -04:00
|
|
|
|
2011-02-18 22:53:06 -05:00
|
|
|
class WebPage : public QWebPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-03-28 23:05:24 -04:00
|
|
|
WebPage(WebPageManager *, QObject *parent = 0);
|
2013-12-06 10:43:17 -05:00
|
|
|
InvocationResult invokeCapybaraFunction(const char *name, bool allowUnattached, const QStringList &arguments);
|
|
|
|
InvocationResult invokeCapybaraFunction(QString &name, bool allowUnattached, const QStringList &arguments);
|
2011-03-09 00:08:30 -05:00
|
|
|
QString failureString();
|
2011-06-08 05:36:45 -04:00
|
|
|
QString userAgentForUrl(const QUrl &url ) const;
|
2011-06-25 07:31:19 -04:00
|
|
|
void setUserAgent(QString userAgent);
|
2012-07-10 09:47:17 -04:00
|
|
|
void setConfirmAction(QString action);
|
2014-07-03 18:21:21 -04:00
|
|
|
QString setConfirmAction(QString action, QString message);
|
|
|
|
QString setPromptAction(QString action, QString message, QString response);
|
|
|
|
QString setPromptAction(QString action, QString message);
|
2012-07-10 09:47:17 -04:00
|
|
|
void setPromptAction(QString action);
|
|
|
|
void setPromptText(QString action);
|
2014-07-03 18:21:21 -04:00
|
|
|
QString acceptAlert(QString);
|
2011-08-12 16:50:43 -04:00
|
|
|
int getLastStatus();
|
2011-08-23 11:18:08 -04:00
|
|
|
void setCustomNetworkAccessManager();
|
2013-01-13 17:19:46 -05:00
|
|
|
bool render(const QString &fileName, const QSize &minimumSize);
|
2011-07-20 15:58:23 -04:00
|
|
|
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
|
2012-03-29 21:38:34 -04:00
|
|
|
void setSkipImageLoading(bool skip);
|
2012-12-29 20:48:15 -05:00
|
|
|
QVariantList consoleMessages();
|
2012-12-30 14:41:23 -05:00
|
|
|
QVariantList alertMessages();
|
2012-12-30 14:28:45 -05:00
|
|
|
QVariantList confirmMessages();
|
2012-12-30 15:04:44 -05:00
|
|
|
QVariantList promptMessages();
|
2014-06-18 18:00:34 -04:00
|
|
|
void createWindow();
|
2013-04-25 23:00:21 -04:00
|
|
|
void resetLocalStorage();
|
2012-03-26 18:41:33 -04:00
|
|
|
QWebPage *createWindow(WebWindowType type);
|
2012-03-27 18:49:57 -04:00
|
|
|
QString uuid();
|
2012-03-28 11:46:07 -04:00
|
|
|
QString getWindowName();
|
2012-03-28 15:20:32 -04:00
|
|
|
bool matchesWindowSelector(QString);
|
2012-04-04 18:18:17 -04:00
|
|
|
void setFocus();
|
2012-12-03 22:47:10 -05:00
|
|
|
void unsupportedContentFinishedReply(QNetworkReply *reply);
|
2012-11-18 02:48:12 -05:00
|
|
|
QStringList pageHeaders();
|
|
|
|
QByteArray body();
|
|
|
|
QString contentType();
|
2013-11-09 15:12:16 -05:00
|
|
|
void mouseEvent(QEvent::Type type, const QPoint &position, Qt::MouseButton button);
|
|
|
|
bool clickTest(QWebElement element, int absoluteX, int absoluteY);
|
2014-06-18 18:00:34 -04:00
|
|
|
void resize(int, int);
|
2014-07-03 18:21:21 -04:00
|
|
|
int modalCount();
|
|
|
|
QString modalMessage(int);
|
2011-02-18 22:53:06 -05:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
bool shouldInterruptJavaScript();
|
2011-02-25 22:32:22 -05:00
|
|
|
void injectJavascriptHelpers();
|
2011-03-09 00:08:30 -05:00
|
|
|
void loadStarted();
|
|
|
|
void loadFinished(bool);
|
|
|
|
bool isLoading() const;
|
2011-04-19 03:16:25 -04:00
|
|
|
void frameCreated(QWebFrame *);
|
2012-05-04 13:56:21 -04:00
|
|
|
void handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &);
|
2011-09-15 11:22:10 -04:00
|
|
|
void handleUnsupportedContent(QNetworkReply *reply);
|
2012-11-18 02:48:12 -05:00
|
|
|
void replyFinished(QUrl &, QNetworkReply *);
|
2014-06-18 18:00:34 -04:00
|
|
|
void remove();
|
2011-09-15 11:22:10 -04:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void pageFinished(bool);
|
2012-07-11 23:36:22 -04:00
|
|
|
void requestCreated(QByteArray &url, QNetworkReply *reply);
|
2012-06-29 10:41:08 -04:00
|
|
|
void replyFinished(QNetworkReply *reply);
|
2011-02-25 22:32:22 -05:00
|
|
|
|
2011-02-26 13:02:43 -05:00
|
|
|
protected:
|
|
|
|
virtual void javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID);
|
2011-03-11 12:07:30 -05:00
|
|
|
virtual void javaScriptAlert(QWebFrame *frame, const QString &message);
|
|
|
|
virtual bool javaScriptConfirm(QWebFrame *frame, const QString &message);
|
|
|
|
virtual bool javaScriptPrompt(QWebFrame *frame, const QString &message, const QString &defaultValue, QString *result);
|
2011-07-18 17:16:57 -04:00
|
|
|
virtual QString chooseFile(QWebFrame * parentFrame, const QString &suggestedFile);
|
2012-04-03 21:27:41 -04:00
|
|
|
virtual bool supportsExtension(Extension extension) const;
|
2011-02-26 13:02:43 -05:00
|
|
|
|
2011-02-25 22:32:22 -05:00
|
|
|
private:
|
|
|
|
QString m_capybaraJavascript;
|
2011-06-25 07:31:19 -04:00
|
|
|
QString m_userAgent;
|
2011-03-09 00:08:30 -05:00
|
|
|
bool m_loading;
|
2012-07-10 23:03:32 -04:00
|
|
|
bool m_failed;
|
2012-11-18 02:48:24 -05:00
|
|
|
QStringList getAttachedFileNames();
|
2011-08-12 15:49:40 -04:00
|
|
|
void loadJavascript();
|
2011-08-12 15:26:26 -04:00
|
|
|
void setUserStylesheet();
|
2014-07-03 18:21:21 -04:00
|
|
|
bool m_confirmAction;
|
|
|
|
bool m_promptAction;
|
2012-12-29 20:48:15 -05:00
|
|
|
QVariantList m_consoleMessages;
|
2012-12-30 14:41:23 -05:00
|
|
|
QVariantList m_alertMessages;
|
2012-12-30 14:28:45 -05:00
|
|
|
QVariantList m_confirmMessages;
|
2012-07-10 09:47:17 -04:00
|
|
|
QString m_prompt_text;
|
2012-12-30 15:04:44 -05:00
|
|
|
QVariantList m_promptMessages;
|
2012-03-27 18:49:57 -04:00
|
|
|
QString m_uuid;
|
2012-03-28 23:05:24 -04:00
|
|
|
WebPageManager *m_manager;
|
2012-04-03 21:27:41 -04:00
|
|
|
QString m_errorPageMessage;
|
2012-11-18 02:48:12 -05:00
|
|
|
void setFrameProperties(QWebFrame *, QUrl &, NetworkReplyProxy *);
|
2013-11-09 15:12:16 -05:00
|
|
|
QPoint m_mousePosition;
|
2014-07-03 18:21:21 -04:00
|
|
|
QList<QVariantMap> m_modalResponses;
|
|
|
|
QStringList m_modalMessages;
|
|
|
|
void addModalMessage(bool, const QString &, const QRegExp &);
|
2011-02-18 22:53:06 -05:00
|
|
|
};
|
|
|
|
|
2012-03-26 18:41:33 -04:00
|
|
|
#endif //_WEBPAGE_H
|
|
|
|
|