From d1398e734c927435f236c2eed36613bedf71acf6 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Fri, 19 Feb 2021 13:57:34 +0100 Subject: Fix embedded PDFs when plugins are disabled Cover all cases from https://pdfobject.com/static - Plugin placeholder is generally broken: displays garbage and crashes on interaction. Fix it and show when PDFs are included by or tags. - Do not start an automatical download when the disabled PDF plugin was requested by an iframe. Show a clickable placeholder and let the end-users start it manually. - Remove unused class PluginPlaceholderQt Task-number: QTBUG-76314 Change-Id: I01a0c93ab23f54e4272f5aeb30578de0dcf18932 Reviewed-by: Allan Sandfeld Jensen --- src/core/content_browser_client_qt.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/core/content_browser_client_qt.cpp') diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index c2c78ff8b..da1ea8dde 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -167,6 +167,7 @@ #include "extensions/common/manifest_handlers/mime_types_handler.h" #include "extensions/extension_web_contents_observer_qt.h" #include "extensions/extensions_browser_client_qt.h" +#include "extensions/pdf_iframe_navigation_throttle_qt.h" #include "net/plugin_response_interceptor_url_loader_throttle.h" #endif @@ -222,6 +223,13 @@ bool IsHandledProtocol(base::StringPiece scheme) namespace QtWebEngineCore { +void MaybeAddThrottle( + std::unique_ptr maybe_throttle, + std::vector>* throttles) { + if (maybe_throttle) + throttles->push_back(std::move(maybe_throttle)); +} + class QtShareGLContext : public gl::GLContext { public: QtShareGLContext(QOpenGLContext *qtContext) @@ -1012,6 +1020,11 @@ std::vector> ContentBrowserClientQt navigation_handle, base::BindRepeating(&navigationThrottleCallback), navigation_interception::SynchronyMode::kSync)); + +#if BUILDFLAG(ENABLE_EXTENSIONS) + MaybeAddThrottle(extensions::PDFIFrameNavigationThrottleQt::MaybeCreateThrottleFor(navigation_handle), &throttles); +#endif + return throttles; } -- cgit v1.2.3