Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 85 lines (77 sloc) 3.067 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#ifndef _WEBPAGE_H
#define _WEBPAGE_H
#include <QtWebKit>

class WebPageManager;
class NetworkAccessManager;

class WebPage : public QWebPage {
  Q_OBJECT

  public:
    WebPage(WebPageManager *, QObject *parent = 0);
    QVariant invokeCapybaraFunction(const char *name, const QStringList &arguments);
    QVariant invokeCapybaraFunction(QString &name, const QStringList &arguments);
    QString failureString();
    QString userAgentForUrl(const QUrl &url ) const;
    void setUserAgent(QString userAgent);
    void setConfirmAction(QString action);
    void setPromptAction(QString action);
    void setPromptText(QString action);
    int getLastStatus();
    void setCustomNetworkAccessManager();
    bool render(const QString &fileName, const QSize &minimumSize);
    virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
    void setSkipImageLoading(bool skip);
    QVariantList consoleMessages();
    QVariantList alertMessages();
    QVariantList confirmMessages();
    QVariantList promptMessages();
    void resetWindowSize();
    QWebPage *createWindow(WebWindowType type);
    QString uuid();
    QString getWindowName();
    bool matchesWindowSelector(QString);
    void setFocus();
    NetworkAccessManager *networkAccessManager();
    bool unsupportedContentLoaded();
    void unsupportedContentFinishedReply(QNetworkReply *reply);

  public slots:
    bool shouldInterruptJavaScript();
    void injectJavascriptHelpers();
    void loadStarted();
    void loadFinished(bool);
    bool isLoading() const;
    const QList<QNetworkReply::RawHeaderPair> &pageHeaders();
    void frameCreated(QWebFrame *);
    void handleSslErrorsForReply(QNetworkReply *reply, const QList<QSslError> &);
    void handleUnsupportedContent(QNetworkReply *reply);

  signals:
    void pageFinished(bool);
    void requestCreated(QByteArray &url, QNetworkReply *reply);
    void replyFinished(QNetworkReply *reply);

  protected:
    virtual void javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID);
    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);
    virtual QString chooseFile(QWebFrame * parentFrame, const QString &suggestedFile);
    virtual bool supportsExtension(Extension extension) const;

  private:
    QString m_capybaraJavascript;
    QString m_userAgent;
    bool m_loading;
    bool m_failed;
    QStringList getAttachedFileNames();
    void loadJavascript();
    void setUserStylesheet();
    bool m_confirm;
    bool m_prompt;
    QVariantList m_consoleMessages;
    QVariantList m_alertMessages;
    QVariantList m_confirmMessages;
    QString m_prompt_text;
    QVariantList m_promptMessages;
    QString m_uuid;
    WebPageManager *m_manager;
    QString m_errorPageMessage;
    bool m_unsupportedContentLoaded;
};

#endif //_WEBPAGE_H
Something went wrong with that request. Please try again.