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.

Different proxy settings in 2 TChromium and windows

snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Different proxy settings in 2 TChromium and windows

Post by snoop »

Hello!
I have 2 TChromium with TCEFWindowParent for each
I want to make different proxy in each browser. But making settings in one changes it in another... So it makes same proxy. How to solve this problem?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different proxy settings in 2 TChromium and windows

Post by salvadordf »

Hi,
snoop wrote: Thu Sep 28, 2017 11:15 am I have 2 TChromium with TCEFWindowParent for each
I want to make different proxy in each browser. But making settings in one changes it in another... So it makes same proxy. How to solve this problem?
That's a pending new feature that I still have to add.

Right now CEF4Delphi uses only one global request context for all browsers and that context is the responsible of setting and getting the preferences.

I'll try to add it as soon as I can.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

Post by snoop »

ok looking forward to it
I hope this won't introduce new functions. Because I have already code to change proxies for my browsers; it just wont change them separately yet
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different proxy settings in 2 TChromium and windows

Post by salvadordf »

Hi,

I just uploaded the new CEF4Delphi and now you should be able to set different proxy settings in your browsers.

I've modified the MDIBrowser to test the new feature. As you can see, there are only a few new parameters in TChromium.CreateBrowser.

The procedure TChildForm.FormShow in MDIBrowser has all the code you need and some comments.

As you can see, to have an independent browser you only have to create a new TCefRequestContextRef and use it as a parameter in TChromium.CreateBrowser.

Using a new TCefRequestContextRef will override several global properties like the cache and cookies directories. You will be able to log in the same website with different accounts from the same application.

If you need to share the same cache and cookies in several browsers you can create the new request context using TCefRequestContextRef.Shared instead of TCefRequestContextRef.New
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

Post by snoop »

thanks.. a bit more complicated but ok
Also, a small question. How can I change text of checking cef-libraries? ("cef libraries are missing", or different version)?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different proxy settings in 2 TChromium and windows

Post by salvadordf »

That text is in the TCefApplication.CheckCEFLibrary function in the uCEFApplication.pas file but you can set GlobalCEFApp.CheckCEFFiles to False if you are distributing your application with the right CEF binaries.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

Post by snoop »

Thanks. This is for future updates in case of manually replacing libraries - to give links/instructions in text for user
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

Post by snoop »

Hello
Can I change proxies after creating browser using this method?
The problem is I need to share all the other settings between browsers, Only different proxies. How to make it?

TCefRequestContextRef.Shared(..
what should I write? I need to take settings which I do at the beginning.
GlobalCEFApp.Cache := gsappPath + 'cache';
etc..
^ from there

also, seems that loading "file:///..." doesnt work in browser. How can I load text file in chromium?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different proxy settings in 2 TChromium and windows

Post by salvadordf »

Hi,
snoop wrote: Mon Nov 13, 2017 12:40 pm Can I change proxies after creating browser using this method?
The problem is I need to share all the other settings between browsers, Only different proxies. How to make it?

TCefRequestContextRef.Shared(..
what should I write? I need to take settings which I do at the beginning.
GlobalCEFApp.Cache := gsappPath + 'cache';
etc..
^ from there
Take a look at the MDIBrowser demo.

The TChildForm.FormShow procedure can create browsers using the global request context or a new one.
If you need several windows sharing a request context use the TChromium.ShareRequestContext function.

The proxy settings can be set anytime. They will be updated internally the next time you load a website.
snoop wrote: Mon Nov 13, 2017 12:40 pm also, seems that loading "file:///..." doesnt work in browser. How can I load text file in chromium?
I just checked the MiniBrowser and opened a text file using the function in the upper-right button and it works.
Remember that the "file:///..." URL must be encoded.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: Different proxy settings in 2 TChromium and windows

Post by snoop »

Thanks, but sorry I will ask my question in another way:

How can I make shared contextRef based on GlobalCefApp settings?
Can you just write that single line for me please?

TCefRequestContextRef.Shared(.. <from GlobalCefApp>?)
Post Reply