How to load static resources offline?

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.

How to load static resources offline?

Postby WzCode1 » Fri Mar 26, 2021 2:22 am

In order to make the app load faster, I try to load static resources (css/js), etc., through local loading instead of loading server data through Url, but how do I intercept the loading server data?
WzCode1
Newbie
 
Posts: 3
Joined: Fri Mar 26, 2021 2:08 am

Re: How to load static resources offline?

Postby magreenblatt » Fri Mar 26, 2021 9:26 am

magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: How to load static resources offline?

Postby WzCode1 » Sun Mar 28, 2021 9:58 pm


Thank you, I will look into it first!
WzCode1
Newbie
 
Posts: 3
Joined: Fri Mar 26, 2021 2:08 am

Re: How to load static resources offline?

Postby WzCode1 » Fri Apr 02, 2021 1:48 am

In the process of implementing offline loading of static resources, I inherited RequestDumpResourceProvider: public CefResourceManager::Provider, this class, but the OnRequest function is not called. What is the reason?

class RequestDumpResourceProvider : public CefResourceManager::Provider
{
public:
explicit RequestDumpResourceProvider(const std::string& url) : url_(url) {
DCHECK(!url.empty());
}

bool OnRequest(scoped_refptr<CefResourceManager::Request> request) OVERRIDE {
CEF_REQUIRE_IO_THREAD();

const std::string& url = request->url();
if (url != url_) {
// Not handled by this provider.
return false;
}

const std::string& dump = DumpRequestContents(request->request());
std::string str =
"<html><body bgcolor=\"white\"><pre>" + dump + "</pre></body></html>";
CefRefPtr<CefStreamReader> stream = CefStreamReader::CreateForData(
static_cast<void*>(const_cast<char*>(str.c_str())), str.size());
DCHECK(stream.get());
request->Continue(new CefStreamResourceHandler("text/html", stream));
return true;
}

private:
std::string url_;
//CefResourceManager::UrlFilter fileterUrl;

DISALLOW_COPY_AND_ASSIGN(RequestDumpResourceProvider);
};

Which does not call the OnRequest function
WzCode1
Newbie
 
Posts: 3
Joined: Fri Mar 26, 2021 2:08 am

Re: How to load static resources offline?

Postby prsolucoes » Sun Jun 20, 2021 1:08 am

Hi,

Im with the sample problem. It dont enter on method OnRequest.

Do you solve it?

Thanks.
prsolucoes
Techie
 
Posts: 10
Joined: Sat Jun 19, 2021 3:20 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 52 guests