166 lines
9.2 KiB
Diff
166 lines
9.2 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 ceb4bc6248a961bd907e35e9f758cebdbd0ae62b..c85acbb33b7b467716b717159816a00e67d46119 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
|
@@ -88,9 +88,11 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
|
|
PlatformNotificationContextImpl* notification_context,
|
|
BrowserContext* browser_context,
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
|
|
+ RenderProcessHost* render_process_host,
|
|
const url::Origin& origin,
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver)
|
|
: notification_context_(notification_context),
|
|
+ render_process_host_(render_process_host),
|
|
browser_context_(browser_context),
|
|
service_worker_context_(std::move(service_worker_context)),
|
|
origin_(origin),
|
|
@@ -151,8 +153,9 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
|
notification_id, std::move(event_listener_remote));
|
|
|
|
GetNotificationService(browser_context_)
|
|
- ->DisplayNotification(notification_id, origin_.GetURL(),
|
|
- platform_notification_data, notification_resources);
|
|
+ ->DisplayNotification(render_process_host_, notification_id,
|
|
+ origin_.GetURL(), platform_notification_data,
|
|
+ notification_resources);
|
|
}
|
|
|
|
void BlinkNotificationServiceImpl::CloseNonPersistentNotification(
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl.h b/content/browser/notifications/blink_notification_service_impl.h
|
|
index 5253f6be778cc78571b3df0a33d364a9b1e6ef52..dc5307e6500b0bfb5da83e8d8ff8886b91133522 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl.h
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.h
|
|
@@ -40,6 +40,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::PendingReceiver<blink::mojom::NotificationService> receiver);
|
|
~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 f64eb733ede38501c34b2af89f42255189abd982..3c2dfad7ac9ba64b0b49ebef41a303edd1470cb1 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
+++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
@@ -138,7 +138,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)),
|
|
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 564d4fdb4d414bdb49d74dc8066dd3de86339dda..32d0ab7f8049dc13e83deac925ef9d10fc1554c1 100644
|
|
--- a/content/browser/notifications/platform_notification_context_impl.cc
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.cc
|
|
@@ -207,12 +207,13 @@ void PlatformNotificationContextImpl::Shutdown() {
|
|
}
|
|
|
|
void PlatformNotificationContextImpl::CreateService(
|
|
+ RenderProcessHost* render_process_host,
|
|
const url::Origin& origin,
|
|
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,
|
|
- std::move(receiver)));
|
|
+ this, browser_context_, service_worker_context_, render_process_host,
|
|
+ origin, 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 83d7c93482bf68ca98ee58de537711dad5844699..edd488efa643e80659cceab476cf53e12f10a1fb 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 "mojo/public/cpp/bindings/pending_receiver.h"
|
|
#include "third_party/blink/public/mojom/notifications/notification_service.mojom.h"
|
|
|
|
@@ -67,6 +68,7 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
|
|
|
|
// Creates a BlinkNotificationServiceImpl that is owned by this context.
|
|
void CreateService(
|
|
+ RenderProcessHost* render_process_host,
|
|
const url::Origin& origin,
|
|
mojo::PendingReceiver<blink::mojom::NotificationService> receiver);
|
|
|
|
diff --git a/content/browser/renderer_interface_binders.cc b/content/browser/renderer_interface_binders.cc
|
|
index cfdfae7e861ca6d5025f9478363e063afae326ef..b5dacb158e01091228aa97bb85db1efb24ceb6f7 100644
|
|
--- a/content/browser/renderer_interface_binders.cc
|
|
+++ b/content/browser/renderer_interface_binders.cc
|
|
@@ -196,7 +196,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 ca61088079c4150fcf389504ddcf26bcf6bf69cd..d9c034c39890eef1fe3d95c6d7c0ae68eb711a89 100644
|
|
--- a/content/public/browser/platform_notification_service.h
|
|
+++ b/content/public/browser/platform_notification_service.h
|
|
@@ -27,6 +27,8 @@ struct PlatformNotificationData;
|
|
|
|
namespace content {
|
|
|
|
+class RenderProcessHost;
|
|
+
|
|
// 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 {
|
|
// 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,
|
|
const std::string& notification_id,
|
|
const GURL& origin,
|
|
const blink::PlatformNotificationData& notification_data,
|
|
diff --git a/content/test/mock_platform_notification_service.cc b/content/test/mock_platform_notification_service.cc
|
|
index faa8e541d9cb530f9212420a4dfd0318069320db..0a244000e60daf8e6bd8e783b41124528a117026 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(
|
|
+ RenderProcessHost* render_process_host,
|
|
const std::string& notification_id,
|
|
const GURL& origin,
|
|
const blink::PlatformNotificationData& notification_data,
|
|
diff --git a/content/test/mock_platform_notification_service.h b/content/test/mock_platform_notification_service.h
|
|
index 6d108f9884f7e8f608b70ec33d286a06346e7456..4650a01c2d090c5957eb7a7e21f124489513142a 100644
|
|
--- a/content/test/mock_platform_notification_service.h
|
|
+++ b/content/test/mock_platform_notification_service.h
|
|
@@ -47,6 +47,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
|
|
|
// PlatformNotificationService implementation.
|
|
void DisplayNotification(
|
|
+ RenderProcessHost* render_process_host,
|
|
const std::string& notification_id,
|
|
const GURL& origin,
|
|
const blink::PlatformNotificationData& notification_data,
|