Page 1 of 1

LoadString and CefRegisterExtension

Posted: Tue Nov 27, 2018 4:09 pm
by Albus
I'm trying to load a HTML page from a string. While this works properly, I have an issue with CefRegisterExtension. Because some times this works, but most times not (more than 90%). I get no error but my extension is just not registered. If i change the LoadString to a LoadUrl (with for example google.com), the registrations works properly.
If someone is wondering why I load a page by string: I have a local HTML file next to my program that should be loaded. However, Chrome now forbids displaying local HTML files (I didn't manage to disable this rule either). So I read the file into a string and injected it into the browser with LoadString. ( Because it is only a small internal app, it would not be a problem to disable the security policy).

Re: LoadString and CefRegisterExtension

Posted: Wed Nov 28, 2018 10:50 am
by salvadordf
LoadString has some issues and it only works when a render process already exists. It's recommended to use LoadURL with a "data" URL instead.

Re: LoadString and CefRegisterExtension

Posted: Wed Nov 28, 2018 11:06 am
by Albus
Because creating a base64 encoded string in Delphi (XE5) is a bit complicated, I tried waiting for the about:blank page to load until it's finished. After about:blank is loaded (LoadEnd Event), I insert my HTML-String. With this solution the CefRegisterExtension works evey single time.