Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

LoadString and CefRegisterExtension

Post Reply
Albus

LoadString and CefRegisterExtension

Post 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).
User avatar
salvadordf
Posts: 4079
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: LoadString and CefRegisterExtension

Post 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.
Albus

Re: LoadString and CefRegisterExtension

Post 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.
Post Reply