2018-10-24 21:24:11 +03:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-10-06 00:24:38 +03:00
|
|
|
From: Jeremy Apthorp <jeremya@chromium.org>
|
|
|
|
Date: Fri, 5 Oct 2018 14:22:06 -0700
|
2019-08-24 04:14:23 +03:00
|
|
|
Subject: notification_provenance.patch
|
2018-10-06 00:24:38 +03:00
|
|
|
|
2022-01-11 22:27:24 +03:00
|
|
|
Pass RenderFrameHost through to PlatformNotificationService
|
2019-08-24 04:14:23 +03:00
|
|
|
so Electron can identify which renderer a notification came from.
|
2018-10-06 00:24:38 +03:00
|
|
|
|
2022-01-11 22:27:24 +03:00
|
|
|
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
|
2024-10-21 03:02:21 +03:00
|
|
|
index ff536e07810d0360d4125587bcc90a2bd3f3ff12..2f632906947fc9b02eaf8547dce5e2b5a9ca46a3 100644
|
2022-01-11 22:27:24 +03:00
|
|
|
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
|
|
|
|
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
|
2024-06-08 00:18:35 +03:00
|
|
|
@@ -218,6 +218,7 @@ bool PlatformNotificationServiceImpl::WasClosedProgrammatically(
|
2022-01-11 22:27:24 +03: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
|
2024-06-08 00:18:35 +03:00
|
|
|
index c173f8a6cde9ab519075987fa451afb63c6580a9..4a1f128d9252a4a858d5ba8c6991bb183de7f064 100644
|
2022-01-11 22:27:24 +03:00
|
|
|
--- a/chrome/browser/notifications/platform_notification_service_impl.h
|
|
|
|
+++ b/chrome/browser/notifications/platform_notification_service_impl.h
|
2023-08-15 18:49:41 +03:00
|
|
|
@@ -57,6 +57,7 @@ class PlatformNotificationServiceImpl
|
2022-01-11 22:27:24 +03: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-06 00:24:38 +03:00
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl.cc b/content/browser/notifications/blink_notification_service_impl.cc
|
2024-05-10 18:21:10 +03:00
|
|
|
index 027ba5088355441ed2dd1abe563277df7c1d3737..65837dcf0c2cd0bcc0c000fc3fe5eb2ddd6f7b5f 100644
|
2018-10-06 00:24:38 +03:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
2023-01-06 05:35:34 +03:00
|
|
|
@@ -87,12 +87,14 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
|
2018-10-06 00:24:38 +03:00
|
|
|
BrowserContext* browser_context,
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
2022-04-12 14:19:14 +03:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 21:23:28 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 05:35:34 +03:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|
2022-06-27 23:50:08 +03:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2022-11-17 22:59:23 +03:00
|
|
|
RenderProcessHost::NotificationServiceCreatorType creator_type,
|
2019-07-25 01:58:51 +03:00
|
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver)
|
2018-10-06 00:24:38 +03:00
|
|
|
: notification_context_(notification_context),
|
2021-04-29 21:23:28 +03:00
|
|
|
+ render_frame_host_(render_frame_host),
|
2018-10-06 00:24:38 +03:00
|
|
|
browser_context_(browser_context),
|
|
|
|
service_worker_context_(std::move(service_worker_context)),
|
2022-04-12 14:19:14 +03:00
|
|
|
render_process_host_id_(render_process_host->GetID()),
|
2023-01-06 05:35:34 +03:00
|
|
|
@@ -184,7 +186,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
2022-11-17 22:59:23 +03:00
|
|
|
creator_type_);
|
2018-10-06 00:24:38 +03:00
|
|
|
|
2021-10-06 05:21:00 +03:00
|
|
|
browser_context_->GetPlatformNotificationService()->DisplayNotification(
|
2023-01-06 05:35:34 +03:00
|
|
|
- notification_id, storage_key_.origin().GetURL(), document_url_,
|
|
|
|
+ render_frame_host_, notification_id, storage_key_.origin().GetURL(), document_url_,
|
2021-10-06 05:21:00 +03:00
|
|
|
platform_notification_data, notification_resources);
|
2018-10-06 00:24:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl.h b/content/browser/notifications/blink_notification_service_impl.h
|
2023-06-10 02:08:36 +03:00
|
|
|
index e7cc73f375ada7ee8715d331c3d372e0f59a0cdf..c0a142bea4a9a30c10dbb30c72fedce9ab4d1e62 100644
|
2018-10-06 00:24:38 +03:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl.h
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.h
|
2022-11-17 22:59:23 +03:00
|
|
|
@@ -44,6 +44,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
2018-10-06 00:24:38 +03:00
|
|
|
BrowserContext* browser_context,
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
2022-04-12 14:19:14 +03:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 21:23:28 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 05:35:34 +03:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|
2022-06-27 23:50:08 +03:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2023-06-10 02:08:36 +03:00
|
|
|
@@ -113,6 +114,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
|
|
|
raw_ptr<PlatformNotificationContextImpl, DanglingUntriaged>
|
|
|
|
notification_context_;
|
2018-10-06 00:24:38 +03:00
|
|
|
|
2022-01-11 01:31:39 +03:00
|
|
|
+ raw_ptr<RenderFrameHost> render_frame_host_;
|
|
|
|
raw_ptr<BrowserContext> browser_context_;
|
2018-10-06 00:24:38 +03:00
|
|
|
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
|
2018-10-11 11:38:48 +03:00
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl_unittest.cc b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
2024-06-08 00:18:35 +03:00
|
|
|
index fe56b0bde4480765e5dffe5afb6ddf73ca8d63c8..93de0ace3dabf526d737897d42df35a5c2accab2 100644
|
2018-10-11 11:38:48 +03:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
2024-01-25 20:46:30 +03:00
|
|
|
@@ -132,7 +132,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
|
2018-10-11 11:38:48 +03:00
|
|
|
notification_service_ = std::make_unique<BlinkNotificationServiceImpl>(
|
|
|
|
notification_context_.get(), &browser_context_,
|
2022-04-12 14:19:14 +03:00
|
|
|
embedded_worker_helper_->context_wrapper(), &render_process_host_,
|
2023-01-06 05:35:34 +03:00
|
|
|
- storage_key_,
|
|
|
|
+ nullptr, storage_key_,
|
2021-04-28 00:27:34 +03:00
|
|
|
/*document_url=*/GURL(),
|
2022-11-17 22:59:23 +03:00
|
|
|
contents_.get()->GetPrimaryMainFrame()->GetWeakDocumentPtr(),
|
|
|
|
RenderProcessHost::NotificationServiceCreatorType::kDocument,
|
2018-10-06 00:24:38 +03:00
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
|
2024-09-25 14:19:39 +03:00
|
|
|
index a5db92c83aa43375d4b1cdae77c2d5a78f13be29..a8c39d1153bae98259039cebfc1817436f951423 100644
|
2018-10-06 00:24:38 +03:00
|
|
|
--- a/content/browser/notifications/platform_notification_context_impl.cc
|
|
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.cc
|
2024-09-25 14:19:39 +03:00
|
|
|
@@ -282,6 +282,7 @@ void PlatformNotificationContextImpl::Shutdown() {
|
2018-10-06 00:24:38 +03:00
|
|
|
|
|
|
|
void PlatformNotificationContextImpl::CreateService(
|
2022-04-12 14:19:14 +03:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 21:23:28 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 05:35:34 +03:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|
2022-06-27 23:50:08 +03:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2024-09-25 14:19:39 +03:00
|
|
|
@@ -290,7 +291,7 @@ void PlatformNotificationContextImpl::CreateService(
|
2018-10-06 00:24:38 +03:00
|
|
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
|
services_.push_back(std::make_unique<BlinkNotificationServiceImpl>(
|
2022-04-12 14:19:14 +03:00
|
|
|
this, browser_context_, service_worker_context_, render_process_host,
|
2023-01-06 05:35:34 +03: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 22:59:23 +03:00
|
|
|
std::move(receiver)));
|
2018-10-06 00:24:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h
|
2024-09-25 14:19:39 +03:00
|
|
|
index 05d3a12dd84c7005d46cc73b312f97ef418d96f5..4765de982802541b3efc7211d106acc72518fd0a 100644
|
2018-10-06 00:24:38 +03:00
|
|
|
--- a/content/browser/notifications/platform_notification_context_impl.h
|
|
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.h
|
2024-01-25 20:46:30 +03:00
|
|
|
@@ -47,6 +47,7 @@ class PlatformNotificationServiceProxy;
|
2022-04-12 14:19:14 +03:00
|
|
|
class RenderProcessHost;
|
2021-04-29 21:23:28 +03:00
|
|
|
class ServiceWorkerContextWrapper;
|
2023-12-11 23:58:26 +03:00
|
|
|
class WeakDocumentPtr;
|
2021-04-29 21:23:28 +03:00
|
|
|
+class RenderFrameHost;
|
2018-10-06 00:24:38 +03:00
|
|
|
|
2021-04-29 21:23:28 +03:00
|
|
|
// Implementation of the Web Notification storage context. The public methods
|
|
|
|
// defined in this interface must only be called on the UI thread.
|
2024-01-25 20:46:30 +03:00
|
|
|
@@ -80,6 +81,7 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
|
2022-11-17 22:59:23 +03:00
|
|
|
// service is created by a dedicated worker, or is `nullptr` otherwise.
|
2019-07-25 01:58:51 +03:00
|
|
|
void CreateService(
|
2022-04-12 14:19:14 +03:00
|
|
|
RenderProcessHost* render_process_host,
|
2021-04-29 21:23:28 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2023-01-06 05:35:34 +03:00
|
|
|
const blink::StorageKey& storage_key,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|
2022-06-27 23:50:08 +03:00
|
|
|
const WeakDocumentPtr& weak_document_ptr,
|
2019-12-11 03:22:35 +03:00
|
|
|
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
|
2024-11-06 03:46:57 +03:00
|
|
|
index 92052ce2da68b0901cf1002022a554eec19e3995..98194c630811de8cb869dffb4b21cc79e0d98b33 100644
|
2019-12-11 03:22:35 +03:00
|
|
|
--- a/content/browser/renderer_host/render_process_host_impl.cc
|
|
|
|
+++ b/content/browser/renderer_host/render_process_host_impl.cc
|
2024-11-06 03:46:57 +03:00
|
|
|
@@ -2105,7 +2105,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
2022-11-17 22:59:23 +03:00
|
|
|
case RenderProcessHost::NotificationServiceCreatorType::kSharedWorker:
|
|
|
|
case RenderProcessHost::NotificationServiceCreatorType::kDedicatedWorker: {
|
|
|
|
storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
|
2023-01-06 05:35:34 +03:00
|
|
|
- this, storage_key, /*document_url=*/GURL(), weak_document_ptr,
|
|
|
|
+ this, rfh, storage_key, /*document_url=*/GURL(), weak_document_ptr,
|
2022-11-17 22:59:23 +03:00
|
|
|
creator_type, std::move(receiver));
|
|
|
|
break;
|
|
|
|
}
|
2024-11-06 03:46:57 +03:00
|
|
|
@@ -2113,7 +2113,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
2022-11-17 22:59:23 +03:00
|
|
|
CHECK(rfh);
|
2019-12-11 03:22:35 +03:00
|
|
|
|
2022-11-17 22:59:23 +03:00
|
|
|
storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
|
2023-01-06 05:35:34 +03:00
|
|
|
- this, storage_key, rfh->GetLastCommittedURL(), weak_document_ptr,
|
|
|
|
+ this, rfh, storage_key, rfh->GetLastCommittedURL(), weak_document_ptr,
|
2022-11-17 22:59:23 +03:00
|
|
|
creator_type, std::move(receiver));
|
|
|
|
break;
|
|
|
|
}
|
2018-10-06 00:24:38 +03:00
|
|
|
diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
|
2023-10-03 01:01:07 +03:00
|
|
|
index 82db1db4175fb9f4ee7490d5a163164ef4495ecb..4f51683be14ba6ee657a290c7747969e052a88ca 100644
|
2018-10-06 00:24:38 +03:00
|
|
|
--- a/content/public/browser/platform_notification_service.h
|
|
|
|
+++ b/content/public/browser/platform_notification_service.h
|
2021-04-28 00:27:34 +03:00
|
|
|
@@ -26,6 +26,8 @@ struct PlatformNotificationData;
|
2019-04-20 20:20:37 +03:00
|
|
|
|
2018-10-06 00:24:38 +03:00
|
|
|
namespace content {
|
|
|
|
|
2021-04-29 21:23:28 +03:00
|
|
|
+class RenderFrameHost;
|
2019-04-20 20:20:37 +03:00
|
|
|
+
|
2019-01-12 04:00:43 +03: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 20:20:37 +03:00
|
|
|
// on the browsing context being used.
|
|
|
|
@@ -41,6 +43,7 @@ class CONTENT_EXPORT PlatformNotificationService {
|
2021-04-28 00:27:34 +03:00
|
|
|
// This method must be called on the UI thread. |document_url| is empty when
|
|
|
|
// the display notification originates from a worker.
|
2018-10-06 00:24:38 +03:00
|
|
|
virtual void DisplayNotification(
|
2021-04-29 21:23:28 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2018-10-06 00:24:38 +03:00
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|
2018-10-11 11:38:48 +03:00
|
|
|
diff --git a/content/test/mock_platform_notification_service.cc b/content/test/mock_platform_notification_service.cc
|
2024-01-25 20:46:30 +03:00
|
|
|
index 32a0cf38389989d3e1c287ad4a3f26b6d3615370..8a788f243e913ef26246b5ea4ac4ac5c1dfc4b86 100644
|
2018-10-11 11:38:48 +03:00
|
|
|
--- a/content/test/mock_platform_notification_service.cc
|
|
|
|
+++ b/content/test/mock_platform_notification_service.cc
|
2023-08-15 18:49:41 +03:00
|
|
|
@@ -29,6 +29,7 @@ MockPlatformNotificationService::MockPlatformNotificationService(
|
2018-10-11 11:38:48 +03:00
|
|
|
MockPlatformNotificationService::~MockPlatformNotificationService() = default;
|
|
|
|
|
|
|
|
void MockPlatformNotificationService::DisplayNotification(
|
2022-01-11 22:27:24 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2018-10-11 11:38:48 +03:00
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|
2018-10-11 11:38:48 +03:00
|
|
|
diff --git a/content/test/mock_platform_notification_service.h b/content/test/mock_platform_notification_service.h
|
2024-01-25 20:46:30 +03:00
|
|
|
index 5e91d867ba1b04358ecb670ba407adc65793b417..a0c5eaafd9ec2242927fe9170e9acd4069f654a0 100644
|
2018-10-11 11:38:48 +03:00
|
|
|
--- a/content/test/mock_platform_notification_service.h
|
|
|
|
+++ b/content/test/mock_platform_notification_service.h
|
2024-01-25 20:46:30 +03:00
|
|
|
@@ -53,6 +53,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
2018-10-11 11:38:48 +03:00
|
|
|
|
|
|
|
// PlatformNotificationService implementation.
|
|
|
|
void DisplayNotification(
|
2022-01-11 22:27:24 +03:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
2018-10-11 11:38:48 +03:00
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|
2021-04-28 00:27:34 +03:00
|
|
|
const GURL& document_url,
|