4

使用CefSharp在.Net程序中嵌入Chrome浏览器(二)——参数设置

 3 years ago
source link: https://www.cnblogs.com/TianFang/p/4658151.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

在实现了.Net程序中嵌入Chrome浏览器后,下一步的个性化操作就是加入一些设置了,在前面的文章中,我们可以看到在使用Chrome控件前,有如下一个操作:

    var setting = new CefSharp.CefSettings();
    CefSharp.Cef.Initialize(setting, true, false);

这个setting变量就是用来存放chrome的全局设置的地方,当需要进行设置的时候,只需要对它进行修改即可。例如,我们要修改缓存目录,只需要如下设置即可:

    var setting = new CefSharp.CefSettings()
    {
        CachePath = Directory.GetCurrentDirectory() + @"\Cache",
    };

另外,有的设置是通过启动参数传入的,这些启动参数存放在CefCommandLineArgs成员中了,通过字符串的形式传入。例如,我们要给Chrome程序加一个代理服务器,则可以修改如下:

    setting.CefCommandLineArgs.Add("--proxy-server", "http://127.0.0.1:8877");

Chrome的常用参数则可以参考这个网页:http://www.ericdlarson.com/misc/chrome_command_line_flags.html


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK