123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Jeremy Apthorp <[email protected]>
- Date: Fri, 5 Oct 2018 14:22:06 -0700
- Subject: notification_provenance.patch
- Pass RenderFrameHost through to PlatformNotificationService
- so Electron can identify which renderer a notification came from.
- diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
- index ec78c36d4541d9d34f2109b880109ebe3bc817f8..67d92005e53cccbc9a4ae8a0db9c2c6220a09d88 100644
- --- a/chrome/browser/notifications/platform_notification_service_impl.cc
- +++ b/chrome/browser/notifications/platform_notification_service_impl.cc
- @@ -239,6 +239,7 @@ bool PlatformNotificationServiceImpl::WasClosedProgrammatically(
-
- // 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
- index 178afda936a25643320b6e36a0497cbfbc370770..1a795c5059b3e41539c1f34a8d2ad23a28247cd6 100644
- --- a/chrome/browser/notifications/platform_notification_service_impl.h
- +++ b/chrome/browser/notifications/platform_notification_service_impl.h
- @@ -57,6 +57,7 @@ class PlatformNotificationServiceImpl
-
- // content::PlatformNotificationService implementation.
- void DisplayNotification(
- + content::RenderFrameHost* render_frame_host,
- const std::string& notification_id,
- const GURL& origin,
- const GURL& document_url,
- diff --git a/content/browser/notifications/blink_notification_service_impl.cc b/content/browser/notifications/blink_notification_service_impl.cc
- index 776c9b4bad591bb0174457caadf5bcab5ffc490b..b5475b328299d823c2cee8cae2fc9111ebc033cb 100644
- --- a/content/browser/notifications/blink_notification_service_impl.cc
- +++ b/content/browser/notifications/blink_notification_service_impl.cc
- @@ -84,12 +84,14 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
- BrowserContext* browser_context,
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
- RenderProcessHost* render_process_host,
- + RenderFrameHost* render_frame_host,
- const blink::StorageKey& storage_key,
- const GURL& document_url,
- const WeakDocumentPtr& weak_document_ptr,
- RenderProcessHost::NotificationServiceCreatorType creator_type,
- mojo::PendingReceiver<blink::mojom::NotificationService> receiver)
- : notification_context_(notification_context),
- + render_frame_host_(render_frame_host),
- browser_context_(browser_context),
- service_worker_context_(std::move(service_worker_context)),
- render_process_host_id_(render_process_host->GetDeprecatedID()),
- @@ -181,7 +183,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
- creator_type_);
-
- browser_context_->GetPlatformNotificationService()->DisplayNotification(
- - notification_id, storage_key_.origin().GetURL(), document_url_,
- + render_frame_host_, notification_id, storage_key_.origin().GetURL(), document_url_,
- platform_notification_data, notification_resources);
- }
-
- diff --git a/content/browser/notifications/blink_notification_service_impl.h b/content/browser/notifications/blink_notification_service_impl.h
- index e7cc73f375ada7ee8715d331c3d372e0f59a0cdf..c0a142bea4a9a30c10dbb30c72fedce9ab4d1e62 100644
- --- a/content/browser/notifications/blink_notification_service_impl.h
- +++ b/content/browser/notifications/blink_notification_service_impl.h
- @@ -44,6 +44,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
- BrowserContext* browser_context,
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
- RenderProcessHost* render_process_host,
- + RenderFrameHost* render_frame_host,
- const blink::StorageKey& storage_key,
- const GURL& document_url,
- const WeakDocumentPtr& weak_document_ptr,
- @@ -113,6 +114,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
- raw_ptr<PlatformNotificationContextImpl, DanglingUntriaged>
- notification_context_;
-
- + raw_ptr<RenderFrameHost> render_frame_host_;
- raw_ptr<BrowserContext> browser_context_;
-
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
- diff --git a/content/browser/notifications/blink_notification_service_impl_unittest.cc b/content/browser/notifications/blink_notification_service_impl_unittest.cc
- index 07e06ac6a3f14081f61f44620b537e5442419660..f2b8a977277c1f1ab014edd007d5df766b70f328 100644
- --- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
- +++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
- @@ -129,7 +129,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
- notification_service_ = std::make_unique<BlinkNotificationServiceImpl>(
- notification_context_.get(), &browser_context_,
- embedded_worker_helper_->context_wrapper(), &render_process_host_,
- - storage_key_,
- + nullptr, storage_key_,
- /*document_url=*/GURL(),
- contents_.get()->GetPrimaryMainFrame()->GetWeakDocumentPtr(),
- RenderProcessHost::NotificationServiceCreatorType::kDocument,
- diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
- index 09ddcfdcf1bbdc35f8e2ad9c89e05f76a6231f68..e3e87a7d08cb2f55706d7d4f06245817811bc83b 100644
- --- a/content/browser/notifications/platform_notification_context_impl.cc
- +++ b/content/browser/notifications/platform_notification_context_impl.cc
- @@ -280,6 +280,7 @@ void PlatformNotificationContextImpl::Shutdown() {
-
- void PlatformNotificationContextImpl::CreateService(
- RenderProcessHost* render_process_host,
- + RenderFrameHost* render_frame_host,
- const blink::StorageKey& storage_key,
- const GURL& document_url,
- const WeakDocumentPtr& weak_document_ptr,
- @@ -288,7 +289,7 @@ void PlatformNotificationContextImpl::CreateService(
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- services_.push_back(std::make_unique<BlinkNotificationServiceImpl>(
- this, browser_context_, service_worker_context_, render_process_host,
- - storage_key, document_url, weak_document_ptr, creator_type,
- + render_frame_host, storage_key, document_url, weak_document_ptr, creator_type,
- std::move(receiver)));
- }
-
- diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h
- index 05d3a12dd84c7005d46cc73b312f97ef418d96f5..4765de982802541b3efc7211d106acc72518fd0a 100644
- --- a/content/browser/notifications/platform_notification_context_impl.h
- +++ b/content/browser/notifications/platform_notification_context_impl.h
- @@ -47,6 +47,7 @@ class PlatformNotificationServiceProxy;
- class RenderProcessHost;
- class ServiceWorkerContextWrapper;
- class WeakDocumentPtr;
- +class RenderFrameHost;
-
- // Implementation of the Web Notification storage context. The public methods
- // defined in this interface must only be called on the UI thread.
- @@ -80,6 +81,7 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
- // service is created by a dedicated worker, or is `nullptr` otherwise.
- void CreateService(
- RenderProcessHost* render_process_host,
- + RenderFrameHost* render_frame_host,
- const blink::StorageKey& storage_key,
- const GURL& document_url,
- const WeakDocumentPtr& weak_document_ptr,
- diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
- index 2ad61dcfc289e20ee1c36540db17301450d37b8b..72f28e56f39561cb4832cb403d8e9c24e53ce133 100644
- --- a/content/browser/renderer_host/render_process_host_impl.cc
- +++ b/content/browser/renderer_host/render_process_host_impl.cc
- @@ -2156,7 +2156,7 @@ void RenderProcessHostImpl::CreateNotificationService(
- case RenderProcessHost::NotificationServiceCreatorType::kSharedWorker:
- case RenderProcessHost::NotificationServiceCreatorType::kDedicatedWorker: {
- storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
- - this, storage_key, /*document_url=*/GURL(), weak_document_ptr,
- + this, rfh, storage_key, /*document_url=*/GURL(), weak_document_ptr,
- creator_type, std::move(receiver));
- break;
- }
- @@ -2164,7 +2164,7 @@ void RenderProcessHostImpl::CreateNotificationService(
- CHECK(rfh);
-
- storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
- - this, storage_key, rfh->GetLastCommittedURL(), weak_document_ptr,
- + this, rfh, storage_key, rfh->GetLastCommittedURL(), weak_document_ptr,
- creator_type, std::move(receiver));
- break;
- }
- diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
- index 82db1db4175fb9f4ee7490d5a163164ef4495ecb..4f51683be14ba6ee657a290c7747969e052a88ca 100644
- --- a/content/public/browser/platform_notification_service.h
- +++ b/content/public/browser/platform_notification_service.h
- @@ -26,6 +26,8 @@ struct PlatformNotificationData;
-
- namespace content {
-
- +class RenderFrameHost;
- +
- // The service using which notifications can be presented to the user. There
- // should be a unique instance of the PlatformNotificationService depending
- // on the browsing context being used.
- @@ -41,6 +43,7 @@ class CONTENT_EXPORT PlatformNotificationService {
- // This method must be called on the UI thread. |document_url| is empty when
- // the display notification originates from a worker.
- virtual void DisplayNotification(
- + RenderFrameHost* render_frame_host,
- const std::string& notification_id,
- const GURL& origin,
- const GURL& document_url,
- diff --git a/content/test/mock_platform_notification_service.cc b/content/test/mock_platform_notification_service.cc
- index 32a0cf38389989d3e1c287ad4a3f26b6d3615370..8a788f243e913ef26246b5ea4ac4ac5c1dfc4b86 100644
- --- a/content/test/mock_platform_notification_service.cc
- +++ b/content/test/mock_platform_notification_service.cc
- @@ -29,6 +29,7 @@ MockPlatformNotificationService::MockPlatformNotificationService(
- MockPlatformNotificationService::~MockPlatformNotificationService() = default;
-
- void MockPlatformNotificationService::DisplayNotification(
- + RenderFrameHost* render_frame_host,
- const std::string& notification_id,
- const GURL& origin,
- const GURL& document_url,
- diff --git a/content/test/mock_platform_notification_service.h b/content/test/mock_platform_notification_service.h
- index 5e91d867ba1b04358ecb670ba407adc65793b417..a0c5eaafd9ec2242927fe9170e9acd4069f654a0 100644
- --- a/content/test/mock_platform_notification_service.h
- +++ b/content/test/mock_platform_notification_service.h
- @@ -53,6 +53,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
-
- // PlatformNotificationService implementation.
- void DisplayNotification(
- + RenderFrameHost* render_frame_host,
- const std::string& notification_id,
- const GURL& origin,
- const GURL& document_url,
|