summaryrefslogtreecommitdiffstats
path: root/src/core/content_browser_client_qt.cpp
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2021-02-19 13:57:34 +0100
committerSzabolcs David <davidsz@inf.u-szeged.hu>2021-04-08 12:45:23 +0200
commitd1398e734c927435f236c2eed36613bedf71acf6 (patch)
treea13da06003b6b142bd5f09e2be110f93f7cb1f3e /src/core/content_browser_client_qt.cpp
parentfb60a0638a47564c1a1e7c2933b699d0205c810e (diff)
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 <embed> or <object> 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 <allan.jensen@qt.io>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r--src/core/content_browser_client_qt.cpp13
1 files changed, 13 insertions, 0 deletions
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<content::NavigationThrottle> maybe_throttle,
+ std::vector<std::unique_ptr<content::NavigationThrottle>>* 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<std::unique_ptr<content::NavigationThrottle>> ContentBrowserClientQt
navigation_handle,
base::BindRepeating(&navigationThrottleCallback),
navigation_interception::SynchronyMode::kSync));
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ MaybeAddThrottle(extensions::PDFIFrameNavigationThrottleQt::MaybeCreateThrottleFor(navigation_handle), &throttles);
+#endif
+
return throttles;
}