在Chromium Embedded 3(DCEF3)(CefVCL)中更改用户代理

在Chromium Embedded 3(DCEF3)(CefVCL)中更改用户代理

问题描述:

我正在尝试修改TChromium的用户代理,并且在使用CefVCL的情况下,我没有发现任何程序。已经由ceflib看起来必须这样做了,我看到一个变量 settings接收到一个值 user_agent,但是VCL已经拥有了,这种方式是否可行?

I'm trying to modify the User Agent of TChromium and I found no procedure for this, in case it is using CefVCL. Already by ceflib looks like it has to yes, I saw a variable "settings" that receives a value "user_agent" but the VCL already has, will have or is not possible this way?

不是完整的更改,但对我有用。

Not full change, but it work for me.

procedure TForm1.Chromium1BeforeResourceLoad(Sender: TObject;
  const browser: ICefBrowser; const frame: ICefFrame;
  const request: ICefRequest; const callback: ICefRequestCallback; out
  Result: TCefReturnValue);

Var
  map: ICefStringMultimap;
begin
    map := TCefStringMultimapOwn.Create;
    request.GetHeaderMap(map);
    map.Append('User-Agent','Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16');
    request.SetHeaderMap(map);
    callback.Cont(true);
end;