electron/patches/common/chromium/notification_provenance.patch
2019-04-02 14:43:03 -07:00

164 lines
9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <jeremya@chromium.org>
Date: Fri, 5 Oct 2018 14:22:06 -0700
Subject: pass RenderProcessHost through to PlatformNotificationService
this is so Electron can identify which renderer a notification came from
diff --git a/content/browser/notifications/blink_notification_service_impl.cc b/content/browser/notifications/blink_notification_service_impl.cc
index f251139f5976d4ff52ac4d0f89a2c627c1809c8a..457890dcb49ca59c61326c633d74eabcf999ff08 100644
--- a/content/browser/notifications/blink_notification_service_impl.cc
+++ b/content/browser/notifications/blink_notification_service_impl.cc
@@ -71,9 +71,11 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
PlatformNotificationContextImpl* notification_context,
BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
+ RenderProcessHost* render_process_host,
const url::Origin& origin,
mojo::InterfaceRequest<blink::mojom::NotificationService> request)
: notification_context_(notification_context),
+ render_process_host_(render_process_host),
browser_context_(browser_context),
service_worker_context_(std::move(service_worker_context)),
origin_(origin),
@@ -133,7 +135,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
notification_id, std::move(event_listener_ptr));
GetNotificationService()->DisplayNotification(
- browser_context_, notification_id, origin_.GetURL(),
+ render_process_host_, browser_context_, notification_id, origin_.GetURL(),
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 cc5f8d1e673962cb435ad9c9547c336ad5542c84..c340739dc78519606081e4190d4538a74e72501a 100644
--- a/content/browser/notifications/blink_notification_service_impl.h
+++ b/content/browser/notifications/blink_notification_service_impl.h
@@ -36,6 +36,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
PlatformNotificationContextImpl* notification_context,
BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
+ RenderProcessHost* render_process_host,
const url::Origin& origin,
mojo::InterfaceRequest<blink::mojom::NotificationService> request);
~BlinkNotificationServiceImpl() override;
@@ -99,6 +100,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
// The notification context that owns this service instance.
PlatformNotificationContextImpl* notification_context_;
+ RenderProcessHost* render_process_host_;
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 8beb9e516bcf636e95f7481837e67e197422d830..d9fc224db4704057e8cb1596173310d8392bc7d7 100644
--- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
+++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
@@ -130,7 +130,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)),
mojo::MakeRequest(&notification_service_ptr_));
diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
index 739a98f2846f0e680e5b175c19692edf754a2bc7..2e9e406e066c750d7fb80ab719265df3e2dba38e 100644
--- a/content/browser/notifications/platform_notification_context_impl.cc
+++ b/content/browser/notifications/platform_notification_context_impl.cc
@@ -182,12 +182,13 @@ void PlatformNotificationContextImpl::Shutdown() {
}
void PlatformNotificationContextImpl::CreateService(
+ RenderProcessHost* render_process_host,
const url::Origin& origin,
blink::mojom::NotificationServiceRequest request) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
services_.push_back(std::make_unique<BlinkNotificationServiceImpl>(
- this, browser_context_, service_worker_context_, origin,
- std::move(request)));
+ this, browser_context_, service_worker_context_, render_process_host,
+ origin, std::move(request)));
}
void PlatformNotificationContextImpl::RemoveService(
diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h
index 24918cede3f2894627c7aaa29e68fa3834bea108..b31583d13a73c72f5a27587add92855472f30dc8 100644
--- a/content/browser/notifications/platform_notification_context_impl.h
+++ b/content/browser/notifications/platform_notification_context_impl.h
@@ -24,6 +24,7 @@
#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"
#include "third_party/blink/public/platform/modules/notifications/notification_service.mojom.h"
class GURL;
@@ -65,7 +66,8 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
void Shutdown();
// Creates a BlinkNotificationServiceImpl that is owned by this context.
- void CreateService(const url::Origin& origin,
+ void CreateService(RenderProcessHost* render_process_host,
+ const url::Origin& origin,
blink::mojom::NotificationServiceRequest request);
// Removes |service| from the list of owned services, for example because the
diff --git a/content/browser/renderer_interface_binders.cc b/content/browser/renderer_interface_binders.cc
index b317a37b4fa12be4e737a91948110fd16308c221..b3968f52c478ce051370e543b2fb904360d7892c 100644
--- a/content/browser/renderer_interface_binders.cc
+++ b/content/browser/renderer_interface_binders.cc
@@ -189,7 +189,7 @@ void RendererInterfaceBinders::InitializeParameterizedBinderRegistry() {
RenderProcessHost* host, const url::Origin& origin) {
static_cast<StoragePartitionImpl*>(host->GetStoragePartition())
->GetPlatformNotificationContext()
- ->CreateService(origin, std::move(request));
+ ->CreateService(host, origin, std::move(request));
}));
parameterized_binder_registry_.AddInterface(
base::BindRepeating(&BackgroundFetchServiceImpl::CreateForWorker));
diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
index b8aaa76d1ffcf92251fd7f229a8e075aba5b2ce3..ab1151f63ff0f21cad5747f5f96afe89d9207107 100644
--- a/content/public/browser/platform_notification_service.h
+++ b/content/public/browser/platform_notification_service.h
@@ -28,6 +28,7 @@ struct PlatformNotificationData;
namespace content {
class BrowserContext;
+class RenderProcessHost;
// The service using which notifications can be presented to the user. There
// should be a unique instance of the PlatformNotificationService depending
@@ -43,6 +44,7 @@ class CONTENT_EXPORT PlatformNotificationService {
// 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,
BrowserContext* browser_context,
const std::string& notification_id,
const GURL& origin,
diff --git a/content/test/mock_platform_notification_service.cc b/content/test/mock_platform_notification_service.cc
index a313cb378e5623b9e55786829e0043974c0cb294..26deae4aa831e050035afb294673d7861c4c7578 100644
--- a/content/test/mock_platform_notification_service.cc
+++ b/content/test/mock_platform_notification_service.cc
@@ -26,6 +26,7 @@ MockPlatformNotificationService::MockPlatformNotificationService() = default;
MockPlatformNotificationService::~MockPlatformNotificationService() = default;
void MockPlatformNotificationService::DisplayNotification(
+ RenderProcessHost* render_process_host,
BrowserContext* browser_context,
const std::string& notification_id,
const GURL& origin,
diff --git a/content/test/mock_platform_notification_service.h b/content/test/mock_platform_notification_service.h
index 9488023df808cfd6633b3ab9b02d66a1bd929d29..d16e9394d1eea6bc657d1a07a1d09c52a7692bdd 100644
--- a/content/test/mock_platform_notification_service.h
+++ b/content/test/mock_platform_notification_service.h
@@ -45,6 +45,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
// PlatformNotificationService implementation.
void DisplayNotification(
+ RenderProcessHost* render_process_host,
BrowserContext* browser_context,
const std::string& notification_id,
const GURL& origin,