// qwebenginepage.sip generated by MetaSIP
//
// This file is part of the QtWebEngineWidgets Python extension module.
//
// Copyright (c) 2016 Riverbank Computing Limited <info@riverbankcomputing.com>
// 
// This file is part of PyQt5.
// 
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file.  Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
// 
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license.  For more information contact
// info@riverbankcomputing.com.
// 
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.


%If (Qt_5_4_0 -)

class QWebEnginePage : QObject
{
%TypeHeaderCode
#include <qwebenginepage.h>
%End

public:
    enum WebAction
    {
        NoWebAction,
        Back,
        Forward,
        Stop,
        Reload,
        Cut,
        Copy,
        Paste,
        Undo,
        Redo,
        SelectAll,
        ReloadAndBypassCache,
        PasteAndMatchStyle,
%If (Qt_5_6_0 -)
        OpenLinkInThisWindow,
%End
%If (Qt_5_6_0 -)
        OpenLinkInNewWindow,
%End
%If (Qt_5_6_0 -)
        OpenLinkInNewTab,
%End
%If (Qt_5_6_0 -)
        CopyLinkToClipboard,
%End
%If (Qt_5_6_0 -)
        DownloadLinkToDisk,
%End
%If (Qt_5_6_0 -)
        CopyImageToClipboard,
%End
%If (Qt_5_6_0 -)
        CopyImageUrlToClipboard,
%End
%If (Qt_5_6_0 -)
        DownloadImageToDisk,
%End
%If (Qt_5_6_0 -)
        CopyMediaUrlToClipboard,
%End
%If (Qt_5_6_0 -)
        ToggleMediaControls,
%End
%If (Qt_5_6_0 -)
        ToggleMediaLoop,
%End
%If (Qt_5_6_0 -)
        ToggleMediaPlayPause,
%End
%If (Qt_5_6_0 -)
        ToggleMediaMute,
%End
%If (Qt_5_6_0 -)
        DownloadMediaToDisk,
%End
%If (Qt_5_6_0 -)
        InspectElement,
%End
%If (Qt_5_6_0 -)
        ExitFullScreen,
%End
%If (Qt_5_6_0 -)
        RequestClose,
%End
    };

    enum FindFlag
    {
        FindBackward,
        FindCaseSensitively,
    };

    typedef QFlags<QWebEnginePage::FindFlag> FindFlags;

    enum WebWindowType
    {
        WebBrowserWindow,
        WebBrowserTab,
        WebDialog,
    };

    enum PermissionPolicy
    {
        PermissionUnknown,
        PermissionGrantedByUser,
        PermissionDeniedByUser,
    };

    enum Feature
    {
        Geolocation,
        MediaAudioCapture,
        MediaVideoCapture,
        MediaAudioVideoCapture,
%If (Qt_5_5_0 -)
        MouseLock,
%End
    };

    enum FileSelectionMode
    {
        FileSelectOpen,
        FileSelectOpenMultiple,
    };

    enum JavaScriptConsoleMessageLevel
    {
        InfoMessageLevel,
        WarningMessageLevel,
        ErrorMessageLevel,
    };

    explicit QWebEnginePage(QObject *parent /TransferThis/ = 0);
%If (Qt_5_5_0 -)
    QWebEnginePage(QWebEngineProfile *profile, QObject *parent /TransferThis/ = 0);
%End
    virtual ~QWebEnginePage();
    QWebEngineHistory *history() const;
    void setView(QWidget *view);
    QWidget *view() const;
    bool hasSelection() const;
    QString selectedText() const;
    QAction *action(QWebEnginePage::WebAction action) const;
    virtual void triggerAction(QWebEnginePage::WebAction action, bool checked = false);
    virtual bool event(QEvent *);
    void findText(const QString &subString, QFlags<QWebEnginePage::FindFlag> options = 0, SIP_PYCALLABLE resultCallback /AllowNone/ = 0);
%MethodCode
        // Make sure any callable doesn't get garbage collected.
        Py_XINCREF(a2);
        
        Py_BEGIN_ALLOW_THREADS
        
        sipCpp->findText(*a0, *a1, [a2](bool arg) {
            if (a2)
            {
                SIP_BLOCK_THREADS
                
                PyObject *res;
        
                res = PyObject_CallFunctionObjArgs(a2, (arg ? Py_True : Py_False), NULL);
        
                Py_DECREF(a2);
        
                if (!res)
                    pyqt5_qtwebenginewidgets_err_print();
                else
                    Py_DECREF(res);
        
                SIP_UNBLOCK_THREADS
            }
        });
        
        Py_END_ALLOW_THREADS
%End

    QMenu *createStandardContextMenu() /Factory/;
    void setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy);
    void load(const QUrl &url);
    void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
    void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
    void toHtml(SIP_PYCALLABLE resultCallback) const;
%MethodCode
        // Make sure the callable doesn't get garbage collected.
        Py_INCREF(a0);
        
        Py_BEGIN_ALLOW_THREADS
        
        sipCpp->toHtml([a0](const QString &arg) {
            SIP_BLOCK_THREADS
            
            PyObject *res;
        
            res = sipCallMethod(NULL, a0, "N", new QString(arg), sipType_QString, NULL);
        
            Py_DECREF(a0);
            
            if (!res)
                pyqt5_qtwebenginewidgets_err_print();
            else
                Py_DECREF(res);
            
            SIP_UNBLOCK_THREADS
        });
        
        Py_END_ALLOW_THREADS
%End

    void toPlainText(SIP_PYCALLABLE resultCallback) const;
%MethodCode
        // Make sure the callable doesn't get garbage collected.
        Py_INCREF(a0);
        
        Py_BEGIN_ALLOW_THREADS
        
        sipCpp->toPlainText([a0](const QString &arg) {
            SIP_BLOCK_THREADS
            
            PyObject *res;
        
            res = sipCallMethod(NULL, a0, "N", new QString(arg), sipType_QString, NULL);
        
            Py_DECREF(a0);
            
            if (!res)
                pyqt5_qtwebenginewidgets_err_print();
            else
                Py_DECREF(res);
            
            SIP_UNBLOCK_THREADS
        });
        
        Py_END_ALLOW_THREADS
%End

    QString title() const;
    void setUrl(const QUrl &url);
    QUrl url() const;
    QUrl requestedUrl() const;
    QUrl iconUrl() const;
    qreal zoomFactor() const;
    void setZoomFactor(qreal factor);
    void runJavaScript(const QString &scriptSource);
    void runJavaScript(const QString &scriptSource, SIP_PYCALLABLE resultCallback);
%MethodCode
        // Make sure the callable doesn't get garbage collected.
        Py_INCREF(a1);
        
        Py_BEGIN_ALLOW_THREADS
        
        sipCpp->runJavaScript(*a0, [a1](const QVariant &arg) {
            SIP_BLOCK_THREADS
            
            PyObject *res;
        
            res = sipCallMethod(NULL, a1, "N", new QVariant(arg), sipType_QVariant, NULL);
        
            Py_DECREF(a1);
        
            if (!res)
                pyqt5_qtwebenginewidgets_err_print();
            else
                Py_DECREF(res);
        
            SIP_UNBLOCK_THREADS
        });
        
        Py_END_ALLOW_THREADS
%End

    QWebEngineSettings *settings() const;

signals:
    void loadStarted();
    void loadProgress(int progress);
    void loadFinished(bool ok);
    void linkHovered(const QString &url);
    void selectionChanged();
    void geometryChangeRequested(const QRect &geom);
    void windowCloseRequested();
    void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature);
    void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature);
    void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
    void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
    void titleChanged(const QString &title);
    void urlChanged(const QUrl &url);
    void iconUrlChanged(const QUrl &url);

protected:
    virtual QWebEnginePage *createWindow(QWebEnginePage::WebWindowType type);
    virtual QStringList chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes);
    virtual void javaScriptAlert(const QUrl &securityOrigin, const QString &msg);
    virtual bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg);
    virtual bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString *result);
    virtual void javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
    virtual bool certificateError(const QWebEngineCertificateError &certificateError /NoCopy/);

public:
%If (Qt_5_5_0 -)

    enum NavigationType
    {
        NavigationTypeLinkClicked,
        NavigationTypeTyped,
        NavigationTypeFormSubmitted,
        NavigationTypeBackForward,
        NavigationTypeReload,
        NavigationTypeOther,
    };

%End
%If (Qt_5_5_0 -)
    QWebEngineProfile *profile() const;
%End
%If (Qt_5_5_0 -)
    QWebEngineScriptCollection &scripts();
%End
%If (Qt_5_5_0 -)
    QWebChannel *webChannel() const;
%End
%If (Qt_5_5_0 -)
    void setWebChannel(QWebChannel *);
%End

protected:
%If (Qt_5_5_0 -)
    virtual bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame);
%End

public:
%If (Qt_5_6_0 -)

    enum RenderProcessTerminationStatus
    {
        NormalTerminationStatus,
        AbnormalTerminationStatus,
        CrashedTerminationStatus,
        KilledTerminationStatus,
    };

%End
%If (Qt_5_6_0 -)
    QColor backgroundColor() const;
%End
%If (Qt_5_6_0 -)
    void setBackgroundColor(const QColor &color);
%End

signals:
%If (Qt_5_6_0 -)
    void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
%End
%If (Qt_5_6_0 -)
    void renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode);
%End

private:
%If (Qt_5_6_0 -)
    QWebEnginePage(const QWebEnginePage &);
%End
};

%End
