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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Migrating from DCEF3

thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Migrating from DCEF3

Post by thefunkyjoint »

Hello,

I'm in the process of migrating existing apps from DCEF3 to CEF4. Some changes in my code are needed and i'm doing this. Here are some questions i have at the moment, if anyone could help with these i'd appreciate very much :

1 - I could not open the examples because i'm using Delphi 2007, it won't open the .dproj file. Any hints ?

2 - It seems the way to get the website html source after loaded changed ; can you please post an example ?

Thanks in advance !
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Migrating from DCEF3

Post by thefunkyjoint »

Nevermind for question 2, i already find it searching on the forum.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Migrating from DCEF3

Post by salvadordf »

Hi,
thefunkyjoint wrote: Thu Aug 10, 2017 4:46 pm 1 - I could not open the examples because i'm using Delphi 2007, it won't open the .dproj file. Any hints ?
Try opening the Delphi 7 project in the SimpleBrowser demo. I only have a Delphi 10 license and I can't create all the project files.
thefunkyjoint wrote: Thu Aug 10, 2017 4:46 pm 2 - It seems the way to get the website html source after loaded changed ; can you please post an example ?
Call TChromium.RetrieveHTML and get the results in the TChromium.OnTextResultAvailable event.
The MiniBrowser demo has the code to copy the HTML into the clipboard.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Migrating from DCEF3

Post by thefunkyjoint »

Thank you, i could open the simple browser project in Delphi 2007.

Another question, please : how do i manage cookies ? Ie, i open my app, login in a website. When i close and open again, i'm not logged anymore.

Here is my current code, but it's not working ; do i have to do anything to load the cookies at app startup and keep my session alive ?

Thanks in advance !

begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.Cookies := 'c:\app\cookies';
GlobalCEFApp.MuteAudio := true;
if GlobalCEFApp.StartMainProcess then
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.Title := 'Myapp';
Application.CreateForm(TFrmprinc, Frmprinc);
frmsplash.free;
Application.Run;
end;
GlobalCEFApp.Free;
end.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Migrating from DCEF3

Post by salvadordf »

Hi,

You must set GlobalCEFApp.cache and GlobalCEFApp.cookies to remain logged in.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Migrating from DCEF3

Post by thefunkyjoint »

Thank you, it worked !

Is it normal when i run my app with multiple instances of TChromium inside only one app, i see multiple instances of my app EXE file on task manager ? This behaviour did not happen in DCEF3.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Migrating from DCEF3

Post by salvadordf »

Hi,

Yes, it's normal. The default configuration uses multiple processes.

For more information about that read these pages :
https://www.briskbard.com/index.php?lang=en&pageid=cef
http://www.chromium.org/developers/design-documents

If you use multiple TChromium components in one application you should take a look at the MDIBrowser or the ToolBoxBroser demos.
You need to destroy them properly or you may have problems.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Migrating from DCEF3

Post by thefunkyjoint »

Is it possible to alter this behaviour, to use only one process ?

My users don't like to see many processes of my app on the task manager, they think it's a bug...
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Migrating from DCEF3

Post by salvadordf »

Hi,

The Chromium Embedded Framework (CEF3) does not support the single process setting anymore. It's still possible to set GlobalCEFApp.SingleProcess to True but it's NOT reliable and it should only be used for debugging.

I would suggest you to use a different executable for the subprocesses. Use the SubProcess demo and create a crash_reporter.cfg file as described here :
https://bitbucket.org/chromiumembedded/ ... porting.md

The crash_reporter.cfg file is needed to use a different executable for the subprocesses.

The latest versions of Chrome, Chromium and many other web browsers use multiple processes and it's perfectly normal.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Migrating from DCEF3

Post by thefunkyjoint »

Ok, will check.

Thank you for your kindness and interest in helping ! : )
Post Reply