如何允许网站访问CEFSharp WPF中的本地文件系统?

问题描述

我正在编写一个带有集成CEFSharp Webbrowser控件的wpf应用程序,但是我在网站上遇到了麻烦。该网站需要访问本地文件系统,但是我不确定如何或在何处将其捕获到后端并授予访问权限。我已经实现了IRequestHandler和IResourceRequestHandler,但是我不确定还要做什么。

这是网站上的错误

enter image description here

enter image description here

Chrome会以某种方式捕获并处理它:

enter image description here

我想以类似的方式处理它。任何帮助表示赞赏。

解决方法

如果我在Chrome浏览器上正确读取了documentation,似乎Chromium正在自动调用chrome.fileSystem.requestFileSystem(object options,function callback)

我想,如果您想手动处理此问题,则也需要提示用户进行此权限/操作,这意味着需要从CEFSharp的Chromium客户端内部执行相同的API调用。

,

谢谢@amaitland和@Jimenemex的答复。他们确实确实使我朝着正确的方向前进。最后,我需要在IRequestHandler的“ OnQuotaRequest”事件中捕获文件系统请求。以下代码解决了我的问题:

public bool OnQuotaRequest(IWebBrowser chromiumWebBrowser,IBrowser browser,string originUrl,long newSize,IRequestCallback callback)
    {
        string askingURL = Helper.GetWebsiteName(originUrl);
        var infoWindow = new InformationWindow("","Allow " + askingURL,"to store files on this device?");
        infoWindow.OkButton.Visibility = Visibility.Hidden;
        infoWindow.YesButton.Visibility = Visibility.Visible;
        infoWindow.NoButton.Visibility = Visibility.Visible;
        infoWindow.Topmost = true;

        if (infoWindow.ShowDialog() == true)
        {
            callback.Continue(true);
            return true;
        }

        return false;
    }