thefunkyjoint wrote: Thu Jan 23, 2020 11:34 pm
Long-time CEF4Delphi user / fan here... I really love this project, thank you very much Salvador !
Thank you so much for all your donations and support in Patreon!!!
thefunkyjoint wrote: Thu Jan 23, 2020 11:34 pm
There are 2 features that would really be awesome if could happen, at least for my use case :
- Set specific user agent for each TChromium instance ; at the moment the user agent is global, ie, same for all TChromium instances.
You can modify the HTTP headers in the normal resource requests to set a custom user agent whenever you want but JavaScript will keep using the user agent you set when you initialize CEF.
In order to fix that we would need to modify Chromium's code, CEF's code and CEF4Delphi's code.
I've never modified Chromium's code and even if I could do that you would need to build custom CEF binaries with all those modifications each time you upgrade your application.
thefunkyjoint wrote: Thu Jan 23, 2020 11:34 pm
- Delete or change cookies/cache dir without having to close the app before. If i want to change to cookies dir, i can't do it unless i close my app before.
You can do that right now and the
MDIBrowser demo has all the code you need :
https://github.com/salvadordf/CEF4Delph ... m.pas#L203
Whenever you need to use a different cache directory you just need to create a new TChromium with a TCEFWindowParent and set a custom ICefRequestContext parameter when you call TChromium.CreateBrowser.
The custom ICefRequestContext would use a different cache directory and the new browser would be completely independent from the previous browsers.
For example, if you use the "c:\old_cache" directory when you initialize CEF you can have several browsers using that cache directory if you don't set a ICefRequestContext parameter when you call TChromium.CreateBrowser.
Later you can create a new independent browser using "c:\new_cache". You would have to create an instance of ICefRequestContext with this code :
Code: Select all
TempNewContext1 := TCefRequestContextRef.New('c:\new_cache', '', False, False, False);
Then use that context like this :
Code: Select all
TempNewChromium1.CreateBrowser(TempNewCEFWindowParent1, '', TempNewContext1);
At that point you would have some browsers using "c:\old_cache" and a new browser using "c:\new_cache".
In case you need a new browser using "c:\old_cache" again then you can create it with a NIL ICefRequestContext parameter when you call TChromium.CreateBrowser.
However, if you need a second browser using "c:\new_cache" then you would need to call TChromium.ShareRequestContext to get the new ICefRequestContext instance in the "aContext" parameter.
Code: Select all
if TempNewChromium1.ShareRequestContext(TempNewContext2, nil) then
TempNewChromium2.CreateBrowser(TempNewCEFWindowParent2, '', TempNewContext2);
Notice that TempNewChromium1, TempNewCEFWindowParent1 and TempNewContext1 where used to create the first browser using "c:\new_cache" and now you are creating a new TempNewChromium2, TempNewCEFWindowParent2 and TempNewContext2.
In this situation TempNewChromium1 and TempNewChromium2 would use "c:\new_cache" while the rest of the browsers would use "c:\old_cache".