blob: 1f6c606bcefa23aeac0d61fe0cc413bbaf6afd84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "extensions/plugin_service_filter_qt.h"
#include "content/public/browser/render_process_host.h"
#include "web_contents_delegate_qt.h"
#include "web_engine_settings.h"
using namespace QtWebEngineCore;
namespace extensions {
// static
PluginServiceFilterQt *PluginServiceFilterQt::GetInstance()
{
return base::Singleton<PluginServiceFilterQt>::get();
}
bool PluginServiceFilterQt::IsPluginAvailable(int render_process_id, int render_frame_id,
content::BrowserContext *browser_context,
const content::WebPluginInfo &plugin)
{
Q_UNUSED(plugin);
Q_UNUSED(browser_context);
content::RenderFrameHost *frame_host = content::RenderFrameHost::FromID(render_process_id, render_frame_id);
content::WebContents *web_contents = content::WebContents::FromRenderFrameHost(frame_host);
if (!web_contents) {
// Availability checked somewhere before/during WebContents initialization. Let it load and enable
// all the plugins at this phase. This information will be queried again when receiving the response
// for the requested content. Postponing our decision and enabling/blocking there makes WebEngineSettings
// modifiable in runtime without reconstructing WebContents.
return true;
}
if (web_contents->IsInnerWebContentsForGuest())
web_contents = web_contents->GetOuterWebContents();
if (auto *delegate = static_cast<WebContentsDelegateQt *>(web_contents->GetDelegate())) {
const WebEngineSettings *settings = delegate->webEngineSettings();
if (!settings->testAttribute(QWebEngineSettings::PdfViewerEnabled)
|| !settings->testAttribute(QWebEngineSettings::PluginsEnabled))
return false;
}
return true;
}
bool PluginServiceFilterQt::CanLoadPlugin(int render_process_id,
const base::FilePath &path)
{
return true;
}
PluginServiceFilterQt::PluginServiceFilterQt()
{
}
PluginServiceFilterQt::~PluginServiceFilterQt()
{
}
} // namespace extensions
|