blob: 65e884a8f1bf5c2277edd0d05b9dd1fc64c2232b (
plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWASMWEBVIEW_P_H
#define QWASMWEBVIEW_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
#include <QtCore/qpointer.h>
#include <QtGui/qwindow.h>
#include <QtGui/qpa/qplatformwindow.h>
#include <QtGui/qpa/qplatformwindow_p.h>
#include <emscripten/val.h>
#include <private/qabstractwebview_p.h>
#include <optional>
QT_BEGIN_NAMESPACE
class QWasmWebViewSettingsPrivate final : public QAbstractWebViewSettings
{
Q_OBJECT
public:
explicit QWasmWebViewSettingsPrivate(QObject *p = nullptr);
bool localStorageEnabled() const final;
bool javaScriptEnabled() const final;
bool localContentCanAccessFileUrls() const final;
bool allowFileAccess() const final;
public Q_SLOTS:
void setLocalContentCanAccessFileUrls(bool enabled) final;
void setJavaScriptEnabled(bool enabled) final;
void setLocalStorageEnabled(bool enabled) final;
void setAllowFileAccess(bool enabled) final;
};
class QWasmWebViewPrivate final : public QAbstractWebView
{
Q_OBJECT
public:
explicit QWasmWebViewPrivate(QObject *p = nullptr);
~QWasmWebViewPrivate() override;
QString httpUserAgent() const final;
void setHttpUserAgent(const QString &httpUserAgent) final;
void setUrl(const QUrl &url) final;
bool canGoBack() const final;
bool canGoForward() const final;
QString title() const final;
int loadProgress() const final;
bool isLoading() const final;
QWindow *nativeWindow() const override { return m_window; }
// NOTE: This is a temporary solution for WASM and should
// be removed once window containers are supported.
void setParentView(QObject *view) override;
void geometryChange(const QRectF &geometry) override;
public Q_SLOTS:
void goBack() final;
void goForward() final;
void reload() final;
void stop() final;
void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()) final;
void setCookie(const QString &domain, const QString &name, const QString &value) final;
void deleteCookie(const QString &domain, const QString &name) final;
void deleteAllCookies() final;
protected:
void runJavaScriptPrivate(const QString& script,
int callbackId) final;
QAbstractWebViewSettings *getSettings() const final;
private:
Q_INVOKABLE void initializeIFrame();
void updateGeometry();
QWasmWebViewSettingsPrivate *m_settings;
QPointer<QWindow> m_parentWindow;
QWindow *m_window = nullptr;
std::optional<emscripten::val> m_iframe;
std::optional<QRect> m_geometry;
QUrl m_currentUrl;
};
QT_END_NAMESPACE
#endif // QWASMWEBVIEW_P_H
|