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.

RequestContext.SetPreference error

Post Reply
gresaggr
Posts: 22
Joined: Mon Mar 04, 2019 12:41 pm

RequestContext.SetPreference error

Post by gresaggr »

Hello.
Trying to set custom params and get error:

Code: Select all

var
  TempValue: ICefValue;
  TempChromium: TChromium;
 begin
  ....
  TempChromium := TChromium.Create(TempSheet); 
  TempValue := TCefValueRef.New;
  TempValue.SetString('de-DE');
  TempChromium.Browser.Host.RequestContext.SetPreference('accept_language_list', TempValue, error); 
 ...	
 end; 
How to fix it?
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: RequestContext.SetPreference error

Post by salvadordf »

Hi,

The easiest way to modify the Accept-Language HTTP header is by setting GlobalCEFApp.AcceptLanguageList before the GlobalCEFApp.StarMainProcess call or by setting TChromium.Options.AcceptLanguageList before the TChormium.CreateBrowser call.

You can modify some browser preferences but not all of them, and some others are not supported by CEF3.

If you want to try updating that preference add a TChromium.UpdatePreference call in TChromium.doUpdatePreferences with the preference name and value.

If you need to modify the request headers you can also use the TChromium.OnBeforeResourceLoad event like this :
https://github.com/salvadordf/CEF4Delph ... r.pas#L419
gresaggr
Posts: 22
Joined: Mon Mar 04, 2019 12:41 pm

Re: RequestContext.SetPreference error

Post by gresaggr »

Well, "accept_language_list" here is just for example but "TChromium.Options." is a good idea!

Thanks!
Post Reply