Page 2 of 2
Re: Different proxy settings in 2 TChromium and windows
Posted: Mon Nov 13, 2017 5:52 pm
by salvadordf
Hi,
The code you are asking is in the TChromium.ShareRequestContext function I mentioned before.
Code: Select all
TCefRequestContextRef.Shared(FBrowser.Host.RequestContext, aHandler);
The "Shared" class function uses the cef_create_context_shared function and these are the CEF code
comments in /include/capi/cef_request_context_capi.h
Code: Select all
///
// Creates a new context object that shares storage with |other| and uses an
// optional |handler|.
///
The first parameter is an existing RequestContext, for example TChromium.Browser.Host.RequestContext
The second parameter is a ICefRequestContextHandler in case you are using that. By default, it's nil.
When you call TChromium.CreateBrowser without a RequestContext, the new browser will use the global request context and the settings from GlobalCEFApp.
If the request context used as the first parameter in TCefRequestContextRef.Shared is the global request context, then it will be using the settings from GlobalCEFApp.
Re: Different proxy settings in 2 TChromium and windows
Posted: Tue Nov 14, 2017 2:42 pm
by snoop
Im still having a problem, because I tried to create 1st browser this way too
TempContext := TCefRequestContextRef.Shared(ch.Browser.Host.RequestContext, nil);
ch.CreateBrowser(wnd, '', TempContext);
but calling ch.Browser.Host.RequestContext before creating browser gets an error.. because its not created I guess
Re: Different proxy settings in 2 TChromium and windows
Posted: Tue Nov 14, 2017 7:49 pm
by salvadordf
The first parameter in the "Shared" function must be a request context from a different browser.
Before you call the ceratebrowser function nothing is initialized.
Re: Different proxy settings in 2 TChromium and windows
Posted: Wed Nov 15, 2017 1:24 am
by snoop
It works incorrect
So I created default 1st browser
ch1.CreateBrowser(ch1w);
then onAfterCreated event I Created 2nd browser sharing its options:
TempContext := TCefRequestContextRef.Shared(ch1.Browser.Host.RequestContext, nil);
ch2.CreateBrowser(wnd, '', TempContext);
But they are sharing all options! And proxies! I need to share all options (cookies,cache etc) except proxies. I need them different
Currently changing browser.proxytype and all the rest, then calling browser.updatepreferences affects both of my chromiums! Like before
Please help
Re: Different proxy settings in 2 TChromium and windows
Posted: Wed Nov 15, 2017 7:41 am
by salvadordf
I forgot that the proxy preferences are modified in the request context.
You're right!
You need a different request context to have different proxy settings.
Re: Different proxy settings in 2 TChromium and windows
Posted: Wed Nov 15, 2017 10:55 am
by snoop
ohhh that's bad! Can you make this in the next version? I really raelly need it! And I think its pretty common task! Sharing all except proxies.
Also currently: what if I make new request context but with same cookies folder? will it share it now or it will conflict between 2 browsers? will it overwrite each others cookies or even raise erorrs?
Re: Different proxy settings in 2 TChromium and windows
Posted: Wed Nov 15, 2017 1:16 pm
by salvadordf
snoop wrote: Wed Nov 15, 2017 10:55 am
ohhh that's bad! Can you make this in the next version? I really raelly need it! And I think its pretty common task! Sharing all except proxies.
I'm afraid I can't. That's how CEF3 works and CEF4Delphi is only the wrapper around it.
snoop wrote: Wed Nov 15, 2017 10:55 am
Also currently: what if I make new request context but with same cookies folder? will it share it now or it will conflict between 2 browsers? will it overwrite each others cookies or even raise erorrs?
I've never tried that.
Re: Different proxy settings in 2 TChromium and windows
Posted: Wed Nov 15, 2017 2:46 pm
by snoop
Oh thats really bad... Can you try to do it
I will try to make 2 new contexts with same parameters...
Re: Different proxy settings in 2 TChromium and windows
Posted: Wed Nov 15, 2017 2:51 pm
by salvadordf
Modifying the original CEF3 code is way beyond my abilities.
