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运维课程体系大纲

    Linux入门:    Linux系统管理:    Linux服务及安全管理:        httpd,lamp,lnmp        Cache:memcached,varnish(缓存系统)  ...

  2. [易学易懂系列|rustlang语言|零基础|快速入门|(16)|代码组织与模块化]

    [易学易懂系列|rustlang语言|零基础|快速入门|(16)|代码组织与模块化] 实用知识 代码组织与模块化 我们知道,在现代软件开发的过程中,代码组织和模块化是应对复杂性的一种方式. 今天我们来 ...

  3. 第五章 动画 50 动画-transition-group中appear和tag属性的作用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  4. Linux双网口配置时重复配置DEFROUTE和GATEWAY

    配置一台机器时,沿袭了原有网口配置,修改网口名,把em1全部修改改为eth0 mv ifcfg-em1 ifcfg-eth0 mv ifcfg-em2 ifcfg-eth1 改完以后,机器变得不稳定, ...

  5. 原生js实现简单的下拉刷新功能

    前言: 我们在浏览移动端web页面的时候,经常会用到下拉刷新. 现在我们用原生的js实现这个非常简单的下拉刷新功能. (温馨提示:本文比较基础,功能也很简单.写的不好的地方,希望大神提点一二.) 一. ...

  6. 阻止默认/冒泡事件(兼容ie)

    (1) 阻止默认事件 function(e){ if(e && e.preventDefault){ e.preventDefault(); }else{ //IE window.ev ...

  7. 文件操作:fseek()

    int fseek(FILE *stream, long offset, int fromwhere); fseek 用于二进制方式打开的文件,移动文件读写指针位置.   int fseek( FIL ...

  8. 一些简单题(1)(Source : NOIP历年试题+杂题)

    最近也写了些许题目吧,还是写写博客,捋捋思路. P2216 [HAOI2007]理想的正方形 求一个$a \times b(a,b \leq 10^3)$的矩阵,求出一个$n \times n (n ...

  9. Codeforces 1213E Two Small Strings

    cf题面 中文题意 给个n,再给两个长度为2的字符串,要求构造一个长度为\(3n\)的字符串,a.b.c三个字母各n个,且构造出的字符串子串中不能出现给定的两个字符串.如果不存在这样的字符串,就输出N ...

  10. A. Transmigration

    A. Transmigration time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...