Index: chrome/browser/chrome_content_browser_client.cc |
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
index 135a0ccca171dfc7600b12ebada6104a8afccd0a..1f4fc7e53d5812e68005502dfe91ceef32d3c5e0 100644 |
--- a/chrome/browser/chrome_content_browser_client.cc |
+++ b/chrome/browser/chrome_content_browser_client.cc |
@@ -331,6 +331,7 @@ |
#include "chrome/browser/media/cast_remoting_connector.h" |
#include "chrome/browser/media/router/media_router_feature.h" |
#include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
+#include "chrome/browser/media/router/receiver_presentation_service_delegate_impl.h" |
#endif |
#if defined(ENABLE_WAYLAND_SERVER) |
@@ -3082,6 +3083,15 @@ ChromeContentBrowserClient::GetPresentationServiceDelegate( |
content::WebContents* web_contents) { |
#if defined(ENABLE_MEDIA_ROUTER) |
if (media_router::MediaRouterEnabled(web_contents->GetBrowserContext())) { |
+ // ReceiverPresentationServiceDelegateImpl exists only for WebContents |
+ // created for offscreen presentations. The WebContents must belong to |
+ // an incognito profile. WebContents cannot be a presentation receiver and |
+ // a presentation controller. |
+ if (auto* impl = media_router::ReceiverPresentationServiceDelegateImpl:: |
+ FromWebContents(web_contents)) { |
+ DCHECK(web_contents->GetBrowserContext()->IsOffTheRecord()); |
+ return impl; |
+ } |
return media_router::PresentationServiceDelegateImpl:: |
GetOrCreateForWebContents(web_contents); |
} |