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
|
|
|
|
2022-01-11 19:27:24 +00:00
|
|
|
Pass RenderFrameHost through to PlatformNotificationService
|
2019-08-24 01:14:23 +00:00
|
|
|
so Electron can identify which renderer a notification came from.
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2022-01-11 19:27:24 +00:00
|
|
|
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
|
2023-11-28 21:40:12 +00:00
|
|
|
index 8ba0cc2afe6a8bcabecee8f081d0ffd75ae71594..584f008f3e5dc9f6e16f18359773f5c8e53d96cd 100644
|
2022-01-11 19:27:24 +00:00
|
|
|
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
|
|
|
|
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
|
2023-11-28 21:40:12 +00:00
|
|
|
@@ -198,6 +198,7 @@ bool PlatformNotificationServiceImpl::WasClosedProgrammatically(
|
2022-01-11 19:27:24 +00:00
|
|
|
|
|
|
|
// TODO(awdf): Rename to DisplayNonPersistentNotification (Similar for Close)
|
|
|
|
void PlatformNotificationServiceImpl::DisplayNotification(
|
|
|
|
+ content::RenderFrameHost* render_frame_host,
|
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
|
|
|
const GURL& document_url,
|
|
|
|
diff --git a/chrome/browser/notifications/platform_notification_service_impl.h b/chrome/browser/notifications/platform_notification_service_impl.h
|
2023-10-02 22:01:07 +00:00
|
|
|
index 2552c32ed769482c8bbb7b7538bf59cb66dcc16d..7fda86e70ad47766211a9ff8b5ed732068f0b885 100644
|
2022-01-11 19:27:24 +00:00
|
|
|
--- a/chrome/browser/notifications/platform_notification_service_impl.h
|
|
|
|
+++ b/chrome/browser/notifications/platform_notification_service_impl.h
|
2023-08-15 15:49:41 +00:00
|
|
|
@@ -57,6 +57,7 @@ class PlatformNotificationServiceImpl
|
2022-01-11 19:27:24 +00:00
|
|
|
|
|
|
|
// content::PlatformNotificationService implementation.
|
|
|
|
void DisplayNotification(
|
|
|
|
+ content::RenderFrameHost* render_frame_host,
|
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
|
|
|
const GURL& document_url,
|
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
|
2023-02-03 11:43:42 +00:00
|
|
|
index 688c95eeb2a1ea60b004eb643cb5afcff48c11bd..226d1e3f01f976d8b35e6b3fbd332683d1a0f84b 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
|
2023-01-06 02:35:34 +00:00
|
|
|
@@ -87,12 +87,14 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
|
2018-10-05 21:24:38 +00:00
|
|
|
BrowserContext* browser_context,
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
2022-04-12 11:19:14 +00:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 18:23:28 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 02:35:34 +00:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|
2022-06-27 20:50:08 +00:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2022-11-17 19:59:23 +00:00
|
|
|
RenderProcessHost::NotificationServiceCreatorType creator_type,
|
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),
|
2021-04-29 18:23:28 +00:00
|
|
|
+ render_frame_host_(render_frame_host),
|
2018-10-05 21:24:38 +00:00
|
|
|
browser_context_(browser_context),
|
|
|
|
service_worker_context_(std::move(service_worker_context)),
|
2022-04-12 11:19:14 +00:00
|
|
|
render_process_host_id_(render_process_host->GetID()),
|
2023-01-06 02:35:34 +00:00
|
|
|
@@ -184,7 +186,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
2022-11-17 19:59:23 +00:00
|
|
|
creator_type_);
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2021-10-06 02:21:00 +00:00
|
|
|
browser_context_->GetPlatformNotificationService()->DisplayNotification(
|
2023-01-06 02:35:34 +00:00
|
|
|
- notification_id, storage_key_.origin().GetURL(), document_url_,
|
|
|
|
+ render_frame_host_, notification_id, storage_key_.origin().GetURL(), document_url_,
|
2021-10-06 02:21:00 +00:00
|
|
|
platform_notification_data, notification_resources);
|
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
|
2023-06-09 23:08:36 +00:00
|
|
|
index e7cc73f375ada7ee8715d331c3d372e0f59a0cdf..c0a142bea4a9a30c10dbb30c72fedce9ab4d1e62 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
|
2022-11-17 19:59:23 +00:00
|
|
|
@@ -44,6 +44,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
2018-10-05 21:24:38 +00:00
|
|
|
BrowserContext* browser_context,
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
2022-04-12 11:19:14 +00:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 18:23:28 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 02:35:34 +00:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|
2022-06-27 20:50:08 +00:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2023-06-09 23:08:36 +00:00
|
|
|
@@ -113,6 +114,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
|
|
|
raw_ptr<PlatformNotificationContextImpl, DanglingUntriaged>
|
|
|
|
notification_context_;
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2022-01-10 22:31:39 +00:00
|
|
|
+ raw_ptr<RenderFrameHost> render_frame_host_;
|
|
|
|
raw_ptr<BrowserContext> browser_context_;
|
2018-10-05 21:24:38 +00:00
|
|
|
|
|
|
|
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
|
2024-01-03 08:52:49 +00:00
|
|
|
index 15525538284b202acdcd3bacdd2b55db16cf6cb7..454e0307bd374a443d3e2f2dbb4ffa330d22d04f 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
|
2024-01-03 08:52:49 +00:00
|
|
|
@@ -130,7 +130,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
|
2018-10-11 08:38:48 +00:00
|
|
|
notification_service_ = std::make_unique<BlinkNotificationServiceImpl>(
|
|
|
|
notification_context_.get(), &browser_context_,
|
2022-04-12 11:19:14 +00:00
|
|
|
embedded_worker_helper_->context_wrapper(), &render_process_host_,
|
2023-01-06 02:35:34 +00:00
|
|
|
- storage_key_,
|
|
|
|
+ nullptr, storage_key_,
|
2021-04-27 21:27:34 +00:00
|
|
|
/*document_url=*/GURL(),
|
2022-11-17 19:59:23 +00:00
|
|
|
contents_.get()->GetPrimaryMainFrame()->GetWeakDocumentPtr(),
|
|
|
|
RenderProcessHost::NotificationServiceCreatorType::kDocument,
|
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
|
2023-11-28 21:40:12 +00:00
|
|
|
index 18cca28edc35dadd4eb9173558d1764b1bf85dd5..4cda3b7f2db6be365e4edb9456e1f72244a5158e 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
|
2023-05-10 14:47:48 +00:00
|
|
|
@@ -268,6 +268,7 @@ void PlatformNotificationContextImpl::Shutdown() {
|
2018-10-05 21:24:38 +00:00
|
|
|
|
|
|
|
void PlatformNotificationContextImpl::CreateService(
|
2022-04-12 11:19:14 +00:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 18:23:28 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 02:35:34 +00:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|
2022-06-27 20:50:08 +00:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2023-05-10 14:47:48 +00:00
|
|
|
@@ -276,7 +277,7 @@ void PlatformNotificationContextImpl::CreateService(
|
2018-10-05 21:24:38 +00:00
|
|
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
|
services_.push_back(std::make_unique<BlinkNotificationServiceImpl>(
|
2022-04-12 11:19:14 +00:00
|
|
|
this, browser_context_, service_worker_context_, render_process_host,
|
2023-01-06 02:35:34 +00:00
|
|
|
- storage_key, document_url, weak_document_ptr, creator_type,
|
|
|
|
+ render_frame_host, storage_key, document_url, weak_document_ptr, creator_type,
|
2022-11-17 19:59:23 +00:00
|
|
|
std::move(receiver)));
|
2018-10-05 21:24:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h
|
2023-12-11 20:58:26 +00:00
|
|
|
index 1dc5478b8d0787a1cc82dc9fcb0227fed3f583c2..9a76f675ccdd4b173afa65aa05b733d456f30cff 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
|
2023-12-11 20:58:26 +00:00
|
|
|
@@ -46,6 +46,7 @@ class PlatformNotificationServiceProxy;
|
2022-04-12 11:19:14 +00:00
|
|
|
class RenderProcessHost;
|
2021-04-29 18:23:28 +00:00
|
|
|
class ServiceWorkerContextWrapper;
|
2023-12-11 20:58:26 +00:00
|
|
|
class WeakDocumentPtr;
|
2021-04-29 18:23:28 +00:00
|
|
|
+class RenderFrameHost;
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2021-04-29 18:23:28 +00:00
|
|
|
// Implementation of the Web Notification storage context. The public methods
|
|
|
|
// defined in this interface must only be called on the UI thread.
|
2023-12-11 20:58:26 +00:00
|
|
|
@@ -79,6 +80,7 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
|
2022-11-17 19:59:23 +00:00
|
|
|
// service is created by a dedicated worker, or is `nullptr` otherwise.
|
2019-07-24 22:58:51 +00:00
|
|
|
void CreateService(
|
2022-04-12 11:19:14 +00:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 18:23:28 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 02:35:34 +00:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|
2022-06-27 20:50:08 +00:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
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
|
2024-01-03 08:52:49 +00:00
|
|
|
index 0ef4f3f740102cfefdb8e2a87be0044fd88746d0..412887e0002a5bc65be1f5ecbed9e991972d373a 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
|
2023-11-14 21:21:32 +00:00
|
|
|
@@ -2035,7 +2035,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
2022-11-17 19:59:23 +00:00
|
|
|
case RenderProcessHost::NotificationServiceCreatorType::kSharedWorker:
|
|
|
|
case RenderProcessHost::NotificationServiceCreatorType::kDedicatedWorker: {
|
|
|
|
storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
|
2023-01-06 02:35:34 +00:00
|
|
|
- this, storage_key, /*document_url=*/GURL(), weak_document_ptr,
|
|
|
|
+ this, rfh, storage_key, /*document_url=*/GURL(), weak_document_ptr,
|
2022-11-17 19:59:23 +00:00
|
|
|
creator_type, std::move(receiver));
|
|
|
|
break;
|
|
|
|
}
|
2023-11-14 21:21:32 +00:00
|
|
|
@@ -2043,7 +2043,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
2022-11-17 19:59:23 +00:00
|
|
|
CHECK(rfh);
|
2019-12-11 00:22:35 +00:00
|
|
|
|
2022-11-17 19:59:23 +00:00
|
|
|
storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
|
2023-01-06 02:35:34 +00:00
|
|
|
- this, storage_key, rfh->GetLastCommittedURL(), weak_document_ptr,
|
|
|
|
+ this, rfh, storage_key, rfh->GetLastCommittedURL(), weak_document_ptr,
|
2022-11-17 19:59:23 +00:00
|
|
|
creator_type, std::move(receiver));
|
|
|
|
break;
|
|
|
|
}
|
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
|
2023-10-02 22:01:07 +00:00
|
|
|
index 82db1db4175fb9f4ee7490d5a163164ef4495ecb..4f51683be14ba6ee657a290c7747969e052a88ca 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
|
2021-04-27 21:27:34 +00:00
|
|
|
@@ -26,6 +26,8 @@ struct PlatformNotificationData;
|
2019-04-20 17:20:37 +00:00
|
|
|
|
2018-10-05 21:24:38 +00:00
|
|
|
namespace content {
|
|
|
|
|
2021-04-29 18:23:28 +00:00
|
|
|
+class RenderFrameHost;
|
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 {
|
2021-04-27 21:27:34 +00:00
|
|
|
// This method must be called on the UI thread. |document_url| is empty when
|
|
|
|
// the display notification originates from a worker.
|
2018-10-05 21:24:38 +00:00
|
|
|
virtual void DisplayNotification(
|
2021-04-29 18:23:28 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2018-10-05 21:24:38 +00:00
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|
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
|
2023-11-28 21:40:12 +00:00
|
|
|
index 2d3b66e8f1960b46d0e790d803fefb3b85c62603..c8106d1390e75bd74fc38cf138cca37ad08b1486 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
|
2023-08-15 15:49:41 +00:00
|
|
|
@@ -29,6 +29,7 @@ MockPlatformNotificationService::MockPlatformNotificationService(
|
2018-10-11 08:38:48 +00:00
|
|
|
MockPlatformNotificationService::~MockPlatformNotificationService() = default;
|
|
|
|
|
|
|
|
void MockPlatformNotificationService::DisplayNotification(
|
2022-01-11 19:27:24 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2018-10-11 08:38:48 +00:00
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|
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
|
2023-10-02 22:01:07 +00:00
|
|
|
index 66fd1e7f1171fec33c337375a9f8f11fcc6ab27e..188d507b42544dfab7abceed24097766496086b5 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
|
2022-01-10 22:31:39 +00:00
|
|
|
@@ -52,6 +52,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
2018-10-11 08:38:48 +00:00
|
|
|
|
|
|
|
// PlatformNotificationService implementation.
|
|
|
|
void DisplayNotification(
|
2022-01-11 19:27:24 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2018-10-11 08:38:48 +00:00
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2021-04-27 21:27:34 +00:00
|
|
|
const GURL& document_url,
|