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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
// Copyright (C) 2025 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
// Qt-Security score:significant reason:default
#include "qwebengineextensioninfo.h"
#include "qwebengineextensioninfo_p.h"
#if QT_CONFIG(webengine_extensions)
#include <QtCore/qdir.h>
#include <QtCore/qfileinfo.h>
#include "extensions/extension_manager.h"
using namespace Qt::StringLiterals;
QT_BEGIN_NAMESPACE
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QWebEngineExtensionInfoPrivate)
/*!
\class QWebEngineExtensionInfo
\brief The QWebEngineExtensionInfo provides information about a browser extension.
\since 6.10
\inmodule QtWebEngineCore
QWebEngineExtensionInfo provides information of an extension loaded into \QWE.
Extensions can be loaded via the \l QWebEngineExtensionManager.
You can check if the extension was successfully loaded using its \l isLoaded() property.
The \l error() property contains error messages if the loading process failed.
Extensions are always loaded in disabled state. To run an extension, it has to be enabled via
\l QWebEngineExtensionManager::setExtensionEnabled().
An extension can be removed using \l QWebEngineExtensionManager::unloadExtension().
You can access extensions with \l QWebEngineExtensionManager::extensions() which provides a list
of the loaded extensions, or connect to the manager's signals to be notified if the loading
process is complete.
\sa QWebEngineExtensionManager, QWebEngineProfile::extensionManager()
*/
QWebEngineExtensionInfoPrivate::QWebEngineExtensionInfoPrivate(
const ExtensionData &data, QtWebEngineCore::ExtensionManager *manager)
: QSharedData(), m_data(data), m_manager(manager)
{
}
QWebEngineExtensionInfoPrivate::~QWebEngineExtensionInfoPrivate() = default;
QString QWebEngineExtensionInfoPrivate::name() const
{
return m_data.name;
}
std::string QWebEngineExtensionInfoPrivate::id() const
{
return m_data.id;
}
QString QWebEngineExtensionInfoPrivate::description() const
{
return m_data.description;
}
QString QWebEngineExtensionInfoPrivate::path() const
{
return m_data.path;
}
QString QWebEngineExtensionInfoPrivate::error() const
{
return m_data.error;
}
QUrl QWebEngineExtensionInfoPrivate::actionPopupUrl() const
{
return m_data.actionPopupUrl;
}
bool QWebEngineExtensionInfoPrivate::isEnabled() const
{
return m_manager->isExtensionEnabled(id());
}
bool QWebEngineExtensionInfoPrivate::isLoaded() const
{
return m_manager->isExtensionLoaded(id());
}
bool QWebEngineExtensionInfoPrivate::isInstalled() const
{
return QFileInfo(m_data.path).dir() == QDir(m_manager->installDirectory());
}
QWebEngineExtensionInfo::QWebEngineExtensionInfo() : d_ptr(nullptr) { }
QWebEngineExtensionInfo::QWebEngineExtensionInfo(QWebEngineExtensionInfoPrivate *d) : d_ptr(d) { }
QWebEngineExtensionInfo::QWebEngineExtensionInfo(const QWebEngineExtensionInfo &other) noexcept =
default;
QWebEngineExtensionInfo &
QWebEngineExtensionInfo::operator=(const QWebEngineExtensionInfo &other) noexcept = default;
QWebEngineExtensionInfo::~QWebEngineExtensionInfo() = default;
/*!
\property QWebEngineExtensionInfo::name
\brief The name of the extension.
Acquired from the extension's manifest file's name property.
Empty if the load failed.
*/
QString QWebEngineExtensionInfo::name() const
{
return d_ptr ? d_ptr->name() : ""_L1;
}
/*!
\property QWebEngineExtensionInfo::id
\brief The id of the extension.
Generated at load time. Multiple QWebEngineExtensionInfo objects with the same id
represent the same underlying extension.
The id is generated from the filesystem path where the extension was loaded from
and the extensions manfiest file. Loading the same extension from the same path
always have the same id.
Empty if the load failed.
*/
QString QWebEngineExtensionInfo::id() const
{
return d_ptr ? QString::fromStdString(d_ptr->id()) : ""_L1;
}
/*!
\property QWebEngineExtensionInfo::name
\brief The description of the extension.
Acquired from the extension's manifest file's description property.
Empty if the load failed.
*/
QString QWebEngineExtensionInfo::description() const
{
return d_ptr ? d_ptr->description() : ""_L1;
}
/*!
\property QWebEngineExtensionInfo::path
\brief The install path of the extension.
The filesystem path where the extension was loaded from.
*/
QString QWebEngineExtensionInfo::path() const
{
return d_ptr ? d_ptr->path() : ""_L1;
}
/*!
\property QWebEngineExtensionInfo::error
\brief Errors happened during loading, installing or uninstalling the extension.
Multiple errors can happen during load time, like missing manifest, invalid file format
or path. The loading process stops at the first error.
Empty if the load succeeded.
*/
QString QWebEngineExtensionInfo::error() const
{
return d_ptr ? d_ptr->error() : ""_L1;
}
/*!
\property QWebEngineExtensionInfo::actionPopupUrl
\brief Returns the url of the extension's popup.
Extension developers usually provide a popup menu where users can control
their extension. The menu can be accessed via this url.
Empty if the load failed.
*/
QUrl QWebEngineExtensionInfo::actionPopupUrl() const
{
return d_ptr ? d_ptr->actionPopupUrl() : QUrl(""_L1);
}
/*!
\property QWebEngineExtensionInfo::isEnabled
\brief This property holds whether the extension is enabled.
\sa QWebEngineExtensionManager::setExtensionEnabled()
*/
bool QWebEngineExtensionInfo::isEnabled() const
{
return d_ptr && d_ptr->isEnabled();
}
/*!
\property QWebEngineExtensionInfo::isLoaded
\brief This property holds whether the extension is loaded.
If the extension was loaded or installed successfully this property returns \c true.
Returns false if the extension was unloaded, uninstalled or the loading process failed.
\sa QWebEngineExtensionManager::loadExtension(), QWebEngineExtensionManager::unloadExtension()
*/
bool QWebEngineExtensionInfo::isLoaded() const
{
return d_ptr && d_ptr->isLoaded();
}
/*
\property QWebEngineExtensionInfo::isInstalled
\brief This property holds whether the extension is installed in the profile's install
directory.
\sa QWebEngineExtensionManager::installDirectory(),
QWebEngineExtensionManager::installExtension(), QWebEngineExtensionManager::uninstallExtension()
*/
bool QWebEngineExtensionInfo::isInstalled() const
{
return d_ptr && d_ptr->isInstalled();
}
QT_END_NAMESPACE
#endif // QT_CONFIG(webengine_extensions)
|