salvadordf / CEF4Delphi

CEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows, Linux and MacOS.
https://www.briskbard.com/forum/
Other
1.2k stars 365 forks source link

SetUserAgentOverride makes Client Hints null #434

Closed Gurkan-Aktas closed 2 years ago

Gurkan-Aktas commented 2 years ago

For a project we need to set User Agent, however method below causes all Client Hints to be null. procedure TChromiumCore.SetUserAgentOverride(const aUserAgent, aAcceptLanguage, aPlatform : ustring);

Please recommend a way to set Client Hints later, or prevent setting UserAgent damaging Client Hints.

Tried setting platform value to Windows by updating Sec-Ch-Ua-Platform header, with below code : request.SetHeaderByName('Sec-Ch-Ua-Platform', 'Windows', true); at OnBeforeResourceLoad event however did not work (it works for some headers, some seem special and not affected, does not work for those starting with Sec-Ch).

Please help..

salvadordf commented 2 years ago

Hi,

Sec-CH-UA Client Hints seems to be unsupported by CEF. Read this CEF issue.

TChromiumCore.SetUserAgentOverride uses the Emulation.setUserAgentOverride DevTools method.

Possible workaround 1 : Try setting the GlobalCEFApp.UserAgent property before the GlobalCEFApp.StartMainProcess call in the DPR file.

Possible workaround 2 : Build the CEF binaries after applying the code in PR #372

Possible workaround 3 : You can also try the new and experimental "Chrome runtime" mode. In order to try this mode in the MiniBrowser demo set GlobalCEFApp.ChromeRuntime := True; here

In any case, this is a CEF feature that needs to be implemented. I would suggest that you ask about the status of this feature in this CEF issue.

Please, use our forums for more questions.