2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-10-05 21:24:38 +00:00
|
|
|
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
|
2019-03-06 17:50:12 +00:00
|
|
|
index 7c6b38b94d714ec2a878ce3cf0448028fbf7c19b..f26dd52579544ad030b603a16ef0ff03ecebb42a 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
2019-02-14 16:34:15 +00:00
|
|
|
@@ -50,9 +50,11 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
|
2018-10-05 21:24:38 +00:00
|
|
|
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),
|
2019-02-14 16:34:15 +00:00
|
|
|
@@ -112,7 +114,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
2018-10-05 21:24:38 +00:00
|
|
|
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
|
2019-03-06 17:50:12 +00:00
|
|
|
index 088637b68b1fb40fb8a32bb72781b425077e668a..ec2cce6b644e6cc8fd899a761fb55d9a01b65f98 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl.h
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.h
|
2019-01-12 01:00:43 +00:00
|
|
|
@@ -36,6 +36,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
2018-10-05 21:24:38 +00:00
|
|
|
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;
|
2019-03-06 17:50:12 +00:00
|
|
|
@@ -99,6 +100,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
2018-10-05 21:24:38 +00:00
|
|
|
// The notification context that owns this service instance.
|
|
|
|
PlatformNotificationContextImpl* notification_context_;
|
|
|
|
|
|
|
|
+ RenderProcessHost* render_process_host_;
|
|
|
|
BrowserContext* browser_context_;
|
|
|
|
|
|
|
|
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
|
2018-10-11 08:38:48 +00:00
|
|
|
diff --git a/content/browser/notifications/blink_notification_service_impl_unittest.cc b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
2019-03-06 17:50:12 +00:00
|
|
|
index 759e317999ec4f37f185310724374c655c2f24fe..874f6d1fb6d2bddc0e6711080adfadc3f7156b0e 100644
|
2018-10-11 08:38:48 +00:00
|
|
|
--- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
|
|
+++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
2019-02-14 16:34:15 +00:00
|
|
|
@@ -127,7 +127,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
|
2019-01-12 01:00:43 +00:00
|
|
|
|
2018-10-11 08:38:48 +00:00
|
|
|
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)),
|
2019-01-12 01:00:43 +00:00
|
|
|
mojo::MakeRequest(¬ification_service_ptr_));
|
2018-10-11 08:38:48 +00:00
|
|
|
|
2018-10-05 21:24:38 +00:00
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
|
2019-02-14 16:34:15 +00:00
|
|
|
index d78bd8005178dea2dd3985527de4709e28b1ac3e..11d82930e851975997fcc69f623c4ec154f83dcc 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/platform_notification_context_impl.cc
|
|
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.cc
|
2019-02-14 16:34:15 +00:00
|
|
|
@@ -108,12 +108,13 @@ void PlatformNotificationContextImpl::Shutdown() {
|
2018-10-05 21:24:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2019-02-14 16:34:15 +00:00
|
|
|
index 09fd40b0a55a9799dc8018ea69a85cb25724fa63..143335b6ba90b0d0aef8aa95687db1dbcc2bdf79 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/notifications/platform_notification_context_impl.h
|
|
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.h
|
2018-10-24 23:25:48 +00:00
|
|
|
@@ -22,6 +22,7 @@
|
2018-10-05 21:24:38 +00:00
|
|
|
#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;
|
2019-02-14 16:34:15 +00:00
|
|
|
@@ -62,7 +63,8 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
|
|
|
|
void Shutdown();
|
2018-10-05 21:24:38 +00:00
|
|
|
|
2019-02-14 16:34:15 +00:00
|
|
|
// Creates a BlinkNotificationServiceImpl that is owned by this context.
|
2018-10-05 21:24:38 +00:00
|
|
|
- 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
|
2019-01-24 09:42:21 +00:00
|
|
|
index 8e4df0b15aebc30c517a8c99f20201d8148777e0..ad49782df16c92a6ed0f736a5980263de908c137 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/browser/renderer_interface_binders.cc
|
|
|
|
+++ b/content/browser/renderer_interface_binders.cc
|
2019-01-24 09:42:21 +00:00
|
|
|
@@ -189,7 +189,7 @@ void RendererInterfaceBinders::InitializeParameterizedBinderRegistry() {
|
2018-10-05 21:24:38 +00:00
|
|
|
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(
|
2018-10-24 23:25:48 +00:00
|
|
|
base::BindRepeating(&BackgroundFetchServiceImpl::CreateForWorker));
|
2018-10-05 21:24:38 +00:00
|
|
|
diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
|
2019-02-14 16:34:15 +00:00
|
|
|
index c7209a74a84ae4a284170ba882ee537cb732d467..4960a11bc922fd79c00bf418e1468f09f0457407 100644
|
2018-10-05 21:24:38 +00:00
|
|
|
--- a/content/public/browser/platform_notification_service.h
|
|
|
|
+++ b/content/public/browser/platform_notification_service.h
|
2019-01-12 01:00:43 +00:00
|
|
|
@@ -27,6 +27,7 @@ struct PlatformNotificationData;
|
2018-10-05 21:24:38 +00:00
|
|
|
namespace content {
|
|
|
|
|
|
|
|
class BrowserContext;
|
|
|
|
+class RenderProcessHost;
|
|
|
|
|
2019-01-12 01:00:43 +00:00
|
|
|
// The service using which notifications can be presented to the user. There
|
|
|
|
// should be a unique instance of the PlatformNotificationService depending
|
|
|
|
@@ -42,6 +43,7 @@ class CONTENT_EXPORT PlatformNotificationService {
|
2018-10-05 21:24:38 +00:00
|
|
|
// 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,
|
2018-10-11 08:38:48 +00:00
|
|
|
diff --git a/content/test/mock_platform_notification_service.cc b/content/test/mock_platform_notification_service.cc
|
2019-02-14 16:34:15 +00:00
|
|
|
index 7d16ee63cd349c107a0a0c35446cef557be1aed1..ac9860af1234d2c451525bbd924b79fb32f99015 100644
|
2018-10-11 08:38:48 +00:00
|
|
|
--- a/content/test/mock_platform_notification_service.cc
|
|
|
|
+++ b/content/test/mock_platform_notification_service.cc
|
2019-02-14 16:34:15 +00:00
|
|
|
@@ -26,6 +26,7 @@ MockPlatformNotificationService::MockPlatformNotificationService() = default;
|
2018-10-11 08:38:48 +00:00
|
|
|
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
|
2019-02-14 16:34:15 +00:00
|
|
|
index 89aad27b34da99fc90e2d0352994eb3baa64fae4..0c8b8dbdacc83006c53fd85894d95c8fa01166d8 100644
|
2018-10-11 08:38:48 +00:00
|
|
|
--- a/content/test/mock_platform_notification_service.h
|
|
|
|
+++ b/content/test/mock_platform_notification_service.h
|
2019-01-12 01:00:43 +00:00
|
|
|
@@ -45,6 +45,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
2018-10-11 08:38:48 +00:00
|
|
|
|
|
|
|
// PlatformNotificationService implementation.
|
|
|
|
void DisplayNotification(
|
|
|
|
+ RenderProcessHost* render_process_host,
|
|
|
|
BrowserContext* browser_context,
|
|
|
|
const std::string& notification_id,
|
|
|
|
const GURL& origin,
|