简体   繁体   English

如何在CefSharp中删除或禁用插件

[英]How to remove or disable plugin in CefSharp

I need to disable Flash Player. 我需要禁用Flash Player。 I tried to do this through the RequestContextHandler, but it did not work: 我试图通过RequestContextHandler做到这一点,但没有成功:

public class RequestContextHandler : IRequestContextHandler
{
    public ICookieManager GetCookieManager()
    {
        return null;
    }

    public bool OnBeforePluginLoad(string mimeType, string url, bool isMainFrame, string topOriginUrl, WebPluginInfo pluginInfo, ref PluginPolicy pluginPolicy)
    {
        bool blockPluginLoad = pluginInfo.Name.ToLower().Contains("flash");
        return blockPluginLoad;
    }
}

Whoer.net shows that Flash is not disabled. Whoer.net显示未禁用Flash。

在此处输入图片说明 在此处输入图片说明

How I can disable "pepflashplayer" plugin? 如何禁用“ pepflashplayer”插件?

Аlso need to configure the plugin policy: 还需要配置插件策略:

public class RequestContextHandler : IRequestContextHandler
{
    public ICookieManager GetCookieManager()
    {
        return null;
    }

    public bool OnBeforePluginLoad(string mimeType, string url, bool isMainFrame, string topOriginUrl, WebPluginInfo pluginInfo, ref PluginPolicy pluginPolicy)
    {

        bool blockPluginLoad = pluginInfo.Name.ToLower().Contains("flash");
        if (blockPluginLoad)
        {
            pluginPolicy = PluginPolicy.Disable;
        }
        return blockPluginLoad;
    }
} 

Thanks to @stuartd 感谢@stuartd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM