summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/api/qwebenginenotification.cpp275
-rw-r--r--src/core/api/qwebenginenotification.h112
-rw-r--r--src/core/content_browser_client_qt.cpp10
-rw-r--r--src/core/content_browser_client_qt.h2
-rw-r--r--src/core/core_chromium.pri4
-rw-r--r--src/core/permission_manager_qt.cpp8
-rw-r--r--src/core/platform_notification_service_qt.cpp208
-rw-r--r--src/core/platform_notification_service_qt.h92
-rw-r--r--src/core/profile_adapter.h14
-rw-r--r--src/core/profile_adapter_client.h4
-rw-r--r--src/core/profile_qt.cpp1
-rw-r--r--src/core/user_notification_controller.cpp219
-rw-r--r--src/core/user_notification_controller.h114
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/core/web_contents_delegate_qt.cpp5
-rw-r--r--src/core/web_contents_delegate_qt.h1
19 files changed, 1074 insertions, 5 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index b5bb93847..d6ef81add 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -38,6 +38,7 @@ HEADERS = \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginehttprequest.h \
+ qwebenginenotification.h \
qwebenginequotarequest.h \
qwebengineregisterprotocolhandlerrequest.h \
qwebengineurlrequestinterceptor.h \
@@ -51,6 +52,7 @@ SOURCES = \
qtwebenginecoreglobal.cpp \
qwebenginecookiestore.cpp \
qwebenginehttprequest.cpp \
+ qwebenginenotification.cpp \
qwebenginequotarequest.cpp \
qwebengineregisterprotocolhandlerrequest.cpp \
qwebengineurlrequestinfo.cpp \
diff --git a/src/core/api/qwebenginenotification.cpp b/src/core/api/qwebenginenotification.cpp
new file mode 100644
index 000000000..0b91cf273
--- /dev/null
+++ b/src/core/api/qwebenginenotification.cpp
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginenotification.h"
+
+#include "user_notification_controller.h"
+
+#include <QExplicitlySharedDataPointer>
+
+QT_BEGIN_NAMESPACE
+
+using QtWebEngineCore::UserNotificationController;
+
+/*!
+ \class QWebEngineNotification
+ \brief The QWebEngineNotification class encapsulates the data of an HTML5 web notification.
+ \since 5.13
+
+ \inmodule QtWebEngineCore
+
+ This class contains the information and API for HTML5 desktop and push notifications.
+*/
+
+class QWebEngineNotificationPrivate : public UserNotificationController::Client {
+public:
+ QWebEngineNotificationPrivate(QWebEngineNotification *q, const QSharedPointer<UserNotificationController> &controller)
+ : controller(controller)
+ , q(q)
+ {
+ controller->setClient(this);
+ }
+ ~QWebEngineNotificationPrivate() override
+ {
+ if (controller->client() == this)
+ controller->setClient(0);
+ }
+
+ // UserNotificationController::Client:
+ virtual void notificationClosed(const UserNotificationController *) Q_DECL_OVERRIDE
+ {
+ Q_EMIT q->closed();
+ }
+
+ QSharedPointer<UserNotificationController> controller;
+ QWebEngineNotification *q;
+};
+
+
+/*!
+ Creates a null QWebEngineNotification.
+
+ \sa isNull()
+*/
+QWebEngineNotification::QWebEngineNotification() { }
+
+/*! \internal
+*/
+QWebEngineNotification::QWebEngineNotification(const QSharedPointer<UserNotificationController> &controller)
+ : d_ptr(new QWebEngineNotificationPrivate(this, controller))
+{ }
+
+/*! \internal
+*/
+QWebEngineNotification::QWebEngineNotification(const QWebEngineNotification &other)
+ : QObject()
+ , d_ptr(new QWebEngineNotificationPrivate(this, other.d_ptr->controller))
+{ }
+
+/*! \internal
+*/
+QWebEngineNotification::~QWebEngineNotification()
+{
+}
+
+/*! \internal
+*/
+const QWebEngineNotification &QWebEngineNotification::operator=(const QWebEngineNotification &other)
+{
+ d_ptr.reset(new QWebEngineNotificationPrivate(this, other.d_ptr->controller));
+ return *this;
+}
+
+/*!
+ Returns \c true if the two notifications belong to the same message chain.
+ That is, if their tag() and origin() are the same. This means one is
+ a replacement or an update of the \a other.
+
+ \sa tag(), origin()
+*/
+bool QWebEngineNotification::matches(const QWebEngineNotification &other) const
+{
+ if (!d_ptr)
+ return !other.d_ptr;
+ if (!other.d_ptr)
+ return false;
+ return tag() == other.tag() && origin() == other.origin();
+}
+
+/*!
+ \property QWebEngineNotification::title
+ \brief The title of the notification.
+ \sa message()
+*/
+QString QWebEngineNotification::title() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? d->controller->title() : QString();
+}
+
+/*!
+ \property QWebEngineNotification::message
+ \brief The body of the notification message.
+ \sa title()
+*/
+
+QString QWebEngineNotification::message() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? d->controller->body() : QString();
+}
+
+/*!
+ \property QWebEngineNotification::tag
+ \brief The tag of the notification message.
+
+ New notifications that have the same tag and origin URL as an existing
+ one should replace or update the old notification with the same tag.
+
+ \sa matches()
+*/
+QString QWebEngineNotification::tag() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? d->controller->tag() : QString();
+}
+
+/*!
+ \property QWebEngineNotification::origin
+ \brief The URL of the page sending the notification.
+*/
+
+QUrl QWebEngineNotification::origin() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? d->controller->origin() : QUrl();
+}
+
+/*!
+ \property QWebEngineNotification::icon
+ \brief The icon to be shown with the notification.
+
+ If no icon is set by the sender, an null QIcon is returned.
+*/
+QIcon QWebEngineNotification::icon() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? d->controller->icon() : QIcon();
+}
+
+/*!
+ \property QWebEngineNotification::language
+ \brief The primary language for the notification's title and body.
+
+ Its value is a valid BCP 47 language tag, or the empty string.
+
+ \sa title(), message()
+*/
+QString QWebEngineNotification::language() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? d->controller->language() : QString();
+}
+
+/*!
+ \property QWebEngineNotification::direction
+ \brief The text direction for the notification's title and body.
+ \sa title(), message()
+*/
+QWebEngineNotification::Direction QWebEngineNotification::direction() const
+{
+ Q_D(const QWebEngineNotification);
+ return d ? static_cast<Direction>(d->controller->direction()) : DirectionAuto;
+}
+
+/*!
+ Returns \c true if the notification is a default constructed null notification.
+*/
+bool QWebEngineNotification::isNull() const
+{
+ return d_ptr.isNull();
+}
+
+/*!
+ Creates and dispatches a JavaScript \e {show event} on notification.
+
+ Should be called by the notification platform when the notification has been shown to user.
+*/
+void QWebEngineNotification::show() const
+{
+ Q_D(const QWebEngineNotification);
+ if (d)
+ d->controller->notificationDisplayed();
+}
+
+/*!
+ Creates and dispatches a JavaScript \e {click event} on notification.
+
+ Should be called by the notification platform when the notification is activated by the user.
+*/
+void QWebEngineNotification::click() const
+{
+ Q_D(const QWebEngineNotification);
+ if (d)
+ d->controller->notificationClicked();
+}
+
+/*!
+ Creates and dispatches a JavaScript \e {close event} on notification.
+
+ Should be called by the notification platform when the notification is closed,
+ either by the underlying platform or by the user.
+*/
+void QWebEngineNotification::close() const
+{
+ Q_D(const QWebEngineNotification);
+ if (d)
+ d->controller->notificationClosed();
+}
+
+/*!
+ \fn void QWebEngineNotification::closed()
+
+ This signal is emitted when the web page calls close steps for the notification,
+ and it no longer needs to be shown.
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qwebenginenotification.cpp"
diff --git a/src/core/api/qwebenginenotification.h b/src/core/api/qwebenginenotification.h
new file mode 100644
index 000000000..b6b7414f9
--- /dev/null
+++ b/src/core/api/qwebenginenotification.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINENOTIFICATION_H
+#define QWEBENGINENOTIFICATION_H
+
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QScopedPointer>
+#include <QtCore/QSharedPointer>
+#include <QtCore/QUrl>
+#include <QtGui/QIcon>
+
+namespace QtWebEngineCore {
+class UserNotificationController;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineNotificationPrivate;
+
+class QWEBENGINECORE_EXPORT QWebEngineNotification : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
+ Q_PROPERTY(QIcon icon READ icon CONSTANT FINAL)
+ Q_PROPERTY(QString title READ title CONSTANT FINAL)
+ Q_PROPERTY(QString message READ message CONSTANT FINAL)
+ Q_PROPERTY(QString tag READ tag CONSTANT FINAL)
+ Q_PROPERTY(QString language READ language CONSTANT FINAL)
+ Q_PROPERTY(Direction direction READ direction CONSTANT FINAL)
+
+public:
+ QWebEngineNotification();
+ QWebEngineNotification(const QWebEngineNotification &);
+ virtual ~QWebEngineNotification();
+ const QWebEngineNotification &operator=(const QWebEngineNotification &);
+
+ enum Direction {
+ LeftToRight = Qt::LeftToRight,
+ RightToLeft = Qt::RightToLeft,
+ DirectionAuto = Qt::LayoutDirectionAuto
+ };
+ Q_ENUM(Direction)
+
+ bool matches(const QWebEngineNotification &) const;
+
+ QUrl origin() const;
+ QIcon icon() const;
+ QString title() const;
+ QString message() const;
+ QString tag() const;
+ QString language() const;
+ Direction direction() const;
+
+ bool isNull() const;
+
+public Q_SLOTS:
+ void show() const;
+ void click() const;
+ void close() const;
+
+Q_SIGNALS:
+ void closed();
+
+private:
+ QWebEngineNotification(const QSharedPointer<QtWebEngineCore::UserNotificationController> &);
+ Q_DECLARE_PRIVATE(QWebEngineNotification)
+ QScopedPointer<QWebEngineNotificationPrivate> d_ptr;
+ friend class QQuickWebEngineProfilePrivate;
+ friend class QWebEngineProfilePrivate;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINENOTIFICATION_H
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 3861d1c95..a9959a82b 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -103,6 +103,7 @@
#include "media_capture_devices_dispatcher.h"
#include "net/network_delegate_qt.h"
#include "net/url_request_context_getter_qt.h"
+#include "platform_notification_service_qt.h"
#if QT_CONFIG(webengine_printing_and_pdf)
#include "printing/printing_message_filter_qt.h"
#endif
@@ -454,7 +455,7 @@ void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base:
void ContentBrowserClientQt::DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host)
{
browser_host->GetPpapiHost()->AddHostFactoryFilter(
- base::WrapUnique(new QtWebEngineCore::PepperHostFactoryQt(browser_host)));
+ std::make_unique<QtWebEngineCore::PepperHostFactoryQt>(browser_host));
}
#endif
@@ -463,6 +464,13 @@ content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDele
return new DevToolsManagerDelegateQt;
}
+content::PlatformNotificationService *ContentBrowserClientQt::GetPlatformNotificationService()
+{
+ if (!m_platformNotificationService)
+ m_platformNotificationService = std::make_unique<PlatformNotificationServiceQt>();
+ return m_platformNotificationService.get();
+}
+
// This is a really complicated way of doing absolutely nothing, but Mojo demands it:
class ServiceDriver
: public blink::mojom::InsecureInputService
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index fc938f882..403ff3a9d 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -108,6 +108,7 @@ public:
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(content::ResourceContext *resource_context) override;
content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() override;
+ content::PlatformNotificationService *GetPlatformNotificationService() override;
std::string GetApplicationLocale() override;
std::string GetAcceptLangs(content::BrowserContext* context) override;
@@ -210,6 +211,7 @@ private:
BrowserMainPartsQt* m_browserMainParts;
std::unique_ptr<content::ResourceDispatcherHostDelegate> m_resourceDispatcherHostDelegate;
+ std::unique_ptr<content::PlatformNotificationService> m_platformNotificationService;
scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
std::unique_ptr<service_manager::BinderRegistry> m_frameInterfaces;
std::unique_ptr<service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>> m_frameInterfacesParameterized;
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index edf6806a3..aa595036d 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -98,6 +98,7 @@ SOURCES = \
ozone/platform_window_qt.cpp \
ozone/surface_factory_qt.cpp \
permission_manager_qt.cpp \
+ platform_notification_service_qt.cpp \
process_main.cpp \
profile_adapter.cpp \
profile_adapter_client.cpp \
@@ -123,6 +124,7 @@ SOURCES = \
touch_selection_controller_client_qt.cpp \
touch_selection_menu_controller.cpp \
type_conversion.cpp \
+ user_notification_controller.cpp \
user_script.cpp \
visited_links_manager_qt.cpp \
web_contents_adapter.cpp \
@@ -201,6 +203,7 @@ HEADERS = \
ozone/platform_window_qt.h \
ozone/surface_factory_qt.h \
permission_manager_qt.h \
+ platform_notification_service_qt.h \
process_main.h \
profile_adapter.h \
profile_adapter_client.h \
@@ -230,6 +233,7 @@ HEADERS = \
touch_selection_controller_client_qt.h \
touch_selection_menu_controller.h \
type_conversion.h \
+ user_notification_controller.h \
user_script.h \
visited_links_manager_qt.h \
web_contents_adapter.h \
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index cf3041e7a..2a7311187 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -61,8 +61,9 @@ ProfileAdapter::PermissionType toQt(content::PermissionType type)
return ProfileAdapter::AudioCapturePermission;
case content::PermissionType::VIDEO_CAPTURE:
return ProfileAdapter::VideoCapturePermission;
- case content::PermissionType::FLASH:
case content::PermissionType::NOTIFICATIONS:
+ return ProfileAdapter::NotificationPermission;
+ case content::PermissionType::FLASH:
case content::PermissionType::MIDI_SYSEX:
case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
case content::PermissionType::MIDI:
@@ -188,6 +189,9 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
m_requests.insert(request_id, request);
if (permissionType == ProfileAdapter::GeolocationPermission)
contentsDelegate->requestGeolocationPermission(request.origin);
+ else if (permissionType == ProfileAdapter::NotificationPermission)
+ contentsDelegate->requestUserNotificationPermission(request.origin);
+
return request_id;
}
@@ -236,6 +240,8 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio
const ProfileAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == ProfileAdapter::GeolocationPermission)
contentsDelegate->requestGeolocationPermission(request.origin);
+ else if (permissionType == ProfileAdapter::NotificationPermission)
+ contentsDelegate->requestUserNotificationPermission(request.origin);
}
return request_id;
}
diff --git a/src/core/platform_notification_service_qt.cpp b/src/core/platform_notification_service_qt.cpp
new file mode 100644
index 000000000..dff3aed61
--- /dev/null
+++ b/src/core/platform_notification_service_qt.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "platform_notification_service_qt.h"
+
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/permission_type.h"
+#include "content/public/browser/notification_event_dispatcher.h"
+#include "ui/message_center/public/cpp/notification_delegate.h"
+
+#include "profile_adapter.h"
+#include "profile_adapter_client.h"
+#include "profile_qt.h"
+#include "user_notification_controller.h"
+#include "resource_context_qt.h"
+#include "type_conversion.h"
+
+#include <QSharedPointer>
+
+namespace QtWebEngineCore {
+
+struct NonPersistentNotificationDelegate : UserNotificationController::Delegate {
+ NonPersistentNotificationDelegate(const std::string &id) : notification_id(id) { }
+
+ virtual void shown() override {
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (auto inst = content::NotificationEventDispatcher::GetInstance())
+ inst->DispatchNonPersistentShowEvent(notification_id);
+ }
+
+ virtual void clicked() override {
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (auto inst = content::NotificationEventDispatcher::GetInstance())
+ inst->DispatchNonPersistentClickEvent(notification_id, base::DoNothing());
+ }
+
+ virtual void closed(bool /*by_user*/) override {
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (auto inst = content::NotificationEventDispatcher::GetInstance())
+ inst->DispatchNonPersistentCloseEvent(notification_id, base::DoNothing());
+ }
+
+ const std::string notification_id;
+};
+
+struct PersistentNotificationDelegate : UserNotificationController::Delegate {
+ PersistentNotificationDelegate(content::BrowserContext *context, const std::string &id, const GURL &origin)
+ : browser_context(context), notification_id(id), origin(origin) { }
+
+ virtual void shown() override { }
+
+ virtual void clicked() override {
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (auto inst = content::NotificationEventDispatcher::GetInstance())
+ inst->DispatchNotificationClickEvent(browser_context, notification_id, origin, base::nullopt, base::nullopt, base::DoNothing());
+ }
+
+ virtual void closed(bool by_user) override {
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (auto inst = content::NotificationEventDispatcher::GetInstance())
+ inst->DispatchNotificationCloseEvent(browser_context, notification_id, origin, by_user, base::DoNothing());
+ }
+
+ content::BrowserContext *browser_context;
+ const std::string notification_id;
+ const GURL origin;
+};
+
+
+PlatformNotificationServiceQt::PlatformNotificationServiceQt() {}
+
+PlatformNotificationServiceQt::~PlatformNotificationServiceQt() {}
+
+void PlatformNotificationServiceQt::DisplayNotification(
+ content::BrowserContext *browser_context,
+ const std::string &notification_id,
+ const GURL &origin,
+ const blink::PlatformNotificationData &notificationData,
+ const blink::NotificationResources &notificationResources)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ ProfileQt *profile = static_cast<ProfileQt*>(browser_context);
+
+ auto delegate = new NonPersistentNotificationDelegate(notification_id);
+ QSharedPointer<UserNotificationController> controller(
+ new UserNotificationController(notificationData, notificationResources, origin, delegate));
+
+ profile->profileAdapter()->ephemeralNotifications().insert(QByteArray::fromStdString(notification_id), controller);
+
+ const QList<ProfileAdapterClient *> clients = profile->profileAdapter()->clients();
+ for (ProfileAdapterClient *client : clients)
+ client->showNotification(controller);
+}
+
+void PlatformNotificationServiceQt::DisplayPersistentNotification(
+ content::BrowserContext *browser_context,
+ const std::string &notification_id,
+ const GURL &service_worker_origin,
+ const GURL &origin,
+ const blink::PlatformNotificationData &notificationData,
+ const blink::NotificationResources &notificationResources)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ ProfileQt * profile = static_cast<ProfileQt*>(browser_context);
+
+ auto delegate = new PersistentNotificationDelegate(profile, notification_id, service_worker_origin);
+ QSharedPointer<UserNotificationController> controller(
+ new UserNotificationController(notificationData, notificationResources, service_worker_origin, delegate));
+
+ profile->profileAdapter()->persistentNotifications().insert(QByteArray::fromStdString(notification_id), controller);
+ const QList<ProfileAdapterClient *> clients = profile->profileAdapter()->clients();
+ for (ProfileAdapterClient *client : clients)
+ client->showNotification(controller);
+}
+
+void PlatformNotificationServiceQt::CloseNotification(
+ content::BrowserContext *browser_context,
+ const std::string &notification_id)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ ProfileQt *profile = static_cast<ProfileQt*>(browser_context);
+
+ QSharedPointer<UserNotificationController> notificationController =
+ profile->profileAdapter()->ephemeralNotifications().take(QByteArray::fromStdString(notification_id)).lock();
+ if (notificationController)
+ notificationController->closeNotification();
+}
+
+void PlatformNotificationServiceQt::ClosePersistentNotification(
+ content::BrowserContext *browser_context,
+ const std::string &notification_id)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ ProfileQt *profile = static_cast<ProfileQt*>(browser_context);
+
+ QSharedPointer<UserNotificationController> notificationController =
+ profile->profileAdapter()->persistentNotifications().take(QByteArray::fromStdString(notification_id));
+ if (notificationController)
+ notificationController->closeNotification();
+}
+
+void PlatformNotificationServiceQt::GetDisplayedNotifications(
+ content::BrowserContext *browser_context,
+ const DisplayedNotificationsCallback &callback)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ ProfileQt *profile = static_cast<ProfileQt *>(browser_context);
+
+ std::unique_ptr<std::set<std::string>> movableStdStringSet = std::make_unique<std::set<std::string>>();
+ auto it = profile->profileAdapter()->persistentNotifications().constBegin();
+ const auto end = profile->profileAdapter()->persistentNotifications().constEnd();
+ while (it != end) {
+ if (it.value()->isShown())
+ movableStdStringSet->insert(it.key().toStdString());
+ ++it;
+ }
+
+ callback.Run(std::move(movableStdStringSet), true /* supports_synchronization */);
+}
+
+int64_t PlatformNotificationServiceQt::ReadNextPersistentNotificationId(content::BrowserContext *browser_context)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ auto prefs = static_cast<ProfileQt *>(browser_context)->GetPrefs();
+ int64_t nextId = prefs->GetInteger(prefs::kNotificationNextPersistentId) + 1;
+ prefs->SetInt64(prefs::kNotificationNextPersistentId, nextId);
+ return nextId;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/platform_notification_service_qt.h b/src/core/platform_notification_service_qt.h
new file mode 100644
index 000000000..66cee9ed0
--- /dev/null
+++ b/src/core/platform_notification_service_qt.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PLATFORM_NOTIFICATION_SERVICE_QT_H
+#define PLATFORM_NOTIFICATION_SERVICE_QT_H
+
+#include "content/public/browser/platform_notification_service.h"
+
+namespace QtWebEngineCore {
+
+class PlatformNotificationServiceQt : public content::PlatformNotificationService {
+public:
+ PlatformNotificationServiceQt();
+ ~PlatformNotificationServiceQt() override;
+
+ // Displays the notification described in |notification_data| to the user. A
+ // closure through which the notification can be closed will be stored in the
+ // |cancel_callback| argument. This method must be called on the UI thread.
+ void DisplayNotification(content::BrowserContext* browser_context,
+ const std::string& notification_id,
+ const GURL& origin,
+ const blink::PlatformNotificationData& notificationData,
+ const blink::NotificationResources& notificationResources) override;
+
+ // Displays the persistent notification described in |notification_data| to
+ // the user. This method must be called on the UI thread.
+ void DisplayPersistentNotification(content::BrowserContext* browser_context,
+ const std::string& notification_id,
+ const GURL& service_worker_origin,
+ const GURL& origin,
+ const blink::PlatformNotificationData& notification_data,
+ const blink::NotificationResources& notification_resources) override;
+
+ // Closes the notification identified by |notification_id|.
+ // This method must be called on the UI thread.
+ void CloseNotification(content::BrowserContext* browser_context, const std::string& notification_id) override;
+
+ // Closes the persistent notification identified by |persistent_notification_id|.
+ // This method must be called on the UI thread.
+ void ClosePersistentNotification(content::BrowserContext* browser_context, const std::string& notification_id) override;
+
+ // Retrieves the ids of all currently displaying notifications and
+ // posts |callback| with the result.
+ void GetDisplayedNotifications(content::BrowserContext* browser_context, const DisplayedNotificationsCallback& callback) override;
+
+ // Reads the value of the next persistent notification ID from the profile and
+ // increments the value, as it is called once per notification write.
+ virtual int64_t ReadNextPersistentNotificationId(content::BrowserContext* browser_context) override;
+
+ // Records a given notification to UKM.
+ virtual void RecordNotificationUkmEvent(content::BrowserContext*, const content::NotificationDatabaseData&) override { }
+};
+
+} // namespace QtWebEngineCore
+
+#endif // PLATFORM_NOTIFICATION_SERVICE_QT_H
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index 800058bc5..482835010 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -69,8 +69,9 @@ QT_FORWARD_DECLARE_CLASS(QObject)
namespace QtWebEngineCore {
-class ProfileAdapterClient;
+class UserNotificationController;
class DownloadManagerDelegateQt;
+class ProfileAdapterClient;
class ProfileQt;
class UserResourceControllerHost;
class VisitedLinksManagerQt;
@@ -153,8 +154,7 @@ public:
enum PermissionType {
UnsupportedPermission = 0,
GeolocationPermission = 1,
-// Reserved:
-// NotificationPermission = 2,
+ NotificationPermission = 2,
AudioCapturePermission = 3,
VideoCapturePermission = 4,
ClipboardRead = 5,
@@ -200,6 +200,11 @@ public:
void removePageRequestInterceptor();
bool hasPageRequestInterceptor() const { return m_pageRequestInterceptors > 0; }
+ QHash<QByteArray, QWeakPointer<UserNotificationController>> &ephemeralNotifications()
+ { return m_ephemeralNotifications; }
+ QHash<QByteArray, QSharedPointer<UserNotificationController>> &persistentNotifications()
+ { return m_persistentNotifications; }
+
private:
void updateCustomUrlSchemeHandlers();
void resetVisitedLinksManager();
@@ -224,6 +229,9 @@ private:
PersistentCookiesPolicy m_persistentCookiesPolicy;
VisitedLinksPolicy m_visitedLinksPolicy;
QHash<QByteArray, QPointer<QWebEngineUrlSchemeHandler>> m_customUrlSchemeHandlers;
+ QHash<QByteArray, QWeakPointer<UserNotificationController>> m_ephemeralNotifications;
+ QHash<QByteArray, QSharedPointer<UserNotificationController>> m_persistentNotifications;
+
QList<ProfileAdapterClient*> m_clients;
int m_httpCacheMaxSize;
int m_pageRequestInterceptors;
diff --git a/src/core/profile_adapter_client.h b/src/core/profile_adapter_client.h
index 4711f8bcf..0309200b4 100644
--- a/src/core/profile_adapter_client.h
+++ b/src/core/profile_adapter_client.h
@@ -52,12 +52,14 @@
#define PROFILE_ADAPTER_CLIENT_H
#include "qtwebenginecoreglobal_p.h"
+#include <QSharedPointer>
#include <QString>
#include <QUrl>
namespace QtWebEngineCore {
class WebContentsAdapterClient;
+class UserNotificationController;
class QWEBENGINECORE_PRIVATE_EXPORT ProfileAdapterClient
{
@@ -143,6 +145,8 @@ public:
virtual void downloadRequested(DownloadItemInfo &info) = 0;
virtual void downloadUpdated(const DownloadItemInfo &info) = 0;
virtual void useForGlobalCertificateVerificationChanged() {}
+ virtual void showNotification(QSharedPointer<UserNotificationController> &) { }
+
static QString downloadInterruptReasonToString(DownloadInterruptReason reason);
};
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp
index 0ede1df55..624a52f7b 100644
--- a/src/core/profile_qt.cpp
+++ b/src/core/profile_qt.cpp
@@ -106,6 +106,7 @@ ProfileQt::ProfileQt(ProfileAdapter *profileAdapter)
registry->RegisterBooleanPref(spellcheck::prefs::kSpellCheckUseSpellingService, false);
#endif // QT_CONFIG(webengine_spellchecker)
registry->RegisterBooleanPref(prefs::kShowInternalAccessibilityTree, false);
+ registry->RegisterIntegerPref(prefs::kNotificationNextPersistentId, 10000);
#if BUILDFLAG(ENABLE_EXTENSIONS)
registry->RegisterDictionaryPref(extensions::pref_names::kExtensions);
diff --git a/src/core/user_notification_controller.cpp b/src/core/user_notification_controller.cpp
new file mode 100644
index 000000000..82cb57e51
--- /dev/null
+++ b/src/core/user_notification_controller.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "user_notification_controller.h"
+
+#include "type_conversion.h"
+
+#include "base/callback.h"
+#include "content/public/browser/notification_event_dispatcher.h"
+#include "third_party/blink/public/common/notifications/notification_resources.h"
+#include "third_party/blink/public/common/notifications/platform_notification_data.h"
+#include "ui/message_center/public/cpp/notification_delegate.h"
+
+#include <memory>
+
+namespace QtWebEngineCore {
+
+static Qt::LayoutDirection toDirection(blink::PlatformNotificationData::Direction direction)
+{
+ switch (direction) {
+ case blink::PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT:
+ return Qt::LeftToRight;
+ case blink::PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT:
+ return Qt::RightToLeft;
+ case blink::PlatformNotificationData::DIRECTION_AUTO:
+ default:
+ break;
+ }
+ return Qt::LayoutDirectionAuto;
+}
+
+class UserNotificationControllerPrivate {
+public:
+ UserNotificationControllerPrivate(const blink::PlatformNotificationData &params,
+ const blink::NotificationResources &resources,
+ const GURL &origin)
+ : m_params(params)
+ , m_origin(origin)
+ , m_delegate(nullptr)
+ , m_resources(resources)
+ , m_client(nullptr)
+ , m_iconGenerated(false)
+ , m_imageGenerated(false)
+ , m_badgeGenerated(false)
+ , m_shown(false)
+ { }
+
+ blink::PlatformNotificationData m_params;
+ GURL m_origin;
+ std::unique_ptr<UserNotificationController::Delegate> m_delegate;
+ blink::NotificationResources m_resources;
+ UserNotificationController::Client *m_client;
+ QIcon m_icon;
+ QImage m_image;
+ QImage m_badge;
+ bool m_iconGenerated;
+ bool m_imageGenerated;
+ bool m_badgeGenerated;
+ bool m_shown;
+};
+
+
+UserNotificationController::UserNotificationController(const blink::PlatformNotificationData &params,
+ const blink::NotificationResources &resources,
+ const GURL &origin,
+ Delegate *delegate)
+ : d(new UserNotificationControllerPrivate(params, resources, origin))
+{
+ d->m_delegate.reset(delegate);
+}
+
+UserNotificationController::~UserNotificationController()
+{
+ delete d;
+ d = nullptr;
+}
+
+void UserNotificationController::notificationDisplayed()
+{
+ if (!d->m_shown) {
+ d->m_shown = true;
+ if (d->m_delegate)
+ d->m_delegate->shown();
+ }
+}
+
+void UserNotificationController::notificationClosed()
+{
+ d->m_shown = false;
+ if (d->m_delegate)
+ d->m_delegate->closed(true);
+}
+
+void UserNotificationController::notificationClicked()
+{
+ if (d->m_delegate)
+ d->m_delegate->clicked();
+}
+
+void UserNotificationController::closeNotification()
+{
+ d->m_shown = false;
+ if (d->m_client)
+ d->m_client->notificationClosed(this);
+}
+
+void UserNotificationController::setClient(UserNotificationController::Client* client)
+{
+ d->m_client = client;
+}
+
+UserNotificationController::Client* UserNotificationController::client()
+{
+ return d->m_client;
+}
+
+QUrl UserNotificationController::origin() const
+{
+ return toQt(d->m_origin);
+}
+
+QIcon UserNotificationController::icon() const
+{
+ if (!d->m_iconGenerated) {
+ d->m_iconGenerated = true;
+ if (!d->m_resources.notification_icon.isNull()) {
+ QImage image = toQImage(d->m_resources.notification_icon);
+ if (!image.isNull())
+ d->m_icon = QIcon(QPixmap::fromImage(std::move(image), Qt::NoFormatConversion));
+ }
+ }
+ return d->m_icon;
+}
+
+QImage UserNotificationController::image() const
+{
+ if (d->m_imageGenerated)
+ return d->m_image;
+ d->m_image = toQImage(d->m_resources.image);
+ d->m_imageGenerated = true;
+ return d->m_image;
+}
+
+QImage UserNotificationController::badge() const
+{
+ if (d->m_badgeGenerated)
+ return d->m_badge;
+ d->m_badge = toQImage(d->m_resources.badge);
+ d->m_badgeGenerated = true;
+ return d->m_badge;
+}
+
+QString UserNotificationController::title() const
+{
+ return toQt(d->m_params.title);
+}
+
+QString UserNotificationController::body() const
+{
+ return toQt(d->m_params.body);
+}
+
+QString UserNotificationController::tag() const
+{
+ return toQt(d->m_params.tag);
+}
+
+QString UserNotificationController::language() const
+{
+ return toQt(d->m_params.lang);
+}
+
+Qt::LayoutDirection UserNotificationController::direction() const
+{
+ return toDirection(d->m_params.direction);
+}
+
+bool UserNotificationController::isShown() const
+{
+ return d->m_shown;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/user_notification_controller.h b/src/core/user_notification_controller.h
new file mode 100644
index 000000000..840074843
--- /dev/null
+++ b/src/core/user_notification_controller.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DESKTOP_NOTIFICATION_CONTROLLER_H
+#define DESKTOP_NOTIFICATION_CONTROLLER_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QtCore/QSharedPointer>
+#include <QtCore/QUrl>
+#include <QtGui/QIcon>
+
+class GURL;
+
+namespace blink {
+ struct NotificationResources;
+ struct PlatformNotificationData;
+}
+
+namespace QtWebEngineCore {
+
+class UserNotificationControllerPrivate;
+
+// Works as an accessor and owner of chromium objects related to showing desktop notifications.
+class QWEBENGINECORE_EXPORT UserNotificationController : public QEnableSharedFromThis<UserNotificationController> {
+public:
+ struct Delegate {
+ virtual ~Delegate() { }
+ virtual void shown() = 0;
+ virtual void clicked() = 0;
+ virtual void closed(bool byUser) = 0;
+ };
+
+ UserNotificationController(const blink::PlatformNotificationData &params,
+ const blink::NotificationResources &resources,
+ const GURL &origin,
+ Delegate *delegate);
+ ~UserNotificationController();
+
+ // The notification was shown.
+ void notificationDisplayed();
+
+ // The notification was closed.
+ void notificationClosed();
+
+ // The user clicked on the notification.
+ void notificationClicked();
+
+ // Chromium requests to close the notification.
+ void closeNotification();
+
+ QUrl origin() const;
+ QIcon icon() const;
+ QImage image() const;
+ QImage badge() const;
+ QString title() const;
+ QString body() const;
+ QString tag() const;
+ QString language() const;
+ Qt::LayoutDirection direction() const;
+
+ bool isShown() const;
+
+ class Client {
+ public:
+ virtual ~Client() { }
+ virtual void notificationClosed(const UserNotificationController *) = 0;
+ };
+ void setClient(Client *client);
+ Client* client();
+
+private:
+ UserNotificationControllerPrivate *d;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // DESKTOP_NOTIFICATION_CONTROLLER_H
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 0c884d265..d85d34eb2 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1271,6 +1271,12 @@ void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigi
m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::GeolocationPermission, allowed);
}
+void WebContentsAdapter::runUserNotificationRequestCallback(const QUrl &securityOrigin, bool allowed)
+{
+ CHECK_INITIALIZED();
+ m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::NotificationPermission, allowed);
+}
+
void WebContentsAdapter::grantMouseLockPermission(bool granted)
{
CHECK_INITIALIZED();
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index b4a01fb17..c6e4f2256 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -183,6 +183,7 @@ public:
void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags);
void runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed);
void grantMouseLockPermission(bool granted);
+ void runUserNotificationRequestCallback(const QUrl &securityOrigin, bool allowed);
void setBackgroundColor(const QColor &color);
QAccessibleInterface *browserAccessible();
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index f4937f0d4..d155ed391 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -459,6 +459,7 @@ public:
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0;
virtual void runQuotaRequest(QWebEngineQuotaRequest) = 0;
virtual void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) = 0;
+ virtual void runUserNotificationPermissionRequest(const QUrl &securityOrigin) = 0;
virtual WebEngineSettings *webEngineSettings() const = 0;
RenderProcessTerminationStatus renderProcessExitStatus(int);
virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 963b89a3f..4fcf2944d 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -585,6 +585,11 @@ void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingO
m_viewClient->runGeolocationPermissionRequest(requestingOrigin);
}
+void WebContentsDelegateQt::requestUserNotificationPermission(const QUrl &requestingOrigin)
+{
+ m_viewClient->runUserNotificationPermissionRequest(requestingOrigin);
+}
+
extern WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition);
void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture)
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 40f585767..77f6cc389 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -148,6 +148,7 @@ public:
void allowCertificateError(const QSharedPointer<CertificateErrorController> &);
void selectClientCert(const QSharedPointer<ClientCertSelectController> &);
void requestGeolocationPermission(const QUrl &requestingOrigin);
+ void requestUserNotificationPermission(const QUrl &requestingOrigin);
void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture);
FaviconManager *faviconManager();