Page 1 of 1

RequestContext.SetPreference error

Posted: Mon Mar 04, 2019 12:49 pm
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?

Re: RequestContext.SetPreference error

Posted: Mon Mar 04, 2019 1:17 pm
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

Re: RequestContext.SetPreference error

Posted: Mon Mar 04, 2019 1:53 pm
by gresaggr
Well, "accept_language_list" here is just for example but "TChromium.Options." is a good idea!

Thanks!