简体   繁体   中英

How to remove or disable plugin in CefSharp

I need to disable Flash Player. I tried to do this through the RequestContextHandler, but it did not work:

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.

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

How I can disable "pepflashplayer" plugin?

А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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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