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. MongoDB的优势应用场景和配置

    一:MongoDB的简介: MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案 MongoDB是一个介于关系数据库和非关系数据库之间的 ...

  2. Django-csrf中间件

    一.详解csrf原理 csrf要求发送post,put,或者delete请求的时候,是先以get方式发送请求,服务端响应时会分配一个随机字符串给客户端,客户端第二次发送post,put或delete请 ...

  3. Python 3标准库 第十四章 应用构建模块

    Python 3标准库 The Python3 Standard Library by  Example -----------------------------------------第十四章   ...

  4. eclipse导入tomcat时Unknown version of Tomcat was specified

    Unknown version of Tomcat was specified 的原因有2种可能: 1 路径不是真正的路径,可能是其子路径,要找到bin路径. 2 安装目录没有访问权限. 我的就是第2 ...

  5. (转)window.parent和window.opener区别

    下面一段代码是关于window.parent和window.opener区别 来讲的,我们如果要用到iframe的值传到另一框架就要用到window.opener.document.getElemen ...

  6. python re.match与re.search的区别

    re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None:而re.search匹配整个字符串,直到找到一个匹配. #!/usr/bin/python impor ...

  7. 2018 计蒜之道-初赛 第一场 A-百度无人车

    百度一共制造了 nn 辆无人车,其中第 ii 辆车的重量为 a_i\ \mathrm{kg}ai​ kg. 由于车辆过重会增大轮胎的磨损程度,现在要给这 nn 辆车减轻重量.每将一辆车减轻 1\ \m ...

  8. luogu P1362 兔子数 x

    P1362 兔子数 题目描述 设 S(N ) 表示 N 的各位数字之和,如 S(484) = 4+8+4 = 16, S(22) = 2+2 = 4.如果一个正整数满足 S(x*x) = S(x) * ...

  9. Linux 打印简单日志(一)

    简单日志输出: #include<stdio.h> #include<string.h> #include<stdlib.h> void write(char* f ...

  10. confluence部署

    confluence -- 团队文档的管理平台. 首先要在confluence官网买key. 部署 安装jdk 1.8 环境 查看机器是否自带 java -version,没有再安装. yum ins ...