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.

Chromium1.CreateBrowser question

Post Reply
sodlf159
Posts: 90
Joined: Thu Nov 09, 2023 1:55 pm

Chromium1.CreateBrowser question

Post by sodlf159 »

if not(Chromium1.CreateBrowser(CEFWindowParent1)) then

Timer1
if not(Chromium1.CreateBrowser(CEFWindowParent1)) and
not(Chromium1.Initialized) then

////////////
TempContext := TCefRequestContextRef.New('', '', '', False, False,False, Chromium1.ReqContextHandler);
Chromium1.CreateBrowser(CEFWindowParent1, '', TempContext);
//////////////

I'm curious about the difference between the two.

Proxy also seems to be affected. There is no problem if I do it the second time, but if I proxy it the first time and use it on another computer, I cannot connect because it is already connected. Is there a difference?
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Chromium1.CreateBrowser question

Post by salvadordf »

Hi,

All the browsers created with a aContext parameter set to NIL will use the global context and all of them will share the same settings, cache, etc.

Creating a browser with a new ICefRequestContext instance allows you to have an independent browser with different settings, cache, etc.

See the MDIBrowser demo :
https://github.com/salvadordf/CEF4Delphi/blob/be0efab35e624317514b6614f1771d7f4c446e8c/demos/Delphi_VCL/MDIBrowser/uChildForm.pas#L172
sodlf159
Posts: 90
Joined: Thu Nov 09, 2023 1:55 pm

Re: Chromium1.CreateBrowser question

Post by sodlf159 »

TempContext := TCefRequestContextRef.New('', '', '', False, False, True, nil);

TempContext := TCefRequestContextRef.New('', '', '', False, False, True, Chromium1.ReqContextHandler);

What's the difference?
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Chromium1.CreateBrowser question

Post by salvadordf »

The Handlers are used to expose Delphi events among other things.

Creating a TCefRequestContextRef instance with a Chromium1.ReqContextHandler means that the TChromiumCore instance will get TChromiumCore.OnRequestContextInitialized and TChromiumCore.OnGetResourceRequestHandler_ReqCtxHdlr events.
Post Reply