From 883aa8c44c78cbac3de53c74e67655505b69111c Mon Sep 17 00:00:00 2001 From: Tony Herre Date: Thu, 2 Dec 2021 18:58:16 +0000 Subject: [PATCH] Handle null urls in PeerConnectionTrackerHost As shown by crbug.com/1274640, the provided URL for the document hosting a PeerConnection can be null. Situations like a page with an opaque origin could potentially lead to this. As the result is only used for the WebRtcInternals debugging page, just handling it gracefully as an empty string will be fine. Bug: 1274640 Change-Id: I584c9f7aec9884d823504a6f5639387585538751 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3310607 Commit-Queue: Tony Herre Reviewed-by: Alex Gough Reviewed-by: Thomas Guilbert Cr-Commit-Position: refs/heads/main@{#947594} --- .../renderer_host/media/peer_connection_tracker_host.cc | 5 ++++- .../mojom/peerconnection/peer_connection_tracker.mojom | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/content/browser/renderer_host/media/peer_connection_tracker_host.cc b/content/browser/renderer_host/media/peer_connection_tracker_host.cc index e5bd5d6aac8b7..2558030693365 100644 --- a/content/browser/renderer_host/media/peer_connection_tracker_host.cc +++ b/content/browser/renderer_host/media/peer_connection_tracker_host.cc @@ -100,8 +100,11 @@ void PeerConnectionTrackerHost::AddPeerConnection( blink::mojom::PeerConnectionInfoPtr info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); + const std::string& url = + (info->url == absl::nullopt) ? std::string() : *info->url; + for (auto& observer : GetObserverList()) { - observer.OnPeerConnectionAdded(frame_id_, info->lid, peer_pid_, info->url, + observer.OnPeerConnectionAdded(frame_id_, info->lid, peer_pid_, url, info->rtc_configuration, info->constraints); } } diff --git a/third_party/blink/public/mojom/peerconnection/peer_connection_tracker.mojom b/third_party/blink/public/mojom/peerconnection/peer_connection_tracker.mojom index b08eeb21141f9..ed0bf4ff2fcb4 100644 --- a/third_party/blink/public/mojom/peerconnection/peer_connection_tracker.mojom +++ b/third_party/blink/public/mojom/peerconnection/peer_connection_tracker.mojom @@ -30,7 +30,9 @@ struct PeerConnectionInfo { // The URL of the blink::WebLocalFrame within which this peer connection // lives. Used for debugging purposes (displayed by WebRTC-Internals). - string url; + // May be null for eg pages with opaque URLs. + // TODO(1274640): Use a mojo URL instead of a string. + string? url; }; // This interface collects data about each peer connection and sends it to the