From f4ca67aa7f70f58d39ef8689ddd5910e215ed6cd Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 31 Jan 2019 13:08:21 +0100 Subject: Web Notifications API Implements API for end-user notifications. Co-authored by Allan Sandfeld Jensen [ChangeLog][Profile] Support for Web Notifications API for end-user notifications through QWebEngineNotification Task-number: QTBUG-50995 Fixes: QTBUG-51191 Change-Id: Icebaaa05275a713e801f1f8ecdaaec725fa264c8 Reviewed-by: Allan Sandfeld Jensen --- src/webengine/api/qquickwebengineprofile.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/webengine/api/qquickwebengineprofile.cpp') diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 8a6c20f67..cf9dae90a 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -46,6 +46,7 @@ #include "qquickwebenginesettings_p.h" #include "qquickwebengineview_p_p.h" #include "qwebenginecookiestore.h" +#include "qwebenginenotification.h" #include @@ -150,6 +151,13 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC The \a download argument holds the state of the finished download instance. */ +/*! + \fn QQuickWebEngineProfile::userNotification(QWebEngineNotification *notification) + + This signal is emitted whenever there is a newly created user notification. + The \a notification argument holds the notification instance to query data and interact with. +*/ + QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(ProfileAdapter *profileAdapter) : m_settings(new QQuickWebEngineSettings()) , m_profileAdapter(profileAdapter) @@ -285,6 +293,14 @@ void QQuickWebEngineProfilePrivate::useForGlobalCertificateVerificationChanged() Q_EMIT q->useForGlobalCertificateVerificationChanged(); } +void QQuickWebEngineProfilePrivate::showNotification(QSharedPointer &controller) +{ + Q_Q(QQuickWebEngineProfile); + auto notification = new QWebEngineNotification(controller); + QQmlEngine::setObjectOwnership(notification, QQmlEngine::JavaScriptOwnership); + Q_EMIT q->userNotification(notification); +} + void QQuickWebEngineProfilePrivate::userScripts_append(QQmlListProperty *p, QQuickWebEngineScript *script) { Q_ASSERT(p && p->data); @@ -364,6 +380,13 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty