diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 760cb8b1d2..5426960fb4 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -61,6 +61,7 @@ #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h" #include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_private_key.h" +#include "pdf/pdf_features.h" #include "printing/buildflags/buildflags.h" #include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h" #include "services/device/public/cpp/geolocation/location_provider.h" @@ -1587,6 +1588,46 @@ bool ElectronBrowserClient::ShouldEnableStrictSiteIsolation() { return true; } +bool ElectronBrowserClient::ShouldEnableSubframeZoom() { +#if BUILDFLAG(ENABLE_PDF_VIEWER) + return chrome_pdf::features::IsOopifPdfEnabled(); +#else + return false; +#endif +} + +#if BUILDFLAG(ENABLE_PDF_VIEWER) +std::optional +ElectronBrowserClient::MaybeOverrideLocalURLCrossOriginEmbedderPolicy( + content::NavigationHandle* navigation_handle) { + if (!chrome_pdf::features::IsOopifPdfEnabled() || + !navigation_handle->IsPdf()) { + return std::nullopt; + } + + content::RenderFrameHost* pdf_extension = navigation_handle->GetParentFrame(); + if (!pdf_extension) { + return std::nullopt; + } + + content::RenderFrameHost* pdf_embedder = pdf_extension->GetParent(); + CHECK(pdf_embedder); + return pdf_embedder->GetCrossOriginEmbedderPolicy(); +} +#endif // BUILDFLAG(ENABLE_PDF_VIEWER) + +bool ElectronBrowserClient::DoesSiteRequireDedicatedProcess( + content::BrowserContext* browser_context, + const GURL& effective_site_url) { +#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) + return GetEnabledExtensionFromEffectiveURL(browser_context, + effective_site_url) != nullptr; +#else + return content::ContentBrowserClient::DoesSiteRequireDedicatedProcess( + browser_context, effective_site_url); +#endif +} + void ElectronBrowserClient::BindHostReceiverForRenderer( content::RenderProcessHost* render_process_host, mojo::GenericPendingReceiver receiver) { diff --git a/shell/browser/electron_browser_client.h b/shell/browser/electron_browser_client.h index 46eb0e790a..cc8cbe76b1 100644 --- a/shell/browser/electron_browser_client.h +++ b/shell/browser/electron_browser_client.h @@ -30,6 +30,7 @@ class FilePath; namespace content { class ClientCertificateDelegate; +class NavigationHandle; class PlatformNotificationService; class NavigationThrottleRegistry; class QuotaPermissionContext; @@ -82,6 +83,14 @@ class ElectronBrowserClient : public content::ContentBrowserClient, // content::ContentBrowserClient: std::string GetApplicationLocale() override; bool ShouldEnableStrictSiteIsolation() override; + bool ShouldEnableSubframeZoom() override; +#if BUILDFLAG(ENABLE_PDF_VIEWER) + std::optional + MaybeOverrideLocalURLCrossOriginEmbedderPolicy( + content::NavigationHandle* navigation_handle) override; +#endif // BUILDFLAG(ENABLE_PDF_VIEWER) + bool DoesSiteRequireDedicatedProcess(content::BrowserContext* browser_context, + const GURL& effective_site_url) override; void BindHostReceiverForRenderer( content::RenderProcessHost* render_process_host, mojo::GenericPendingReceiver receiver) override; diff --git a/shell/browser/extensions/api/streams_private/streams_private_api.cc b/shell/browser/extensions/api/streams_private/streams_private_api.cc index d3153b05c6..62a9848c04 100644 --- a/shell/browser/extensions/api/streams_private/streams_private_api.cc +++ b/shell/browser/extensions/api/streams_private/streams_private_api.cc @@ -70,7 +70,7 @@ void StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent( std::move(transferrable_loader), original_url); #if BUILDFLAG(ENABLE_PDF_VIEWER) - if (base::FeatureList::IsEnabled(chrome_pdf::features::kPdfOopif) && + if (chrome_pdf::features::IsOopifPdfEnabled() && extension_id == extension_misc::kPdfExtensionId) { pdf::PdfViewerStreamManager::Create(web_contents); pdf::PdfViewerStreamManager::FromWebContents(web_contents)