167 lines
9 KiB
Diff
167 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 cbcd2b5369fc513bed8190a83431826cba4e7637..1b4066649d926f18c0f1286243bfde848d80f1e3 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
|
@@ -40,9 +40,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),
|
|
@@ -99,7 +101,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 193f5d241c314e9921048d592602e5caa362f198..3cfcc6b86ae10102a1cc9e9abb27c529a57511cb 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl.h
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.h
|
|
@@ -33,6 +33,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;
|
|
@@ -94,6 +95,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 618c7bd88cde563eaaf93914039b5fb6d81db514..be08e89b5c6d57abf6b61ed9ee4b1c536a6ca134 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
+++ b/content/browser/notifications/blink_notification_service_impl_unittest.cc
|
|
@@ -113,7 +113,7 @@ class BlinkNotificationServiceImplTest : public ::testing::Test {
|
|
blink::mojom::NotificationServicePtr notification_service_ptr;
|
|
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(¬ification_service_ptr));
|
|
|
|
diff --git a/content/browser/notifications/platform_notification_context_impl.cc b/content/browser/notifications/platform_notification_context_impl.cc
|
|
index 627e8dbd251d952f1567847775d8147e78e697b9..48c290470e4854a5e17c70bbfe178a34ffe7d73f 100644
|
|
--- a/content/browser/notifications/platform_notification_context_impl.cc
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.cc
|
|
@@ -122,12 +122,13 @@ void PlatformNotificationContextImpl::ShutdownOnIO() {
|
|
}
|
|
|
|
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 7ea92b626202fcc3c1a830e74549ef87c206c4cd..faa3a1d8069f2d87c22cb40f98bc1d96db557464 100644
|
|
--- a/content/browser/notifications/platform_notification_context_impl.h
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.h
|
|
@@ -21,6 +21,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
|
|
|
|
// Creates a BlinkNotificationServiceImpl that is owned by this context. Must
|
|
// be called on the UI thread.
|
|
- 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 896f1b27ded7a73c62ec16d11418dacb0631d976..20a1f86a36fdefe3eeeb56a56eff874e2d6422fd 100644
|
|
--- a/content/browser/renderer_interface_binders.cc
|
|
+++ b/content/browser/renderer_interface_binders.cc
|
|
@@ -168,7 +168,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::Create));
|
|
diff --git a/content/public/browser/platform_notification_service.h b/content/public/browser/platform_notification_service.h
|
|
index 228fc30240c5251c0a4182f085b41c189e28365d..fd3e20c5335a09ba5bae31a76cc4a2cc3ad0a2f0 100644
|
|
--- a/content/public/browser/platform_notification_service.h
|
|
+++ b/content/public/browser/platform_notification_service.h
|
|
@@ -21,6 +21,7 @@ class GURL;
|
|
namespace content {
|
|
|
|
class BrowserContext;
|
|
+class RenderProcessHost;
|
|
struct NotificationResources;
|
|
struct PlatformNotificationData;
|
|
|
|
@@ -38,6 +39,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 28dc2651a3269a4e7483d7e84a25d85f98083fcf..646817070e7fd831eb6caff5a369357dce2cccec 100644
|
|
--- a/content/test/mock_platform_notification_service.cc
|
|
+++ b/content/test/mock_platform_notification_service.cc
|
|
@@ -20,6 +20,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 baf24f9effc9569f070757832681a82e62322d30..98a128e5d24933fbf98a5cfdda90b0611fce63d8 100644
|
|
--- a/content/test/mock_platform_notification_service.h
|
|
+++ b/content/test/mock_platform_notification_service.h
|
|
@@ -42,6 +42,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
|
|
|
// PlatformNotificationService implementation.
|
|
void DisplayNotification(
|
|
+ RenderProcessHost* render_process_host,
|
|
BrowserContext* browser_context,
|
|
const std::string& notification_id,
|
|
const GURL& origin,
|
|
--
|
|
2.17.0
|
|
|