summaryrefslogtreecommitdiffstats
path: root/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp')
-rw-r--r--src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp b/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp
index 61f64dc0b..5bfd3a316 100644
--- a/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp
+++ b/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp
@@ -61,6 +61,9 @@
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
+#include "web_contents_delegate_qt.h"
+#include "web_engine_settings.h"
+
namespace extensions {
constexpr char kPDFMimeType[] = "application/pdf";
@@ -86,7 +89,7 @@ public:
private:
friend class content::WebContentsUserData<PdfWebContentsLifetimeHelper>;
- content::WebContents* const web_contents_;
+ content::WebContents *const web_contents_;
base::WeakPtrFactory<PdfWebContentsLifetimeHelper> weak_factory_{this};
WEB_CONTENTS_USER_DATA_KEY_DECL();
@@ -97,15 +100,25 @@ WEB_CONTENTS_USER_DATA_KEY_IMPL(PdfWebContentsLifetimeHelper);
bool IsPDFPluginEnabled(content::NavigationHandle *navigation_handle, bool *is_stale)
{
content::WebContents *web_contents = navigation_handle->GetWebContents();
+ Q_ASSERT(web_contents);
+
+ if (web_contents->IsInnerWebContentsForGuest())
+ web_contents = web_contents->GetOuterWebContents();
+
+ if (auto *delegate = static_cast<QtWebEngineCore::WebContentsDelegateQt *>(web_contents->GetDelegate())) {
+ const QtWebEngineCore::WebEngineSettings *settings = delegate->webEngineSettings();
+ if (!settings->testAttribute(QWebEngineSettings::PdfViewerEnabled)
+ || !settings->testAttribute(QWebEngineSettings::PluginsEnabled))
+ return false;
+ }
+
int process_id = web_contents->GetMainFrame()->GetProcess()->GetID();
- int routing_id = web_contents->GetMainFrame()->GetRoutingID();
content::WebPluginInfo plugin_info;
- // Will check WebEngineSettings by PluginServiceFilterQt
return content::PluginService::GetInstance()->GetPluginInfo(
- process_id, routing_id, navigation_handle->GetURL(),
- web_contents->GetMainFrame()->GetLastCommittedOrigin(), kPDFMimeType,
- false /* allow_wildcard */, is_stale, &plugin_info,
- nullptr /* actual_mime_type */);
+ process_id, navigation_handle->GetURL(),
+ kPDFMimeType,
+ false /* allow_wildcard */, is_stale, &plugin_info,
+ nullptr /* actual_mime_type */);
}
std::string GetPDFPlaceholderHTML(const GURL &pdf_url)