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.

Different proxy settings in 2 TChromium and windows

User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different proxy settings in 2 TChromium and windows

Post 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.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

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

Re: Different proxy settings in 2 TChromium and windows

Post 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.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

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

Re: Different proxy settings in 2 TChromium and windows

Post by salvadordf »

I forgot that the proxy preferences are modified in the request context. :oops:

You're right!

You need a different request context to have different proxy settings.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

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

Re: Different proxy settings in 2 TChromium and windows

Post 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.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

Post by snoop »

Oh thats really bad... Can you try to do it
I will try to make 2 new contexts with same parameters...
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different proxy settings in 2 TChromium and windows

Post by salvadordf »

Modifying the original CEF3 code is way beyond my abilities. :(
Post Reply