1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QABSTRACTWEBVIEW_P_H
5#define QABSTRACTWEBVIEW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qwebviewinterface_p.h"
19
20QT_BEGIN_NAMESPACE
21
22class QWebView;
23class QWebViewSettings;
24class QWebViewLoadRequestPrivate;
25
26class Q_WEBVIEW_EXPORT QAbstractWebViewSettings : public QObject
27{
28 Q_OBJECT
29public:
30 virtual bool localStorageEnabled() const = 0;
31 virtual bool javaScriptEnabled() const = 0;
32 virtual bool localContentCanAccessFileUrls() const = 0;
33 virtual bool allowFileAccess() const = 0;
34
35 virtual void setLocalContentCanAccessFileUrls(bool) = 0;
36 virtual void setJavaScriptEnabled(bool) = 0;
37 virtual void setLocalStorageEnabled(bool) = 0;
38 virtual void setAllowFileAccess(bool) = 0;
39
40protected:
41 explicit QAbstractWebViewSettings(QObject *p = nullptr) : QObject(p) {}
42};
43
44class Q_WEBVIEW_EXPORT QAbstractWebView
45 : public QObject
46{
47 Q_OBJECT
48
49public:
50 virtual QAbstractWebViewSettings *getSettings() const = 0;
51 virtual QString httpUserAgent() const = 0;
52 virtual void setHttpUserAgent(const QString &httpUserAgent) = 0;
53 virtual void setUrl(const QUrl &url) = 0;
54 virtual bool canGoBack() const = 0;
55 virtual bool canGoForward() const = 0;
56 virtual QString title() const = 0;
57 virtual int loadProgress() const = 0;
58 virtual bool isLoading() const = 0;
59 virtual void goBack() = 0;
60 virtual void goForward() = 0;
61 virtual void stop() = 0;
62 virtual void reload() = 0;
63 virtual void loadHtml(const QString &html, const QUrl &baseUrl) = 0;
64 virtual void runJavaScriptPrivate(const QString &script, int callbackId) = 0;
65 virtual void setCookie(const QString &domain, const QString &name, const QString &value) = 0;
66 virtual void deleteCookie(const QString &domain, const QString &name) = 0;
67 virtual void deleteAllCookies() = 0;
68 virtual QWindow *nativeWindow() const = 0;
69 // NOTE: This is a temporary solution for WASM and should
70 // be removed once window containers are supported.
71#if defined(Q_OS_WASM) || 1
72 virtual void setParentView(QObject *) { }
73 virtual void geometryChange(const QRectF &) { }
74#endif // Q_OS_WASM
75
76Q_SIGNALS:
77 void titleChanged(const QString &title);
78 void urlChanged(const QUrl &url);
79 void loadingChanged(const QWebViewLoadRequestPrivate &loadRequest);
80 void loadProgressChanged(int progress);
81 void javaScriptResult(int id, const QVariant &result);
82 void httpUserAgentChanged(const QString &httpUserAgent);
83 void cookieAdded(const QString &domain, const QString &name);
84 void cookieRemoved(const QString &domain, const QString &name);
85 void nativeWindowChanged(QWindow *window);
86
87protected:
88 explicit QAbstractWebView(QObject *p = nullptr) : QObject(p) { }
89};
90
91QT_END_NAMESPACE
92
93#endif // QABSTRACTWEBVIEW_P_H
94
95

source code of qtwebview/src/webview/qabstractwebview_p.h