by codelimit » Tue Dec 17, 2019 7:59 am
Okay. What i have done for now
I added resource manager instance, and use AddContentProvider (url, html_src, "text/html", 0, std::string());
Url - custom scheme name + full path of the directory that contains html and related files (for ex. "myapp://somedir/somesubdir")
Html_src - is a std::string with html source (for ex. "<html>...</html>")
Also i have custom scheme handling.
So how it works now:
after about_button_press event I call
void load_html (std::string html_src, std::string dir)
{
resource_manager->AddContentProvider (url, html_src, "text/html", 0, std::string());
frame->loadUrl(dir);
}
For given url I create content provider that loads html_src as html. Then it creates html's internal resource request (ex. "logo.png"). So url becomes "myapp://somedir/somesubdir/logo.png". It handled by custom scheme's resource handler (for "myapp" scheme), that loads image source.
At least it works. As i understood AddContentProvider can be called on any thread.
Now the question is where is a correct place to remove provider? With above code it will create provider again and again while i visit and leave "about" page.
At this moment I use OnResourceLoadComplete(), and call removeAllProviders. But that means that on EVERY "OnResourceLoadComplete" i have removeAllProviders called. Even despite none was added.
Can someone comment this workaround?
Best regards.