2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-10-05 21:24:38 +00:00
|
|
|
From: Jeremy Apthorp <jeremya@chromium.org>
|
|
|
|
Date: Fri, 5 Oct 2018 14:22:06 -0700
|
2019-08-24 01:14:23 +00:00
|
|
|
Subject: notification_provenance.patch
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2019-08-24 01:14:23 +00:00
|
|
|
Pass RenderProcessHost through to PlatformNotificationService
|
|
|
|
so Electron can identify which renderer a notification came from.
|
2018-10-05 21:24:38 +00:00
|
|
|
|
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl.cc b/content/browser/notifications/blink_notification_service_impl.cc
|
2021-03-15 18:32:18 +00:00
|
|
|
index deacfeefaa2fde66378fed29bb29d4bfbcaecf85..d13758a82dc0a809d0812f07caf79316b4b321b4 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
2021-03-15 18:32:18 +00:00
|
|
|
@@ -88,9 +88,11 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
|
2018-10-05 21:24:38 +00:00
|
|
|
PlatformNotificationContextImpl* notification_context,
|
|
|
|
BrowserContext* browser_context,
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const url::Origin& origin,
|
2019-07-24 22:58:51 +00:00
|
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver)
|
2018-10-05 21:24:38 +00:00
|
|
|
: notification_context_(notification_context),
|
|
|
|
+ render_process_host_(render_process_host),
|
|
|
|
browser_context_(browser_context),
|
|
|
|
service_worker_context_(std::move(service_worker_context)),
|
|
|
|
origin_(origin),
|
2021-03-15 18:32:18 +00:00
|
|
|
@@ -151,8 +153,9 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
2019-07-24 22:58:51 +00:00
|
|
|
notification_id, std::move(event_listener_remote));
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
GetNotificationService(browser_context_)
|
|
|
|
- ->DisplayNotification(notification_id, origin_.GetURL(),
|
|
|
|
- platform_notification_data, notification_resources);
|
|
|
|
+ ->DisplayNotification(render_process_host_, notification_id,
|
|
|
|
+ origin_.GetURL(), platform_notification_data,
|
|
|
|
+ notification_resources);
|
2018-10-05 21:24:38 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
void BlinkNotificationServiceImpl::CloseNonPersistentNotification(
|
2018-10-05 21:24:38 +00:00
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl.h b/content/browser/notifications/blink_notification_service_impl.h
|
2019-07-24 22:58:51 +00:00
|
|
|
index 5253f6be778cc78571b3df0a33d364a9b1e6ef52..dc5307e6500b0bfb5da83e8d8ff8886b91133522 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl.h
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.h
|
2019-07-24 22:58:51 +00:00
|
|
|
@@ -40,6 +40,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
2018-10-05 21:24:38 +00:00
|
|
|
PlatformNotificationContextImpl* notification_context,
|
|
|
|
BrowserContext* browser_context,
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const url::Origin& origin,
|
2019-07-24 22:58:51 +00:00
|
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver);
|
2018-10-05 21:24:38 +00:00
|
|
|
~BlinkNotificationServiceImpl() override;
|
2019-07-24 22:58:51 +00:00
|
|
|
@@ -99,6 +100,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
2018-10-05 21:24:38 +00:00
|
|
|
// The notification context that owns this service instance.
|
|
|
|
PlatformNotificationContextImpl* notification_context_;
|
|
|
|
|
|
|
|
+ RenderProcessHost* render_process_host_;
|
|
|
|
BrowserContext* browser_context_;
|
|
|
|
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
|
2018-10-11 08:38:48 +00:00
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl_unittest.cc b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
2020-11-14 00:16:56 +00:00
|
|
|
index dcb0b03f0b814238860a17f88c1d7ed00546dad4..17184d672af88947c04b30de0aa62acda84084fb 100644
|
2018-10-11 08:38:48 +00:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
2020-11-14 00:16:56 +00:00
|
|
|
@@ -139,7 +139,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
|
2019-01-12 01:00:43 +00:00
|
|
|
|
2018-10-11 08:38:48 +00:00
|
|
|
notification_service_ = std::make_unique<BlinkNotificationServiceImpl>(
|
|
|
|
notification_context_.get(), &browser_context_,
|
|
|
|
- embedded_worker_helper_->context_wrapper(),
|
|
|
|
+ embedded_worker_helper_->context_wrapper(), nullptr,
|
|
|
|
url::Origin::Create(GURL(kTestOrigin)),
|
2019-07-24 22:58:51 +00:00
|
|
|
notification_service_remote_.BindNewPipeAndPassReceiver());
|
2018-10-11 08:38:48 +00:00
|
|
|
|
2018-10-05 21:24:38 +00:00
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
|
2021-03-04 17:27:05 +00:00
|
|
|
index 8d516c814ef9882f15aaa903121a1c7a8270d28e..da523905809761a10cabb0963a691dd268d08f1c 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/platform_notification_context_impl.cc
|
|
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.cc
|
2021-03-04 17:27:05 +00:00
|
|
|
@@ -284,12 +284,13 @@ void PlatformNotificationContextImpl::Shutdown() {
|
2018-10-05 21:24:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformNotificationContextImpl::CreateService(
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const url::Origin& origin,
|
2019-07-24 22:58:51 +00:00
|
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver) {
|
2018-10-05 21:24:38 +00:00
|
|
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
|
services_.push_back(std::make_unique<BlinkNotificationServiceImpl>(
|
|
|
|
- this, browser_context_, service_worker_context_, origin,
|
2019-07-24 22:58:51 +00:00
|
|
|
- std::move(receiver)));
|
2018-10-05 21:24:38 +00:00
|
|
|
+ this, browser_context_, service_worker_context_, render_process_host,
|
2019-07-24 22:58:51 +00:00
|
|
|
+ origin, std::move(receiver)));
|
2018-10-05 21:24:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformNotificationContextImpl::RemoveService(
|
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h
|
2021-03-04 17:27:05 +00:00
|
|
|
index 60558d5f40b765ed3ca2f7d1abc1b95f7518fee9..ab44370dc89f64fe2b86089fd9781b710fbcec8a 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/platform_notification_context_impl.h
|
|
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.h
|
2019-03-21 22:45:52 +00:00
|
|
|
@@ -24,6 +24,7 @@
|
2018-10-05 21:24:38 +00:00
|
|
|
#include "content/common/content_export.h"
|
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
#include "content/public/browser/platform_notification_context.h"
|
|
|
|
+#include "content/public/browser/render_process_host.h"
|
2019-07-24 22:58:51 +00:00
|
|
|
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
2019-04-20 17:20:37 +00:00
|
|
|
#include "third_party/blink/public/mojom/notifications/notification_service.mojom.h"
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2019-07-24 22:58:51 +00:00
|
|
|
@@ -67,6 +68,7 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2019-02-14 16:34:15 +00:00
|
|
|
// Creates a BlinkNotificationServiceImpl that is owned by this context.
|
2019-07-24 22:58:51 +00:00
|
|
|
void CreateService(
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const url::Origin& origin,
|
|
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver);
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2019-12-11 00:22:35 +00:00
|
|
|
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
|
2021-03-15 18:32:18 +00:00
|
|
|
index 1b7c03f529ec864c9fb30887137b92317dcd1f11..bb60223620f6aab8d48db90ddc9f8b511834f692 100644
|
2019-12-11 00:22:35 +00:00
|
|
|
--- a/content/browser/renderer_host/render_process_host_impl.cc
|
|
|
|
+++ b/content/browser/renderer_host/render_process_host_impl.cc
|
2021-03-15 18:32:18 +00:00
|
|
|
@@ -2107,7 +2107,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
2019-12-11 00:22:35 +00:00
|
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver) {
|
|
|
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
|
storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
|
|
|
|
- origin, std::move(receiver));
|
|
|
|
+ this, origin, std::move(receiver));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderProcessHostImpl::CreateWebSocketConnector(
|
2018-10-05 21:24:38 +00:00
|
|
|
diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
|
2019-04-20 17:20:37 +00:00
|
|
|
index ca61088079c4150fcf389504ddcf26bcf6bf69cd..d9c034c39890eef1fe3d95c6d7c0ae68eb711a89 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/public/browser/platform_notification_service.h
|
|
|
|
+++ b/content/public/browser/platform_notification_service.h
|
2019-04-20 17:20:37 +00:00
|
|
|
@@ -27,6 +27,8 @@ struct PlatformNotificationData;
|
|
|
|
|
2018-10-05 21:24:38 +00:00
|
|
|
namespace content {
|
|
|
|
|
|
|
|
+class RenderProcessHost;
|
2019-04-20 17:20:37 +00:00
|
|
|
+
|
2019-01-12 01:00:43 +00:00
|
|
|
// The service using which notifications can be presented to the user. There
|
|
|
|
// should be a unique instance of the PlatformNotificationService depending
|
2019-04-20 17:20:37 +00:00
|
|
|
// on the browsing context being used.
|
|
|
|
@@ -41,6 +43,7 @@ class CONTENT_EXPORT PlatformNotificationService {
|
2018-10-05 21:24:38 +00:00
|
|
|
// Displays the notification described in |notification_data| to the user.
|
|
|
|
// This method must be called on the UI thread.
|
|
|
|
virtual void DisplayNotification(
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2019-04-20 17:20:37 +00:00
|
|
|
const blink::PlatformNotificationData& notification_data,
|
2018-10-11 08:38:48 +00:00
|
|
|
diff --git a/content/test/mock_platform_notification_service.cc b/content/test/mock_platform_notification_service.cc
|
2021-03-15 18:32:18 +00:00
|
|
|
index 1d8a0687f9ec7e7894c74ac94f1648ad3c1621c8..05450dbe825552e00136837ee4ec4e5373201a45 100644
|
2018-10-11 08:38:48 +00:00
|
|
|
--- a/content/test/mock_platform_notification_service.cc
|
|
|
|
+++ b/content/test/mock_platform_notification_service.cc
|
2020-06-01 20:34:34 +00:00
|
|
|
@@ -30,6 +30,7 @@ MockPlatformNotificationService::MockPlatformNotificationService(
|
2018-10-11 08:38:48 +00:00
|
|
|
MockPlatformNotificationService::~MockPlatformNotificationService() = default;
|
|
|
|
|
|
|
|
void MockPlatformNotificationService::DisplayNotification(
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2019-04-20 17:20:37 +00:00
|
|
|
const blink::PlatformNotificationData& notification_data,
|
2018-10-11 08:38:48 +00:00
|
|
|
diff --git a/content/test/mock_platform_notification_service.h b/content/test/mock_platform_notification_service.h
|
2021-03-15 18:32:18 +00:00
|
|
|
index caf6118cc1f0d99b054d2361648751be31368387..ea906b97850c676951a554af288845bb95d6e2a8 100644
|
2018-10-11 08:38:48 +00:00
|
|
|
--- a/content/test/mock_platform_notification_service.h
|
|
|
|
+++ b/content/test/mock_platform_notification_service.h
|
2019-04-20 17:20:37 +00:00
|
|
|
@@ -47,6 +47,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
2018-10-11 08:38:48 +00:00
|
|
|
|
|
|
|
// PlatformNotificationService implementation.
|
|
|
|
void DisplayNotification(
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2019-04-20 17:20:37 +00:00
|
|
|
const blink::PlatformNotificationData& notification_data,
|