123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- 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 225609e52130d4113c8ae667f3ffa565bbde5b73..b33d27ce4fc6222146255cf4c0e7342751c75c9b 100644
- --- a/chrome/browser/notifications/platform_notification_service_impl.cc
- +++ b/chrome/browser/notifications/platform_notification_service_impl.cc
- @@ -196,6 +196,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 b0e64049d411305d58802fd290bb0480e9b36fee..4afcf3b7a5b841409b0e1c4c2f32fd4878f12768 100644
- --- a/chrome/browser/notifications/platform_notification_service_impl.h
- +++ b/chrome/browser/notifications/platform_notification_service_impl.h
- @@ -56,6 +56,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 fd2c2d72ebc3cab0cc824bb091da32d4be635dd9..8bcd6a87c38413a5281d164e3c0fcfd23c3fa04b 100644
- --- a/content/browser/notifications/blink_notification_service_impl.cc
- +++ b/content/browser/notifications/blink_notification_service_impl.cc
- @@ -81,10 +81,12 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
- PlatformNotificationContextImpl* notification_context,
- BrowserContext* browser_context,
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
- + RenderFrameHost* render_frame_host,
- const url::Origin& origin,
- const GURL& document_url,
- 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)),
- origin_(origin),
- @@ -147,7 +149,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
- notification_id, std::move(event_listener_remote));
-
- browser_context_->GetPlatformNotificationService()->DisplayNotification(
- - notification_id, origin_.GetURL(), document_url_,
- + render_frame_host_, notification_id, 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 cb2b09912dbe426611e944316841ee2a9c2e373f..4d2603c29b2d89fa296b1aad40c2132a9c7498aa 100644
- --- a/content/browser/notifications/blink_notification_service_impl.h
- +++ b/content/browser/notifications/blink_notification_service_impl.h
- @@ -41,6 +41,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
- PlatformNotificationContextImpl* notification_context,
- BrowserContext* browser_context,
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
- + RenderFrameHost* render_frame_host,
- const url::Origin& origin,
- const GURL& document_url,
- mojo::PendingReceiver<blink::mojom::NotificationService> receiver);
- @@ -101,6 +102,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
- // The notification context that owns this service instance.
- raw_ptr<PlatformNotificationContextImpl> 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 f0d5ea365cf09d2dc06de88fc03e4bf5ddfdf4a6..b68666813ab231a3d4233d3ed2f9655b18d8a280 100644
- --- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
- +++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
- @@ -126,7 +126,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
-
- 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)),
- /*document_url=*/GURL(),
- notification_service_remote_.BindNewPipeAndPassReceiver());
- diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
- index 5580c415a1e8a45327147861d7c71cebd1ecbd5a..d37711f83be7566ec5ad2078942aaca1948a77c5 100644
- --- a/content/browser/notifications/platform_notification_context_impl.cc
- +++ b/content/browser/notifications/platform_notification_context_impl.cc
- @@ -281,13 +281,14 @@ void PlatformNotificationContextImpl::Shutdown() {
- }
-
- void PlatformNotificationContextImpl::CreateService(
- + RenderFrameHost* render_frame_host,
- const url::Origin& origin,
- const GURL& document_url,
- mojo::PendingReceiver<blink::mojom::NotificationService> receiver) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- services_.push_back(std::make_unique<BlinkNotificationServiceImpl>(
- - this, browser_context_, service_worker_context_, origin, document_url,
- - std::move(receiver)));
- + this, browser_context_, service_worker_context_, render_frame_host,
- + origin, document_url, std::move(receiver)));
- }
-
- void PlatformNotificationContextImpl::RemoveService(
- diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h
- index 951075749b24814606f494c5a89ee2adf527f512..7036323ff8ee38ae92790dfd2e216df61181bc55 100644
- --- a/content/browser/notifications/platform_notification_context_impl.h
- +++ b/content/browser/notifications/platform_notification_context_impl.h
- @@ -47,6 +47,7 @@ class BrowserContext;
- struct NotificationDatabaseData;
- class PlatformNotificationServiceProxy;
- class ServiceWorkerContextWrapper;
- +class RenderFrameHost;
-
- // Implementation of the Web Notification storage context. The public methods
- // defined in this interface must only be called on the UI thread.
- @@ -76,6 +77,7 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
- // Creates a BlinkNotificationServiceImpl that is owned by this context.
- // |document_url| is empty when originating from a worker.
- void CreateService(
- + RenderFrameHost* render_frame_host,
- const url::Origin& origin,
- const GURL& document_url,
- mojo::PendingReceiver<blink::mojom::NotificationService> receiver);
- diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
- index cc5f7c8d616ec9a433da428f180483da60736a9d..fb25a7c19f20ca690963c5a15bd09224687b5f57 100644
- --- a/content/browser/renderer_host/render_process_host_impl.cc
- +++ b/content/browser/renderer_host/render_process_host_impl.cc
- @@ -2083,7 +2083,7 @@ void RenderProcessHostImpl::CreateNotificationService(
- document_url = rfh->GetLastCommittedURL();
-
- storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
- - origin, document_url, std::move(receiver));
- + RenderFrameHost::FromID(GetID(), render_frame_id), origin, document_url, std::move(receiver));
- }
-
- void RenderProcessHostImpl::CreateWebSocketConnector(
- diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
- index 9646cbeb31141e3518f51482801431f3a6010360..b13b6ab07b4931b892749c84879d9a6adb3bcb58 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 7397963a36bec7016ae92fbc4bb741825e5fb8d1..d1818311fd657d3c099cdce41898daf4ab3ede8b 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 45ad11f0fc5f0abebbc05836221528e59da6c26b..7f914f69d597dbd149d554dc0282c27ed234c7ed 100644
- --- a/content/test/mock_platform_notification_service.h
- +++ b/content/test/mock_platform_notification_service.h
- @@ -52,6 +52,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,
|