Allow files access from CEF browser and Disable Web Security

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Allow files access from CEF browser and Disable Web Security

Postby HarshMakadia » Tue Jul 18, 2017 11:26 pm

I want to make file system accessible from a web browser using CEF Library. In order to do this, I tried following options :

file_access_from_file_urls = STATE_ENABLED;

universal_access_from_file_urls = STATE_ENABLED;

web_security = STATE_DISABLED;

Here are some changes which were made


Code: Select all
TSharedPtr<IWebBrowserWindow> FWebBrowserSingleton::CreateBrowserWindow(const FCreateBrowserWindowSettings& WindowSettings)
{
#if WITH_CEF3
    static bool AllowCEF = !FParse::Param(FCommandLine::Get(), TEXT("nocef"));
    if (AllowCEF)
    {
        // Information used when creating the native window.
        CefWindowInfo WindowInfo;

        // Specify CEF browser settings here.
        CefBrowserSettings BrowserSettings;

        // Disable plugins
        BrowserSettings.plugins = STATE_DISABLED;
        BrowserSettings.file_access_from_file_urls = STATE_ENABLED;
        BrowserSettings.universal_access_from_file_urls = STATE_ENABLED;
        BrowserSettings.web_security = STATE_DISABLED;
    }
}


Also made changes in the OnBeforeCommandLineProcessing method of CEF Library where the user can change the settings of the browser.

Here is the sample code

Code: Select all
void FCEFBrowserApp::OnBeforeCommandLineProcessing(const CefString& ProcessType, CefRefPtr< CefCommandLine > CommandLine)
{
  CommandLine->AppendSwitch("allow-file-access-from-files");
  CommandLine->AppendSwitch("disable-gpu");
  CommandLine->AppendSwitch("disable-web-security");
  CommandLine->AppendSwitch("disable-gpu-compositing");
}



I'm trying to disable web security inside the Unreal Engine Web Browser. Is there is any extra setting which we need to do in order to disable the web security and allow the files to be accessed by the following path

file:///C:/image.jpg. (Please note that opening the sample url in browser loads the image)

I'm basically using web browser inside the unreal engine which uses CEF library C++. Can someone show me sample code to disable this web security ?
HarshMakadia
Newbie
 
Posts: 5
Joined: Tue Jul 18, 2017 11:18 pm

Re: Allow files access from CEF browser and Disable Web Secu

Postby salmon17 » Tue Aug 01, 2017 3:54 am

at one point we used
Code: Select all
settings.no_sandbox = true;

maybe it will help your case
generally now we only access the filesystem from the browser process
salmon17
Newbie
 
Posts: 9
Joined: Tue Jul 05, 2016 9:55 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 34 guests