dcef3 基本使用经验总结

https://www.cnblogs.com/h2285409/p/10517483.html

加载命令启动参数    --enable-system-flash 会加载系统默认的flash浏览器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
procedure OnBeforeCmdLine(const processType: ustring; const commandLine: ICefCommandLine);
begin
  commandLine.AppendSwitch('--enable-system-flash');
  commandLine.AppendSwitch('--disable-web-security');
  commandLine.AppendSwitch('no-proxy-server');
end;
 
begin
  CefCache := 'cache';
  CefLocale := 'zh-CN';
  CefOnBeforeCommandLineProcessing := OnBeforeCmdLine;
  CefSingleProcess := False;
 
  if not CefLoadLibDefault then
    Exit;
 
  Application.Initialize;
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end.

  

其它cmdLine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
procedure OnBeforeCmdLine(const processType: ustring; const commandLine: ICefCommandLine);
begin
 
  //加载系统安装的flash,使用前系统需安装flash播放器
  //commandLine.AppendSwitch('--enable-system-flash');
 
  //允许js跨域
  commandLine.AppendSwitch('--disable-web-security'); 
 str_ip:='218.207.212.79:80';  //设置代理ip  120.203.159.18:8118  218.189.26.20:8080
  commandLine.AppendSwitchWithValue('proxy-server',str_ip);
 
  //禁用代理
  //commandLine.AppendSwitch('no-proxy-server');
 
  //不同域名不同进程
  commandLine.AppendSwitch('--process-per-site');
 
  //指定子进程渲染
  //commandLine.AppendSwitchWithValue('browser-subprocess-path', 'cefsubprocess.exe');
 
  //加载指定flash版本
  commandLine.AppendSwitchWithValue('ppapi-flash-version''21.0.0.213');
  commandLine.AppendSwitchWithValue('ppapi-flash-path''PepperFlash\pepflashplayer.dll');
end;

拓展JS方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
TCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn)
  protected
    procedure OnWebKitInitialized; override;
  end;
 
TTestExtension = class
class function hello: string;
class procedure mouseover(const data: string);
end;
 
procedure TCustomRenderProcessHandler.OnWebKitInitialized;
begin
{$IFDEF DELPHI14_UP}
  TCefRTTIExtension.Register('app', TTestExtension);
{$ENDIF}
end;
 
class procedure TTestExtension.mouseover(const data: string);
var
msg: ICefProcessMessage;
begin
msg := TCefProcessMessageRef.New('mouseover');
msg.ArgumentList.SetString(0, data);
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
end;
 
class function TTestExtension.hello: string;
begin
Result := 'Hello from Delphi';
end;
 
initialization
  CefRemoteDebuggingPort := 9000;
  CefRenderProcessHandler := TCustomRenderProcessHandler.Create;
  CefBrowserProcessHandler := TCefBrowserProcessHandlerOwn.Create;

  

Delphi执行JS方法

1
2
3
4
5
6
procedure TMainForm.actExecuteJSExecute(Sender: TObject);
begin
  if crm.Browser <> nil then
    crm.Browser.MainFrame.ExecuteJavaScript(
      'alert(''JavaScript execute works!'');''about:blank'0);
end;

 

一般单进程模式是用来调试的,release版本最好是多进程模式,如果debug版本也是多进程的话,由于Browser、Rendder等进程是独立分开的,所以即便在一些函数中打上断点也进不去!而单进程话就都可以进去。至于debug版本多进程模式下为何会弹出两个主程序窗口我也不是很清楚,但是release版本多进程模式下就正常了,只有一个主程序窗口。并且多进程模式下调用CefShutdown就是OK的,app也能够正常析构,而单进程模式调用CefShutdown会直接崩溃!

另外,官方文档上说release版本单进程不是很稳定,不建议使用单进程模式

dcef3 基本使用经验总结的更多相关文章

  1. MyEclipse10--的使用经验

    MyEclipse10--的使用经验总结 ------------------ 1.MyEclipse中的验证validation----->>用MyEclipse做ExtJs项目研发的时 ...

  2. XCode的个人使用经验

    Xcode是强大的IDE(但个人觉得不如Visual Studio做得好),其强大功能无需本人再赘述,本文也不是一篇“快捷键列表”,因为XCode上的快捷键极其多,而且还有不少是需要同时按下四个按键的 ...

  3. Flask-admin使用经验技巧总结

    笔者是看狗书入门的flask,狗书上对于flask-admin这个扩展并没有进行讲解,最近因为项目需要,学习使用flask-admin,瞬间体会到了flask开发的快速.扩展的强大 Flask-adm ...

  4. Unity3D使用经验总结 缺点篇

    不论是从官方手册,还是各种第三方教程,几乎涉及到的,都是讲如何使用U3D,以及U3D的优点. 虽然我是用的一个让步语气,但请不要否认U3D的这些优点,它们的确存在. 但对于一个引擎的特性来说,优点与缺 ...

  5. Unity3D使用经验总结 优点篇

    09年还在和其它小伙伴开发引擎的时候,Unity3D就初露头角. 当时就对这种基于组件式的设计结构很不理解. 觉得拆分过于细致,同时影响效率. 而时至今日,UNITY3D已经成为了众多团队的首选3D引 ...

  6. 控件使用经验-MVP模式+控件封装

    项目背景 几年前参与了一个面向学校的人事管理软件的开发,基于WinForm平台.今天主要想谈一谈其中关于控件的使用经验.这个项目我们大量使用了第三方控件.由于这个产品的生命周期很长,我们在设计时要考虑 ...

  7. 走进异步世界-犯傻也值得分享:ConfigureAwait(false)使用经验分享

    在上周解决“博客程序异步化改造之后遭遇的性能问题”的过程中,我们干了一件自以为很有成就感的事——在表现层(MVC与WebForms)将所有使用await的地方都加上了ConfigureAwait(fa ...

  8. Fastreport使用经验(转)在Delphi程序中访问报表对象

    Fastreport使用经验(转) 在Delphi程序中访问报表对象 最基本的方法就是frxReport1.FindObject. 然后把返回的对象强制转换成它的类型,当然,在报表中必须真的有这么个东 ...

  9. [转]Session服务器配置指南与使用经验

    本文转自:http://www.cnblogs.com/zhangziqiu/archive/2009/03/26/SessionServer.html 一.摘要 所有Web程序都会使用Session ...

随机推荐

  1. linux服务器上软件的安装

    mysql数据库的安装 redis的安装 zookeeper的安装

  2. DB2中常见sqlCode原因分析

    000 | 00000 | SQL语句成功完成 01xxx | SQL语句成功完成,但是有警告 +012 | 01545 | 未限定的列名被解释为一个有相互关系的引用 +098 | 01568 | 动 ...

  3. Vue -- mounted方法中调用methods的方法(并取出mounted方法中回调函数的值)

    结果:

  4. 使用es6新增Set函数快速数组去重

    使用new Set()快速数组去重: let arr = [1, 2, 2, 3, 4, 5, 5, 5, 6] let set = new Set([...arr]) console.log([.. ...

  5. C# WCF发布服务的元数据的方式

    发布服务元数据的方式有两种:一是基于HTTP-GET协议提供元数据,它是一种绝大多数平台都能支持的简单text-based协议:另一种是元数据交换终结点. 1.基于HTTP-GET协议 <?xm ...

  6. 数组翻转的方法(java实现)

    数组翻转的方法(java实现),所谓数组翻转,就是将数组倒置,例如原数组为:{"a","b","c","d"},那么翻转 ...

  7. TTTTTTTTTTTTTTTTTT POJ 2724 奶酪消毒机 二分匹配 建图 比较难想

    Purifying Machine Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5004   Accepted: 1444 ...

  8. 【LOJ2316】「NOIP2017」逛公园

    [题目链接] [点击打开链接] [题目概括] 对给定\(K\),起点\(1\)到终点\(n\)中对长度为\([L,L+K]\)的路径计数. \(L\)为\(1\)到\(n\)的最短路长度. [思路要点 ...

  9. Vue CLi3入门

    摘自:https://www.jianshu.com/p/cf9b56efd3b8 Vue CLi3入门 12018.11.15 14:16:17字数 1222阅读 8895 地址 Vue CLi3 ...

  10. centos6 centos7 配置开机启动服务

    centos 6 :使用chkconfig命令即可. 我们以apache服务为例: #chkconfig --add apache 添加nginx服务 #chkconfig apache on 开机自 ...