005101424a
Co-authored-by: Charles Kerr <charles@charleskerr.com>
167 lines
9.1 KiB
Diff
167 lines
9.1 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: notification_provenance.patch
|
|
|
|
Pass RenderProcessHost through to PlatformNotificationService
|
|
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 cd1f69dfbc76c78411de953c6b2ff7146a323cca..4526b0e632205809858cdc8a88ad973024b63c5d 100644
|
|
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
|
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
|
@@ -89,10 +89,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),
|
|
@@ -155,7 +157,8 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
|
notification_id, std::move(event_listener_remote));
|
|
|
|
GetNotificationService(browser_context_)
|
|
- ->DisplayNotification(notification_id, origin_.GetURL(), document_url_,
|
|
+ ->DisplayNotification(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 19c2beb1f1949f0dc4466a8728f151c035544b24..f7aa5f94d6dea0e6b2c1107b8ef01600bf13903b 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);
|
|
@@ -96,6 +97,7 @@ class CONTENT_EXPORT BlinkNotificationServiceImpl
|
|
// The notification context that owns this service instance.
|
|
PlatformNotificationContextImpl* notification_context_;
|
|
|
|
+ RenderFrameHost* render_frame_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 e27c23e0aeaf08c903c2fc1f7cb0b24d137b9a7a..4768449379941021c9c2fd388040b75395129231 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)),
|
|
/*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 8db550c4d38132b062eac6eca7862b113de6c780..edb5fbd27e4503984a21a310e0ea26395d10b6ab 100644
|
|
--- a/content/browser/notifications/platform_notification_context_impl.cc
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.cc
|
|
@@ -284,13 +284,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 71dad766e05ac4726e1e18159f2af5ea01079a91..ef8e55a4420288fe64c99e68d0a649a9f31a49f8 100644
|
|
--- a/content/browser/notifications/platform_notification_context_impl.h
|
|
+++ b/content/browser/notifications/platform_notification_context_impl.h
|
|
@@ -44,6 +44,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.
|
|
@@ -68,6 +69,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 8ed81f9cc14157827c33aab5952e2b28c0755027..458f004ce92f719795dbc91f65a6bb6f05244291 100644
|
|
--- a/content/browser/renderer_host/render_process_host_impl.cc
|
|
+++ b/content/browser/renderer_host/render_process_host_impl.cc
|
|
@@ -2152,7 +2152,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 d36d0c40d61f4e131c4a996d283a6ce2d3657ac3..ee08f52a9f8a02c380e8aac52c59849540e8bf4a 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 GURL& document_url,
|
|
diff --git a/content/test/mock_platform_notification_service.h b/content/test/mock_platform_notification_service.h
|
|
index fb20e5bd456a88a7ebd95aa7e1d5a2a527dc8775..6162a2581b4d84e5feb7c4b9eaa440c03fe9b374 100644
|
|
--- a/content/test/mock_platform_notification_service.h
|
|
+++ b/content/test/mock_platform_notification_service.h
|
|
@@ -46,6 +46,7 @@ class MockPlatformNotificationService : public PlatformNotificationService {
|
|
|
|
// PlatformNotificationService implementation.
|
|
void DisplayNotification(
|
|
+ RenderProcessHost* render_process_host,
|
|
const std::string& notification_id,
|
|
const GURL& origin,
|
|
const GURL& document_url,
|