summaryrefslogtreecommitdiffstats
path: root/tests/manual/widgets/geolocation/main.cpp
diff options
context:
space:
mode:
authorKaloyan Chehlarski <kaloyan.chehlarski@qt.io>2024-04-02 16:08:15 +0200
committerKaloyan Chehlarski <kaloyan.chehlarski@qt.io>2024-06-03 14:42:44 +0200
commit00d7de830a43a84a431511a55525f04c21b8ba49 (patch)
tree9411fe4666661afa85a11d5a8070968b69747dc4 /tests/manual/widgets/geolocation/main.cpp
parentece3b065828bc6ca09dd2ad8654b48cdaddf1178 (diff)
Add QWebEnginePermission and rewrite permissions API
With the addition of permission persistence, it's now important for us to have an API for querying previously granted/denied permissions, so that they can be revoked at a later point. This change does the bulk of the work to get us there, by introducing a new type representing a single permission for a given URL/Feature pair. This type holds no information about the permission's state; it is simply an accessor object which allows its user to query the current status of the permission, grant/deny it, or reset it back to its initial state (so, delete it from storage). This provides application developers an easy way to store/modify lists of permissions without having to define their own custom types. A subsequent change will expand the API to provide a list of all permissions for a given profile. The current API (in QWebEnginePage and QQuickWebEngineView) has been marked as deprecated, but has not been disabled to ensure a smooth transition for developers. [ChangeLog][QtWebEngineCore][QWebEnginePage] Deprecated old permissions API [ChangeLog][QtWebEngineQuick][WebEngineView] Deprecated old permissions API [ChangeLog][QtWebEngineCore] Added new API for querying and modifying website permissions. [ChangeLog][QtWebEngineQuick] Added new API for querying and modifying website permissions. Pick-to: 6.8 Change-Id: I8661cdc26bbd6dcde6403d29cc083bcea1a49ccc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/manual/widgets/geolocation/main.cpp')
-rw-r--r--tests/manual/widgets/geolocation/main.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/manual/widgets/geolocation/main.cpp b/tests/manual/widgets/geolocation/main.cpp
index f33cf5798..1f4cefe54 100644
--- a/tests/manual/widgets/geolocation/main.cpp
+++ b/tests/manual/widgets/geolocation/main.cpp
@@ -16,18 +16,15 @@ class GeoPermissionWebView : public QWebEngineView {
Q_OBJECT
public slots:
- void handleFeaturePermissionRequested(const QUrl &securityOrigin,
- QWebEnginePage::Feature feature)
+ void handlePermissionRequested(QWebEnginePermission permission)
{
qWarning("Feature Permission");
QString title = tr("Permission Request");
QString question = QLatin1String("Allow access to geolocation?");
if (!question.isEmpty() && QMessageBox::question(window(), title, question) == QMessageBox::Yes)
- page()->setFeaturePermission(securityOrigin, feature,
- QWebEnginePage::PermissionGrantedByUser);
+ permission.grant();
else
- page()->setFeaturePermission(securityOrigin, feature,
- QWebEnginePage::PermissionDeniedByUser);
+ permission.deny();
}
};
@@ -38,8 +35,8 @@ int main(int argc, char *argv[])
QMainWindow w;
GeoPermissionWebView webview;
QWebEnginePage page;
- QObject::connect(&page, &QWebEnginePage::featurePermissionRequested, &webview,
- &GeoPermissionWebView::handleFeaturePermissionRequested);
+ QObject::connect(&page, &QWebEnginePage::permissionRequested, &webview,
+ &GeoPermissionWebView::handlePermissionRequested);
webview.setPage(&page);
page.load(QUrl("qrc:/geolocation.html"));
w.setCentralWidget(&webview);