mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-01-03 10:15:38 +02:00
bug fix #68
This commit is contained in:
parent
b54a2861c4
commit
f5f1a767c9
@ -60,16 +60,6 @@ begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnProcessMessageReceived := JSEvalFrm.RenderProcessHandler_OnProcessMessageReceivedEvent;
|
||||
|
||||
// In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data.
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'cef\locales';
|
||||
GlobalCEFApp.cache := 'cef\cache';
|
||||
GlobalCEFApp.cookies := 'cef\cookies';
|
||||
GlobalCEFApp.UserDataPath := 'cef\User Data';
|
||||
}
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -41,19 +41,13 @@ program JSExecutingFunctions;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFInterfaces,
|
||||
uCEFv8Value,
|
||||
uCEFConstants,
|
||||
uCEFTypes,
|
||||
uJSExecutingFunctions in 'uJSExecutingFunctions.pas' {JSExecutingFunctionsFrm},
|
||||
uMyV8Handler in 'uMyV8Handler.pas';
|
||||
|
||||
@ -62,32 +56,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
context.Global.SetValueByKey('register', TCefv8ValueRef.NewFunction('register', TempHandler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser;
|
||||
sourceProcess : TCefProcessId;
|
||||
const message : ICefProcessMessage;
|
||||
var aHandled : boolean);
|
||||
var
|
||||
arguments: TCefv8ValueArray;
|
||||
begin
|
||||
if (message.name = EXECFUNCTION_MSGNAME) then
|
||||
begin
|
||||
if (GlobalCallbackFunc <> nil) then
|
||||
GlobalCallbackFunc.ExecuteFunctionWithContext(GlobalCallbackContext, nil, arguments);
|
||||
|
||||
aHandled := True;
|
||||
end
|
||||
else
|
||||
aHandled := False;
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextCreated := GlobalCEFApp_OnContextCreated;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -49,7 +49,8 @@ uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics,
|
||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
||||
{$ENDIF}
|
||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants;
|
||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes,
|
||||
uCEFConstants, uCEFv8Value;
|
||||
|
||||
const
|
||||
JSDEMO_CONTEXTMENU_EXECFUNCTION = MENU_ID_USER_FIRST + 1;
|
||||
@ -88,6 +89,12 @@ var
|
||||
GlobalCallbackFunc : ICefv8Value = nil;
|
||||
GlobalCallbackContext : ICefv8Context = nil;
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser;
|
||||
sourceProcess : TCefProcessId;
|
||||
const aMessage : ICefProcessMessage;
|
||||
var aHandled : boolean);
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
@ -106,7 +113,36 @@ implementation
|
||||
// be executed.
|
||||
|
||||
uses
|
||||
uCEFProcessMessage;
|
||||
uCEFProcessMessage, uMyV8Handler;
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempHandler : ICefv8Handler;
|
||||
TempFunction : ICefv8Value;
|
||||
begin
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
TempFunction := TCefv8ValueRef.NewFunction('register', TempHandler);
|
||||
|
||||
context.Global.SetValueByKey('register', TempFunction, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser;
|
||||
sourceProcess : TCefProcessId;
|
||||
const aMessage : ICefProcessMessage;
|
||||
var aHandled : boolean);
|
||||
var
|
||||
arguments: TCefv8ValueArray;
|
||||
begin
|
||||
if (aMessage.name = EXECFUNCTION_MSGNAME) then
|
||||
begin
|
||||
if (GlobalCallbackFunc <> nil) then
|
||||
GlobalCallbackFunc.ExecuteFunctionWithContext(GlobalCallbackContext, nil, arguments);
|
||||
|
||||
aHandled := True;
|
||||
end
|
||||
else
|
||||
aHandled := False;
|
||||
end;
|
||||
|
||||
procedure TJSExecutingFunctionsFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
|
@ -41,21 +41,13 @@ program JSExtension;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFMiscFunctions,
|
||||
uCEFConstants,
|
||||
uCEFRenderProcessHandler,
|
||||
uCEFInterfaces,
|
||||
uCEFv8Handler,
|
||||
uCEFTypes,
|
||||
uJSExtension in 'uJSExtension.pas' {JSExtensionFrm},
|
||||
uTestExtensionHandler in 'uTestExtensionHandler.pas',
|
||||
uSimpleTextViewer in 'uSimpleTextViewer.pas' {SimpleTextViewerFrm};
|
||||
@ -65,34 +57,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitialized;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is a JS extension example with 2 functions and several parameters.
|
||||
// Please, read the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var myextension;' +
|
||||
'if (!myextension)' +
|
||||
' myextension = {};' +
|
||||
'(function() {' +
|
||||
' myextension.mouseover = function(a) {' +
|
||||
' native function mouseover();' +
|
||||
' mouseover(a);' +
|
||||
' };' +
|
||||
' myextension.sendresulttobrowser = function(b,c) {' +
|
||||
' native function sendresulttobrowser();' +
|
||||
' sendresulttobrowser(b,c);' +
|
||||
' };' +
|
||||
'})();';
|
||||
|
||||
TempHandler := TTestExtensionHandler.Create;
|
||||
|
||||
CefRegisterExtension('myextension', TempExtensionCode, TempHandler);
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitialized;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -97,12 +97,14 @@ type
|
||||
var
|
||||
JSExtensionFrm: TJSExtensionFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitialized;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uSimpleTextViewer, uCEFMiscFunctions;
|
||||
uSimpleTextViewer, uCEFMiscFunctions, uTestExtensionHandler;
|
||||
|
||||
// The CEF3 document describing extensions is here :
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
@ -122,6 +124,34 @@ uses
|
||||
// Even if you create several TChromium objects you should have no problem because each of them will have its own
|
||||
// TChromium.OnProcessMessageReceived event to receive the messages from the extension.
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitialized;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is a JS extension example with 2 functions and several parameters.
|
||||
// Please, read the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var myextension;' +
|
||||
'if (!myextension)' +
|
||||
' myextension = {};' +
|
||||
'(function() {' +
|
||||
' myextension.mouseover = function(a) {' +
|
||||
' native function mouseover();' +
|
||||
' mouseover(a);' +
|
||||
' };' +
|
||||
' myextension.sendresulttobrowser = function(b,c) {' +
|
||||
' native function sendresulttobrowser();' +
|
||||
' sendresulttobrowser(b,c);' +
|
||||
' };' +
|
||||
'})();';
|
||||
|
||||
TempHandler := TTestExtensionHandler.Create;
|
||||
|
||||
CefRegisterExtension('myextension', TempExtensionCode, TempHandler);
|
||||
end;
|
||||
|
||||
procedure TJSExtensionFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -41,17 +41,13 @@ program JSExtensionWithFunction;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFMiscFunctions,
|
||||
uCEFInterfaces,
|
||||
uJSExtensionWithFunction in 'uJSExtensionWithFunction.pas' {JSExtensionWithFunctionFrm},
|
||||
uMyV8Handler in 'uMyV8Handler.pas';
|
||||
|
||||
@ -60,29 +56,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is the JS extension example with a function in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var test;' +
|
||||
'if (!test)' +
|
||||
' test = {};' +
|
||||
'(function() {' +
|
||||
' test.myfunc = function() {' +
|
||||
' native function myfunc();' +
|
||||
' return myfunc();' +
|
||||
' };' +
|
||||
'})();';
|
||||
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
|
||||
CefRegisterExtension('v8/test', TempExtensionCode, TempHandler);
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -74,16 +74,44 @@ type
|
||||
var
|
||||
JSExtensionWithFunctionFrm: TJSExtensionWithFunctionFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uMyV8Handler;
|
||||
|
||||
// The CEF3 document describing JavaScript integration is here :
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
// The HTML file in this demo has a button that shows the contents of 'test.myfunc()'
|
||||
// which was registered in the GlobalCEFApp.OnWebKitInitialized event.
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is the JS extension example with a function in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var test;' +
|
||||
'if (!test)' +
|
||||
' test = {};' +
|
||||
'(function() {' +
|
||||
' test.myfunc = function() {' +
|
||||
' native function myfunc();' +
|
||||
' return myfunc();' +
|
||||
' };' +
|
||||
'})();';
|
||||
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
|
||||
CefRegisterExtension('v8/test', TempExtensionCode, TempHandler);
|
||||
end;
|
||||
|
||||
procedure TJSExtensionWithFunctionFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -41,17 +41,13 @@ program JSExtensionWithObjectParameter;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFMiscFunctions,
|
||||
uCEFInterfaces,
|
||||
uJSExtensionWithObjectParameter in 'uJSExtensionWithObjectParameter.pas' {JSExtensionWithObjectParameterFrm},
|
||||
uMyV8Handler in 'uMyV8Handler.pas';
|
||||
|
||||
@ -60,33 +56,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is the JS extension example with a function in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var test;' +
|
||||
'if (!test)' +
|
||||
' test = {};' +
|
||||
'(function() {' +
|
||||
' test.__defineGetter__(' + quotedstr('myparam') + ', function() {' +
|
||||
' native function GetMyParam();' +
|
||||
' return GetMyParam();' +
|
||||
' });' +
|
||||
' test.__defineSetter__(' + quotedstr('myparam') + ', function(b) {' +
|
||||
' native function SetMyParam();' +
|
||||
' if(b) SetMyParam(b);' +
|
||||
' });' +
|
||||
'})();';
|
||||
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
|
||||
CefRegisterExtension('v8/test', TempExtensionCode, TempHandler);
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
@ -98,7 +67,7 @@ begin
|
||||
Application.MainFormOnTaskbar := True;
|
||||
{$ENDIF}
|
||||
Application.CreateForm(TJSExtensionWithObjectParameterFrm, JSExtensionWithObjectParameterFrm);
|
||||
Application.Run;
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
GlobalCEFApp.Free;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -74,10 +74,15 @@ type
|
||||
var
|
||||
JSExtensionWithObjectParameterFrm: TJSExtensionWithObjectParameterFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uMyV8Handler;
|
||||
|
||||
// The CEF3 document describing JavaScript integration is here :
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
@ -87,6 +92,33 @@ implementation
|
||||
// This demo is based in the code comments for the cef_register_extension function in the file
|
||||
// /include/capi/cef_v8_capi.h
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is the JS extension example with a function in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var test;' +
|
||||
'if (!test)' +
|
||||
' test = {};' +
|
||||
'(function() {' +
|
||||
' test.__defineGetter__(' + quotedstr('myparam') + ', function() {' +
|
||||
' native function GetMyParam();' +
|
||||
' return GetMyParam();' +
|
||||
' });' +
|
||||
' test.__defineSetter__(' + quotedstr('myparam') + ', function(b) {' +
|
||||
' native function SetMyParam();' +
|
||||
' if(b) SetMyParam(b);' +
|
||||
' });' +
|
||||
'})();';
|
||||
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
|
||||
CefRegisterExtension('v8/test', TempExtensionCode, TempHandler);
|
||||
end;
|
||||
|
||||
procedure TJSExtensionWithObjectParameterFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -41,17 +41,13 @@ program JSSimpleExtension;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFMiscFunctions,
|
||||
uCEFTypes,
|
||||
uJSSimpleExtension in 'uJSSimpleExtension.pas' {JSSimpleExtensionFrm};
|
||||
|
||||
{$R *.res}
|
||||
@ -59,23 +55,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
begin
|
||||
// This is the first JS extension example in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var test;' +
|
||||
'if (!test)' +
|
||||
' test = {};' +
|
||||
'(function() {' +
|
||||
' test.myval = ' + quotedstr('My Value!') + ';' +
|
||||
'})();';
|
||||
|
||||
CefRegisterExtension('v8/test', TempExtensionCode, nil);
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
|
@ -45,6 +45,17 @@
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug with optimization' or '$(Cfg_3)'!=''">
|
||||
<Cfg_3>true</Cfg_3>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_3)'=='true') or '$(Cfg_3_Win32)'!=''">
|
||||
<Cfg_3_Win32>true</Cfg_3_Win32>
|
||||
<CfgParent>Cfg_3</CfgParent>
|
||||
<Cfg_3>true</Cfg_3>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<VerInfo_Locale>3082</VerInfo_Locale>
|
||||
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
|
||||
@ -100,6 +111,18 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_3_Win32)'!=''">
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
|
||||
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
|
||||
<DCC_DebugDCUs>true</DCC_DebugDCUs>
|
||||
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
@ -108,17 +131,21 @@
|
||||
<DCCReference Include="uJSSimpleExtension.pas">
|
||||
<Form>JSSimpleExtensionFrm</Form>
|
||||
</DCCReference>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_1</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Debug with optimization">
|
||||
<Key>Cfg_3</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
|
@ -74,16 +74,38 @@ type
|
||||
var
|
||||
JSSimpleExtensionFrm: TJSSimpleExtensionFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions;
|
||||
|
||||
// The CEF3 document describing JavaScript integration is here :
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
// The HTML file in this demo has a button that shows the contents of 'test.myval'
|
||||
// which was registered in the GlobalCEFApp.OnWebKitInitialized event.
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitializedEvent;
|
||||
var
|
||||
TempExtensionCode : string;
|
||||
begin
|
||||
// This is the first JS extension example in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempExtensionCode := 'var test;' +
|
||||
'if (!test)' +
|
||||
' test = {};' +
|
||||
'(function() {' +
|
||||
' test.myval = ' + quotedstr('My Value!') + ';' +
|
||||
'})();';
|
||||
|
||||
CefRegisterExtension('v8/test', TempExtensionCode, nil);
|
||||
end;
|
||||
|
||||
procedure TJSSimpleExtensionFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -41,18 +41,13 @@ program JSSimpleWindowBinding;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFInterfaces,
|
||||
uCEFv8Value,
|
||||
uCEFConstants,
|
||||
uJSSimpleWindowBinding in 'uJSSimpleWindowBinding.pas' {JSSimpleWindowBindingFrm};
|
||||
|
||||
{$R *.res}
|
||||
@ -60,14 +55,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
begin
|
||||
// This is the first JS Window Binding example in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
context.Global.SetValueByKey('myval', TCefv8ValueRef.NewString('My Value!'), V8_PROPERTY_ATTRIBUTE_NONE);;
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextCreated := GlobalCEFApp_OnContextCreated;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -49,7 +49,8 @@ uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics,
|
||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
||||
{$ENDIF}
|
||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants;
|
||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes,
|
||||
uCEFConstants, uCEFv8Value;
|
||||
|
||||
type
|
||||
TJSSimpleWindowBindingFrm = class(TForm)
|
||||
@ -74,6 +75,8 @@ type
|
||||
var
|
||||
JSSimpleWindowBindingFrm: TJSSimpleWindowBindingFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
@ -84,6 +87,18 @@ implementation
|
||||
// The HTML file in this demo has a button that shows the contents of 'window.myval'
|
||||
// which was set in the GlobalCEFApp.OnContextCreated event.
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempValue : ICEFv8Value;
|
||||
begin
|
||||
// This is the first JS Window Binding example in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempValue := TCefv8ValueRef.NewString('My Value!');
|
||||
|
||||
context.Global.SetValueByKey('myval', TempValue, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
procedure TJSSimpleWindowBindingFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -41,18 +41,13 @@ program JSWindowBindingWithFunction;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFInterfaces,
|
||||
uCEFv8Value,
|
||||
uCEFConstants,
|
||||
uJSWindowBindingWithFunction in 'uJSWindowBindingWithFunction.pas' {JSWindowBindingWithFunctionFrm},
|
||||
uMyV8Handler in 'uMyV8Handler.pas';
|
||||
|
||||
@ -61,18 +56,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempHandler : ICefv8Handler;
|
||||
begin
|
||||
// This is the JS Window Binding example with a function in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
|
||||
context.Global.SetValueByKey('myfunc', TCefv8ValueRef.NewFunction('myfunc', TempHandler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextCreated := GlobalCEFApp_OnContextCreated;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -74,16 +74,35 @@ type
|
||||
var
|
||||
JSWindowBindingWithFunctionFrm: TJSWindowBindingWithFunctionFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uCEFv8Value, uMyV8Handler;
|
||||
|
||||
// The CEF3 document describing JavaScript integration is here :
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
// The HTML file in this demo has a button that shows the result of 'window.myfunc()'
|
||||
// which was set in the GlobalCEFApp.OnContextCreated event.
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempHandler : ICefv8Handler;
|
||||
TempFunction : ICefv8Value;
|
||||
begin
|
||||
// This is the JS Window Binding example with a function in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempHandler := TMyV8Handler.Create;
|
||||
TempFunction := TCefv8ValueRef.NewFunction('myfunc', TempHandler);
|
||||
|
||||
context.Global.SetValueByKey('myfunc', TempFunction, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
procedure TJSWindowBindingWithFunctionFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -41,18 +41,13 @@ program JSWindowBindingWithObject;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
Vcl.Forms,
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
SysUtils,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uCEFInterfaces,
|
||||
uCEFv8Value,
|
||||
uCEFConstants,
|
||||
uJSWindowBindingWithObject in 'uJSWindowBindingWithObject.pas' {JSWindowBindingWithObjectFrm},
|
||||
uMyV8Accessor in 'uMyV8Accessor.pas';
|
||||
|
||||
@ -61,21 +56,6 @@ uses
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempAccessor : ICefV8Accessor;
|
||||
TempObject : ICefv8Value;
|
||||
begin
|
||||
// This is the first JS Window Binding example in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempAccessor := TMyV8Accessor.Create;
|
||||
TempObject := TCefv8ValueRef.NewObject(TempAccessor, nil);
|
||||
TempObject.SetValueByKey('myval', TCefv8ValueRef.NewString('My Value!'), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
context.Global.SetValueByKey('myobj', TempObject, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextCreated := GlobalCEFApp_OnContextCreated;
|
||||
|
@ -100,6 +100,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<AppEnableHighDPI>true</AppEnableHighDPI>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
|
@ -74,16 +74,36 @@ type
|
||||
var
|
||||
JSWindowBindingWithObjectFrm: TJSWindowBindingWithObjectFrm;
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uCEFv8Value, uMyV8Accessor;
|
||||
|
||||
// The CEF3 document describing JavaScript integration is here :
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
// The HTML file in this demo has a button that shows the contents of 'window.myobj.myval'
|
||||
// which was set in the GlobalCEFApp.OnContextCreated event.
|
||||
|
||||
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
var
|
||||
TempAccessor : ICefV8Accessor;
|
||||
TempObject : ICefv8Value;
|
||||
begin
|
||||
// This is the first JS Window Binding example in the "JavaScript Integration" wiki page at
|
||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||
|
||||
TempAccessor := TMyV8Accessor.Create;
|
||||
TempObject := TCefv8ValueRef.NewObject(TempAccessor, nil);
|
||||
TempObject.SetValueByKey('myval', TCefv8ValueRef.NewString('My Value!'), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
context.Global.SetValueByKey('myobj', TempObject, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
end;
|
||||
|
||||
procedure TJSWindowBindingWithObjectFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(Edit1.Text);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<MainSource>MiniBrowser.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<Config Condition="'$(Config)'==''">Release</Config>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Application</AppType>
|
||||
|
@ -9,23 +9,22 @@ package CEF4Delphi;
|
||||
{$EXTENDEDSYNTAX ON}
|
||||
{$IMPORTEDDATA ON}
|
||||
{$IOCHECKS ON}
|
||||
{$LOCALSYMBOLS ON}
|
||||
{$LOCALSYMBOLS OFF}
|
||||
{$LONGSTRINGS ON}
|
||||
{$OPENSTRINGS ON}
|
||||
{$OPTIMIZATION OFF}
|
||||
{$OPTIMIZATION ON}
|
||||
{$OVERFLOWCHECKS OFF}
|
||||
{$RANGECHECKS OFF}
|
||||
{$REFERENCEINFO ON}
|
||||
{$REFERENCEINFO OFF}
|
||||
{$SAFEDIVIDE OFF}
|
||||
{$STACKFRAMES ON}
|
||||
{$STACKFRAMES OFF}
|
||||
{$TYPEDADDRESS OFF}
|
||||
{$VARSTRINGCHECKS ON}
|
||||
{$WRITEABLECONST OFF}
|
||||
{$MINENUMSIZE 1}
|
||||
{$IMAGEBASE $400000}
|
||||
{$DEFINE DEBUG}
|
||||
{$DEFINE RELEASE}
|
||||
{$ENDIF IMPLICITBUILDING}
|
||||
{$DESCRIPTION 'CEF4Delphi'}
|
||||
{$IMPLICITBUILD OFF}
|
||||
|
||||
requires
|
||||
@ -157,6 +156,8 @@ contains
|
||||
uCEFGetExtensionResourceCallback in 'uCEFGetExtensionResourceCallback.pas',
|
||||
uCEFExtension in 'uCEFExtension.pas',
|
||||
uCEFExtensionHandler in 'uCEFExtensionHandler.pas',
|
||||
uBufferPanel in 'uBufferPanel.pas';
|
||||
uBufferPanel in 'uBufferPanel.pas',
|
||||
uCEFApp in 'uCEFApp.pas';
|
||||
|
||||
end.
|
||||
|
||||
|
@ -39,6 +39,23 @@
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
|
||||
<Cfg_2_Win32>true</Cfg_2_Win32>
|
||||
<CfgParent>Cfg_2</CfgParent>
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug with optimization' or '$(Cfg_3)'!=''">
|
||||
<Cfg_3>true</Cfg_3>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_3)'=='true') or '$(Cfg_3_Win32)'!=''">
|
||||
<Cfg_3_Win32>true</Cfg_3_Win32>
|
||||
<CfgParent>Cfg_3</CfgParent>
|
||||
<Cfg_3>true</Cfg_3>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<DCC_CBuilderOutput>All</DCC_CBuilderOutput>
|
||||
<GenPackage>true</GenPackage>
|
||||
@ -90,6 +107,17 @@
|
||||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
||||
<DCC_DebugInformation>0</DCC_DebugInformation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_3_Win32)'!=''">
|
||||
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<DCC_DebugDCUs>true</DCC_DebugDCUs>
|
||||
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
@ -221,17 +249,22 @@
|
||||
<DCCReference Include="uCEFExtension.pas"/>
|
||||
<DCCReference Include="uCEFExtensionHandler.pas"/>
|
||||
<DCCReference Include="uBufferPanel.pas"/>
|
||||
<DCCReference Include="uCEFApp.pas"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_1</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Debug with optimization">
|
||||
<Key>Cfg_3</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
|
@ -154,6 +154,7 @@ contains
|
||||
uCEFGetExtensionResourceCallback in 'uCEFGetExtensionResourceCallback.pas',
|
||||
uCEFExtension in 'uCEFExtension.pas',
|
||||
uCEFExtensionHandler in 'uCEFExtensionHandler.pas',
|
||||
uBufferPanel in 'uBufferPanel.pas';
|
||||
uBufferPanel in 'uBufferPanel.pas',
|
||||
uCEFApp in 'uCEFApp.pas';
|
||||
|
||||
end.
|
||||
|
248
source/uCEFApp.pas
Normal file
248
source/uCEFApp.pas
Normal file
@ -0,0 +1,248 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2017 Salvador Díaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFApp;
|
||||
|
||||
{$IFNDEF CPUX64}
|
||||
{$ALIGN ON}
|
||||
{$MINENUMSIZE 4}
|
||||
{$ENDIF}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows, System.Classes, System.UITypes,
|
||||
{$ELSE}
|
||||
Windows, Classes,
|
||||
{$ENDIF}
|
||||
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar, uCEFApplication;
|
||||
|
||||
type
|
||||
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
||||
protected
|
||||
procedure OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); virtual; abstract;
|
||||
procedure OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); virtual; abstract;
|
||||
procedure GetResourceBundleHandler(var aHandler : ICefResourceBundleHandler); virtual; abstract;
|
||||
procedure GetBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler); virtual; abstract;
|
||||
procedure GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler); virtual; abstract;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCustomCefApp = class(TCefAppOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
procedure OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); override;
|
||||
procedure OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); override;
|
||||
procedure GetResourceBundleHandler(var aHandler : ICefResourceBundleHandler); override;
|
||||
procedure GetBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler); override;
|
||||
procedure GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler); override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.SysUtils,
|
||||
{$ELSE}
|
||||
SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFCommandLine, uCEFConstants;
|
||||
|
||||
|
||||
// TCefAppOwn
|
||||
|
||||
procedure cef_app_on_before_command_line_processing(self: PCefApp;
|
||||
const process_type: PCefString;
|
||||
command_line: PCefCommandLine); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
TCefAppOwn(TempObject).OnBeforeCommandLineProcessing(CefString(process_type), TCefCommandLineRef.UnWrap(command_line));
|
||||
end;
|
||||
|
||||
procedure cef_app_on_register_custom_schemes(self: PCefApp; registrar: PCefSchemeRegistrar); stdcall;
|
||||
var
|
||||
TempWrapper : TCefSchemeRegistrarRef;
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempWrapper := nil;
|
||||
|
||||
try
|
||||
try
|
||||
TempWrapper := TCefSchemeRegistrarRef.Create(registrar);
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
TCefAppOwn(TempObject).OnRegisterCustomSchemes(TempWrapper);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('cef_app_on_register_custom_schemes', e) then raise;
|
||||
end;
|
||||
finally
|
||||
if (TempWrapper <> nil) then FreeAndNil(TempWrapper);
|
||||
end;
|
||||
end;
|
||||
|
||||
function cef_app_get_resource_bundle_handler(self: PCefApp): PCefResourceBundleHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempHandler : ICefResourceBundleHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
TempHandler := nil;
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
begin
|
||||
TCefAppOwn(TempObject).GetResourceBundleHandler(TempHandler);
|
||||
Result := CefGetData(TempHandler);
|
||||
end;
|
||||
end;
|
||||
|
||||
function cef_app_get_browser_process_handler(self: PCefApp): PCefBrowserProcessHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempHandler : ICefBrowserProcessHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
TempHandler := nil;
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
begin
|
||||
TCefAppOwn(TempObject).GetBrowserProcessHandler(TempHandler);
|
||||
Result := CefGetData(TempHandler);
|
||||
end;
|
||||
end;
|
||||
|
||||
function cef_app_get_render_process_handler(self: PCefApp): PCefRenderProcessHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempHandler : ICefRenderProcessHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
TempHandler := nil;
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
begin
|
||||
TCefAppOwn(TempObject).GetRenderProcessHandler(TempHandler);
|
||||
Result := CefGetData(TempHandler);
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefAppOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefApp));
|
||||
|
||||
with PCefApp(FData)^ do
|
||||
begin
|
||||
on_before_command_line_processing := cef_app_on_before_command_line_processing;
|
||||
on_register_custom_schemes := cef_app_on_register_custom_schemes;
|
||||
get_resource_bundle_handler := cef_app_get_resource_bundle_handler;
|
||||
get_browser_process_handler := cef_app_get_browser_process_handler;
|
||||
get_render_process_handler := cef_app_get_render_process_handler;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// TCustomCefApp
|
||||
|
||||
|
||||
constructor TCustomCefApp.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
destructor TCustomCefApp.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCustomCefApp.OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBeforeCommandLineProcessing(processType, commandLine);
|
||||
end;
|
||||
|
||||
procedure TCustomCefApp.OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnRegisterCustomSchemes(registrar);
|
||||
end;
|
||||
|
||||
procedure TCustomCefApp.GetResourceBundleHandler(var aHandler : ICefResourceBundleHandler);
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
FCefApp.Internal_CopyResourceBundleHandler(aHandler)
|
||||
else
|
||||
aHandler := nil;
|
||||
end;
|
||||
|
||||
procedure TCustomCefApp.GetBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler);
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
FCefApp.Internal_CopyBrowserProcessHandler(aHandler)
|
||||
else
|
||||
aHandler := nil;
|
||||
end;
|
||||
|
||||
procedure TCustomCefApp.GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler);
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
FCefApp.Internal_CopyRenderProcessHandler(aHandler)
|
||||
else
|
||||
aHandler := nil;
|
||||
end;
|
||||
|
||||
end.
|
@ -52,8 +52,7 @@ uses
|
||||
{$ELSE}
|
||||
Windows, Classes,
|
||||
{$ENDIF}
|
||||
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar,
|
||||
uCEFBrowserProcessHandler, uCEFResourceBundleHandler, uCEFRenderProcessHandler;
|
||||
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar;
|
||||
|
||||
const
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 3;
|
||||
@ -70,8 +69,6 @@ const
|
||||
CHROMEELF_DLL = 'chrome_elf.dll';
|
||||
|
||||
type
|
||||
TInternalApp = class;
|
||||
|
||||
TCefApplication = class
|
||||
protected
|
||||
FMustShutDown : boolean;
|
||||
@ -129,14 +126,14 @@ type
|
||||
FChromeVersionInfo : TFileVersionInfo;
|
||||
FLibHandle : THandle;
|
||||
FOnRegisterCustomSchemes : TOnRegisterCustomSchemes;
|
||||
FResourceBundleHandler : ICefResourceBundleHandler;
|
||||
FBrowserProcessHandler : ICefBrowserProcessHandler;
|
||||
FRenderProcessHandler : ICefRenderProcessHandler;
|
||||
FAppSettings : TCefSettings;
|
||||
FDeviceScaleFactor : single;
|
||||
FCheckDevToolsResources : boolean;
|
||||
FDisableGPUCache : boolean;
|
||||
FProcessType : TCefProcessType;
|
||||
FResourceBundleHandler : ICefResourceBundleHandler;
|
||||
FBrowserProcessHandler : ICefBrowserProcessHandler;
|
||||
FRenderProcessHandler : ICefRenderProcessHandler;
|
||||
|
||||
// ICefBrowserProcessHandler
|
||||
FOnContextInitializedEvent : TOnContextInitializedEvent;
|
||||
@ -168,6 +165,12 @@ type
|
||||
function GetChromeVersion : string;
|
||||
function GetLibCefPath : string;
|
||||
function GetChromeElfPath : string;
|
||||
function GetMustCreateResourceBundleHandler : boolean;
|
||||
function GetMustCreateBrowserProcessHandler : boolean;
|
||||
function GetMustCreateRenderProcessHandler : boolean;
|
||||
function GetHasResourceBundleHandler : boolean;
|
||||
function GetHasBrowserProcessHandler : boolean;
|
||||
function GetHasRenderProcessHandler : boolean;
|
||||
|
||||
function LoadCEFlibrary : boolean; virtual;
|
||||
function Load_cef_app_capi_h : boolean;
|
||||
@ -224,9 +227,6 @@ type
|
||||
procedure ShowErrorMessageDlg(const aError : string); virtual;
|
||||
function ParseProcessType : TCefProcessType;
|
||||
procedure CreateAppHandlers;
|
||||
procedure CreateBrowserProcessHandler;
|
||||
procedure CreateResourceBundleHandler;
|
||||
procedure CreateRenderProcessHandler;
|
||||
|
||||
public
|
||||
constructor Create;
|
||||
@ -241,9 +241,9 @@ type
|
||||
// ICefResourceBundleHandler and ICefRenderProcessHandler should use them.
|
||||
procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
||||
procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
||||
procedure Internal_OnGetResourceBundleHandler(var aCefResourceBundleHandler : ICefResourceBundleHandler);
|
||||
procedure Internal_OnGetBrowserProcessHandler(var aCefBrowserProcessHandler : ICefBrowserProcessHandler);
|
||||
procedure Internal_OnGetRenderProcessHandler(var aCefRenderProcessHandler : ICefRenderProcessHandler);
|
||||
procedure Internal_CopyRenderProcessHandler(var aHandler : ICefRenderProcessHandler);
|
||||
procedure Internal_CopyResourceBundleHandler(var aHandler : ICefResourceBundleHandler);
|
||||
procedure Internal_CopyBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler);
|
||||
procedure Internal_OnContextInitialized;
|
||||
procedure Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||
procedure Internal_OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||
@ -323,6 +323,15 @@ type
|
||||
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
|
||||
property CustomFlashPath : ustring read FCustomFlashPath write FCustomFlashPath;
|
||||
property ProcessType : TCefProcessType read FProcessType;
|
||||
property MustCreateResourceBundleHandler : boolean read GetMustCreateResourceBundleHandler;
|
||||
property MustCreateBrowserProcessHandler : boolean read GetMustCreateBrowserProcessHandler;
|
||||
property MustCreateRenderProcessHandler : boolean read GetMustCreateRenderProcessHandler;
|
||||
property HasResourceBundleHandler : boolean read GetHasResourceBundleHandler;
|
||||
property HasBrowserProcessHandler : boolean read GetHasBrowserProcessHandler;
|
||||
property HasRenderProcessHandler : boolean read GetHasRenderProcessHandler;
|
||||
property ResourceBundleHandler : ICefResourceBundleHandler read FResourceBundleHandler write FResourceBundleHandler;
|
||||
property BrowserProcessHandler : ICefBrowserProcessHandler read FBrowserProcessHandler write FBrowserProcessHandler;
|
||||
property RenderProcessHandler : ICefRenderProcessHandler read FRenderProcessHandler write FRenderProcessHandler;
|
||||
|
||||
property OnRegCustomSchemes : TOnRegisterCustomSchemes read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes;
|
||||
|
||||
@ -350,80 +359,6 @@ type
|
||||
property OnProcessMessageReceived : TOnProcessMessageReceivedEvent read FOnProcessMessageReceived write FOnProcessMessageReceived;
|
||||
end;
|
||||
|
||||
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
||||
protected
|
||||
procedure OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); virtual; abstract;
|
||||
procedure OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); virtual; abstract;
|
||||
function GetResourceBundleHandler: ICefResourceBundleHandler; virtual; abstract;
|
||||
function GetBrowserProcessHandler: ICefBrowserProcessHandler; virtual; abstract;
|
||||
function GetRenderProcessHandler: ICefRenderProcessHandler; virtual; abstract;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TInternalApp = class(TCefAppOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
procedure OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); override;
|
||||
procedure OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); override;
|
||||
function GetResourceBundleHandler: ICefResourceBundleHandler; override;
|
||||
function GetBrowserProcessHandler: ICefBrowserProcessHandler; override;
|
||||
function GetRenderProcessHandler: ICefRenderProcessHandler; override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefCustomBrowserProcessHandler = class(TCefBrowserProcessHandlerOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
procedure OnContextInitialized; override;
|
||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); override;
|
||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); override;
|
||||
procedure OnScheduleMessagePumpWork(const delayMs: Int64); override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefCustomResourceBundleHandler = class(TCefResourceBundleHandlerOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
function GetLocalizedString(stringid: Integer; var stringVal: ustring): Boolean; override;
|
||||
function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; override;
|
||||
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
procedure OnRenderThreadCreated(const extraInfo: ICefListValue); override;
|
||||
procedure OnWebKitInitialized; override;
|
||||
procedure OnBrowserCreated(const browser: ICefBrowser); override;
|
||||
procedure OnBrowserDestroyed(const browser: ICefBrowser); override;
|
||||
function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean; override;
|
||||
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
|
||||
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
|
||||
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); override;
|
||||
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); override;
|
||||
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage : ICefProcessMessage): Boolean; override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
var
|
||||
GlobalCEFApp : TCefApplication = nil;
|
||||
|
||||
@ -436,7 +371,8 @@ uses
|
||||
Math, {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} SysUtils, Dialogs,
|
||||
{$ENDIF}
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFCommandLine, uCEFConstants,
|
||||
uCEFSchemeHandlerFactory, uCEFCookieManager;
|
||||
uCEFSchemeHandlerFactory, uCEFCookieManager, uCEFApp,
|
||||
uCEFBrowserProcessHandler, uCEFResourceBundleHandler, uCEFRenderProcessHandler;
|
||||
|
||||
constructor TCefApplication.Create;
|
||||
begin
|
||||
@ -488,9 +424,6 @@ begin
|
||||
FFastUnload := False;
|
||||
FDisableSafeBrowsing := False;
|
||||
FOnRegisterCustomSchemes := nil;
|
||||
FResourceBundleHandler := nil;
|
||||
FBrowserProcessHandler := nil;
|
||||
FRenderProcessHandler := nil;
|
||||
FEnableHighDPISupport := False;
|
||||
FMuteAudio := False;
|
||||
FReRaiseExceptions := False;
|
||||
@ -502,6 +435,9 @@ begin
|
||||
FDisableGPUCache := False;
|
||||
FLocalesRequired := '';
|
||||
FProcessType := ParseProcessType;
|
||||
FResourceBundleHandler := nil;
|
||||
FBrowserProcessHandler := nil;
|
||||
FRenderProcessHandler := nil;
|
||||
|
||||
// ICefBrowserProcessHandler
|
||||
FOnContextInitializedEvent := nil;
|
||||
@ -561,54 +497,6 @@ begin
|
||||
FCustomCommandLineValues := TStringList.Create;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.CreateAppHandlers;
|
||||
begin
|
||||
if FSingleProcess then
|
||||
begin
|
||||
CreateBrowserProcessHandler;
|
||||
CreateResourceBundleHandler;
|
||||
CreateRenderProcessHandler;
|
||||
end
|
||||
else
|
||||
case FProcessType of
|
||||
ptBrowser :
|
||||
begin
|
||||
CreateBrowserProcessHandler;
|
||||
CreateResourceBundleHandler;
|
||||
end;
|
||||
|
||||
ptRenderer : CreateRenderProcessHandler;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.CreateBrowserProcessHandler;
|
||||
begin
|
||||
FBrowserProcessHandler := TCefCustomBrowserProcessHandler.Create(self);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.CreateResourceBundleHandler;
|
||||
begin
|
||||
if assigned(FOnGetLocalizedStringEvent) or
|
||||
assigned(FOnGetDataResourceEvent) or
|
||||
assigned(FOnGetDataResourceForScaleEvent) then
|
||||
FResourceBundleHandler := TCefCustomResourceBundleHandler.Create(self);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.CreateRenderProcessHandler;
|
||||
begin
|
||||
if assigned(FOnRenderThreadCreated) or
|
||||
assigned(FOnWebKitInitialized) or
|
||||
assigned(FOnBrowserCreated) or
|
||||
assigned(FOnBrowserDestroyed) or
|
||||
assigned(FOnBeforeNavigation) or
|
||||
assigned(FOnContextCreated) or
|
||||
assigned(FOnContextReleased) or
|
||||
assigned(FOnUncaughtException) or
|
||||
assigned(FOnFocusedNodeChanged) or
|
||||
assigned(FOnProcessMessageReceived) then
|
||||
FRenderProcessHandler := TCefCustomRenderProcessHandler.Create(self);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.AddCustomCommandLine(const aCommandLine, aValue : string);
|
||||
begin
|
||||
if (FCustomCommandLines <> nil) then FCustomCommandLines.Add(aCommandLine);
|
||||
@ -628,7 +516,7 @@ begin
|
||||
|
||||
if LoadCEFlibrary then
|
||||
begin
|
||||
TempApp := TInternalApp.Create(self);
|
||||
TempApp := TCustomCefApp.Create(self);
|
||||
Result := InitializeLibrary(TempApp);
|
||||
end;
|
||||
end;
|
||||
@ -647,7 +535,7 @@ begin
|
||||
try
|
||||
if CheckCEFLibrary and LoadCEFlibrary then
|
||||
begin
|
||||
TempApp := TInternalApp.Create(self);
|
||||
TempApp := TCustomCefApp.Create(self);
|
||||
|
||||
if (ExecuteProcess(TempApp) < 0) then
|
||||
begin
|
||||
@ -819,7 +707,7 @@ begin
|
||||
try
|
||||
if not(FSingleProcess) and LoadCEFlibrary then
|
||||
begin
|
||||
TempApp := TInternalApp.Create(self);
|
||||
TempApp := TCustomCefApp.Create(self);
|
||||
Result := (ExecuteProcess(TempApp) >= 0);
|
||||
end;
|
||||
except
|
||||
@ -1043,6 +931,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.CreateAppHandlers;
|
||||
begin
|
||||
if MustCreateBrowserProcessHandler then
|
||||
FBrowserProcessHandler := TCefCustomBrowserProcessHandler.Create(self);
|
||||
|
||||
if MustCreateResourceBundleHandler then
|
||||
FResourceBundleHandler := TCefCustomResourceBundleHandler.Create(self);
|
||||
|
||||
if MustCreateRenderProcessHandler then
|
||||
FRenderProcessHandler := TCefCustomRenderProcessHandler.Create(self);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.Internal_OnContextInitialized;
|
||||
begin
|
||||
InitializeCookies;
|
||||
@ -1109,7 +1009,10 @@ end;
|
||||
|
||||
procedure TCefApplication.Internal_OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean; var aStopNavigation : boolean);
|
||||
begin
|
||||
if assigned(FOnBeforeNavigation) then FOnBeforeNavigation(browser, frame, request, navigationType, isRedirect, aStopNavigation);
|
||||
if assigned(FOnBeforeNavigation) then
|
||||
FOnBeforeNavigation(browser, frame, request, navigationType, isRedirect, aStopNavigation)
|
||||
else
|
||||
aStopNavigation := False;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.Internal_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
@ -1134,7 +1037,10 @@ end;
|
||||
|
||||
procedure TCefApplication.Internal_OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean);
|
||||
begin
|
||||
if assigned(FOnProcessMessageReceived) then FOnProcessMessageReceived(browser, sourceProcess, aMessage, aHandled);
|
||||
if assigned(FOnProcessMessageReceived) then
|
||||
FOnProcessMessageReceived(browser, sourceProcess, aMessage, aHandled)
|
||||
else
|
||||
aHandled := False;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processType : ustring;
|
||||
@ -1220,19 +1126,76 @@ begin
|
||||
if assigned(FOnRegisterCustomSchemes) then FOnRegisterCustomSchemes(registrar);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.Internal_OnGetResourceBundleHandler(var aCefResourceBundleHandler : ICefResourceBundleHandler);
|
||||
procedure TCefApplication.Internal_CopyRenderProcessHandler(var aHandler : ICefRenderProcessHandler);
|
||||
begin
|
||||
if (FResourceBundleHandler <> nil) then aCefResourceBundleHandler := FResourceBundleHandler;
|
||||
if (FRenderProcessHandler <> nil) then
|
||||
aHandler := FRenderProcessHandler
|
||||
else
|
||||
aHandler := nil;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.Internal_OnGetBrowserProcessHandler(var aCefBrowserProcessHandler : ICefBrowserProcessHandler);
|
||||
procedure TCefApplication.Internal_CopyResourceBundleHandler(var aHandler : ICefResourceBundleHandler);
|
||||
begin
|
||||
if (FBrowserProcessHandler <> nil) then aCefBrowserProcessHandler := FBrowserProcessHandler;
|
||||
if (FResourceBundleHandler <> nil) then
|
||||
aHandler := FResourceBundleHandler
|
||||
else
|
||||
aHandler := nil;
|
||||
end;
|
||||
|
||||
procedure TCefApplication.Internal_OnGetRenderProcessHandler(var aCefRenderProcessHandler : ICefRenderProcessHandler);
|
||||
procedure TCefApplication.Internal_CopyBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler);
|
||||
begin
|
||||
if (FRenderProcessHandler <> nil) then aCefRenderProcessHandler := FRenderProcessHandler;
|
||||
if (FBrowserProcessHandler <> nil) then
|
||||
aHandler := FBrowserProcessHandler
|
||||
else
|
||||
aHandler := nil;
|
||||
end;
|
||||
|
||||
function TCefApplication.GetMustCreateResourceBundleHandler : boolean;
|
||||
begin
|
||||
Result := not(HasResourceBundleHandler) and
|
||||
(FSingleProcess or
|
||||
((FProcessType = ptBrowser) and
|
||||
(assigned(FOnGetLocalizedStringEvent) or
|
||||
assigned(FOnGetDataResourceEvent) or
|
||||
assigned(FOnGetDataResourceForScaleEvent))));
|
||||
end;
|
||||
|
||||
function TCefApplication.GetMustCreateBrowserProcessHandler : boolean;
|
||||
begin
|
||||
Result := not(HasBrowserProcessHandler) and
|
||||
(FSingleProcess or (FProcessType = ptBrowser));
|
||||
end;
|
||||
|
||||
function TCefApplication.GetMustCreateRenderProcessHandler : boolean;
|
||||
begin
|
||||
Result := not(HasRenderProcessHandler) and
|
||||
(FSingleProcess or
|
||||
((FProcessType = ptRenderer) and
|
||||
(assigned(FOnRenderThreadCreated) or
|
||||
assigned(FOnWebKitInitialized) or
|
||||
assigned(FOnBrowserCreated) or
|
||||
assigned(FOnBrowserDestroyed) or
|
||||
assigned(FOnBeforeNavigation) or
|
||||
assigned(FOnContextCreated) or
|
||||
assigned(FOnContextReleased) or
|
||||
assigned(FOnUncaughtException) or
|
||||
assigned(FOnFocusedNodeChanged) or
|
||||
assigned(FOnProcessMessageReceived))));
|
||||
end;
|
||||
|
||||
function TCefApplication.GetHasResourceBundleHandler : boolean;
|
||||
begin
|
||||
Result := (FResourceBundleHandler <> nil);
|
||||
end;
|
||||
|
||||
function TCefApplication.GetHasBrowserProcessHandler : boolean;
|
||||
begin
|
||||
Result := (FBrowserProcessHandler <> nil);
|
||||
end;
|
||||
|
||||
function TCefApplication.GetHasRenderProcessHandler : boolean;
|
||||
begin
|
||||
Result := (FRenderProcessHandler <> nil);
|
||||
end;
|
||||
|
||||
function TCefApplication.LoadCEFlibrary : boolean;
|
||||
@ -1844,307 +1807,4 @@ begin
|
||||
assigned(cef_trace_event_async_end);
|
||||
end;
|
||||
|
||||
|
||||
// TCefAppOwn
|
||||
|
||||
procedure cef_app_on_before_command_line_processing(self: PCefApp;
|
||||
const process_type: PCefString;
|
||||
command_line: PCefCommandLine); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
TCefAppOwn(TempObject).OnBeforeCommandLineProcessing(CefString(process_type), TCefCommandLineRef.UnWrap(command_line));
|
||||
end;
|
||||
|
||||
procedure cef_app_on_register_custom_schemes(self: PCefApp; registrar: PCefSchemeRegistrar); stdcall;
|
||||
var
|
||||
TempWrapper : TCefSchemeRegistrarRef;
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempWrapper := nil;
|
||||
|
||||
try
|
||||
try
|
||||
TempWrapper := TCefSchemeRegistrarRef.Create(registrar);
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
TCefAppOwn(TempObject).OnRegisterCustomSchemes(TempWrapper);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('cef_app_on_register_custom_schemes', e) then raise;
|
||||
end;
|
||||
finally
|
||||
if (TempWrapper <> nil) then FreeAndNil(TempWrapper);
|
||||
end;
|
||||
end;
|
||||
|
||||
function cef_app_get_resource_bundle_handler(self: PCefApp): PCefResourceBundleHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
Result := CefGetData(TCefAppOwn(TempObject).GetResourceBundleHandler)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function cef_app_get_browser_process_handler(self: PCefApp): PCefBrowserProcessHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
Result := CefGetData(TCefAppOwn(TempObject).GetBrowserProcessHandler)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function cef_app_get_render_process_handler(self: PCefApp): PCefRenderProcessHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefAppOwn) then
|
||||
Result := CefGetData(TCefAppOwn(TempObject).GetRenderProcessHandler)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
||||
constructor TCefAppOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefApp));
|
||||
|
||||
with PCefApp(FData)^ do
|
||||
begin
|
||||
on_before_command_line_processing := cef_app_on_before_command_line_processing;
|
||||
on_register_custom_schemes := cef_app_on_register_custom_schemes;
|
||||
get_resource_bundle_handler := cef_app_get_resource_bundle_handler;
|
||||
get_browser_process_handler := cef_app_get_browser_process_handler;
|
||||
get_render_process_handler := cef_app_get_render_process_handler;
|
||||
end;
|
||||
end;
|
||||
|
||||
// TInternalApp
|
||||
|
||||
procedure TInternalApp.OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBeforeCommandLineProcessing(processType, commandLine);
|
||||
end;
|
||||
|
||||
procedure TInternalApp.OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnRegisterCustomSchemes(registrar);
|
||||
end;
|
||||
|
||||
function TInternalApp.GetResourceBundleHandler: ICefResourceBundleHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnGetResourceBundleHandler(Result);
|
||||
end;
|
||||
|
||||
function TInternalApp.GetBrowserProcessHandler: ICefBrowserProcessHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnGetBrowserProcessHandler(Result);
|
||||
end;
|
||||
|
||||
function TInternalApp.GetRenderProcessHandler: ICefRenderProcessHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnGetRenderProcessHandler(Result);
|
||||
end;
|
||||
|
||||
constructor TInternalApp.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
destructor TInternalApp.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
// TCefCustomBrowserProcessHandler
|
||||
|
||||
constructor TCefCustomBrowserProcessHandler.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
destructor TCefCustomBrowserProcessHandler.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnContextInitialized;
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnContextInitialized;
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBeforeChildProcessLaunch(commandLine);
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnRenderProcessThreadCreated(extraInfo);
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnScheduleMessagePumpWork(delayMs);
|
||||
end;
|
||||
|
||||
// TCefCustomResourceBundleHandler
|
||||
|
||||
constructor TCefCustomResourceBundleHandler.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
destructor TCefCustomResourceBundleHandler.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TCefCustomResourceBundleHandler.GetLocalizedString(stringid : Integer;
|
||||
var stringVal : ustring): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
Result := FCefApp.Internal_GetLocalizedString(stringid, stringVal)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TCefCustomResourceBundleHandler.GetDataResource(resourceId : Integer;
|
||||
var data : Pointer;
|
||||
var dataSize : NativeUInt): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
Result := FCefApp.Internal_GetDataResource(resourceId, data, dataSize)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TCefCustomResourceBundleHandler.GetDataResourceForScale(resourceId : Integer;
|
||||
scaleFactor : TCefScaleFactor;
|
||||
var data : Pointer;
|
||||
var dataSize : NativeUInt): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
Result := FCefApp.Internal_GetDataResourceForScale(resourceId, scaleFactor, data, dataSize)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
// TCefCustomRenderProcessHandler
|
||||
|
||||
constructor TCefCustomRenderProcessHandler.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
destructor TCefCustomRenderProcessHandler.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnRenderThreadCreated(const extraInfo: ICefListValue);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnRenderThreadCreated(extraInfo);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnWebKitInitialized;
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnWebKitInitialized;
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnBrowserCreated(const browser: ICefBrowser);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBrowserCreated(browser);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnBrowserDestroyed(const browser: ICefBrowser);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBrowserDestroyed(browser);
|
||||
end;
|
||||
|
||||
function TCefCustomRenderProcessHandler.OnBeforeNavigation(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const request : ICefRequest;
|
||||
navigationType : TCefNavigationType;
|
||||
isRedirect : Boolean): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
FCefApp.Internal_OnBeforeNavigation(browser, frame, request, navigationType, isRedirect, Result)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const context : ICefv8Context);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnContextCreated(browser, frame, context);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnContextReleased(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const context : ICefv8Context);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnContextReleased(browser, frame, context);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnUncaughtException(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const context : ICefv8Context;
|
||||
const exception : ICefV8Exception;
|
||||
const stackTrace : ICefV8StackTrace);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnUncaughtException(browser, frame, context, exception, stackTrace);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnFocusedNodeChanged(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const node : ICefDomNode);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnFocusedNodeChanged(browser, frame, node);
|
||||
end;
|
||||
|
||||
function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser : ICefBrowser;
|
||||
sourceProcess : TCefProcessId;
|
||||
const aMessage : ICefProcessMessage): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
FCefApp.Internal_OnProcessMessageReceived(browser, sourceProcess, aMessage, Result)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -55,7 +55,7 @@ type
|
||||
FData: Pointer;
|
||||
|
||||
public
|
||||
constructor CreateData(size: Cardinal; owned: Boolean = False); virtual;
|
||||
constructor CreateData(size: Cardinal; owned : boolean = False); virtual;
|
||||
destructor Destroy; override;
|
||||
function Wrap: Pointer;
|
||||
end;
|
||||
@ -88,7 +88,7 @@ begin
|
||||
TCefBaseRefCountedOwn(TempObject)._AddRef;
|
||||
end;
|
||||
|
||||
function cef_base_release(self: PCefBaseRefCounted): Integer; stdcall;
|
||||
function cef_base_release_ref(self: PCefBaseRefCounted): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
@ -127,7 +127,7 @@ begin
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
constructor TCefBaseRefCountedOwn.CreateData(size: Cardinal; owned: Boolean);
|
||||
constructor TCefBaseRefCountedOwn.CreateData(size: Cardinal; owned : boolean);
|
||||
begin
|
||||
GetMem(FData, size + SizeOf(Pointer));
|
||||
PPointer(FData)^ := Self;
|
||||
@ -144,7 +144,7 @@ begin
|
||||
else
|
||||
begin
|
||||
PCefBaseRefCounted(FData)^.add_ref := cef_base_add_ref;
|
||||
PCefBaseRefCounted(FData)^.release := cef_base_release;
|
||||
PCefBaseRefCounted(FData)^.release := cef_base_release_ref;
|
||||
PCefBaseRefCounted(FData)^.has_one_ref := cef_base_has_one_ref;
|
||||
end;
|
||||
end;
|
||||
|
@ -47,48 +47,93 @@ unit uCEFBrowserProcessHandler;
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplication;
|
||||
|
||||
type
|
||||
TCefBrowserProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefBrowserProcessHandler)
|
||||
protected
|
||||
procedure OnContextInitialized; virtual;
|
||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); virtual;
|
||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); virtual;
|
||||
procedure OnScheduleMessagePumpWork(const delayMs: Int64); virtual;
|
||||
procedure OnContextInitialized; virtual; abstract;
|
||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); virtual; abstract;
|
||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); virtual; abstract;
|
||||
function GetPrintHandler : ICefPrintHandler; virtual;
|
||||
procedure OnScheduleMessagePumpWork(const delayMs: Int64); virtual; abstract;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCefCustomBrowserProcessHandler = class(TCefBrowserProcessHandlerOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
procedure OnContextInitialized; override;
|
||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); override;
|
||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); override;
|
||||
procedure OnScheduleMessagePumpWork(const delayMs: Int64); override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFCommandLine, uCEFListValue;
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFCommandLine, uCEFListValue, uCEFConstants;
|
||||
|
||||
procedure cef_browser_process_handler_on_context_initialized(self: PCefBrowserProcessHandler); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefBrowserProcessHandlerOwn(CefGetObject(self)) do
|
||||
OnContextInitialized;
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then
|
||||
TCefBrowserProcessHandlerOwn(TempObject).OnContextInitialized;
|
||||
end;
|
||||
|
||||
procedure cef_browser_process_handler_on_before_child_process_launch(
|
||||
self: PCefBrowserProcessHandler; command_line: PCefCommandLine); stdcall;
|
||||
procedure cef_browser_process_handler_on_before_child_process_launch(self : PCefBrowserProcessHandler;
|
||||
command_line : PCefCommandLine); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefBrowserProcessHandlerOwn(CefGetObject(self)) do
|
||||
OnBeforeChildProcessLaunch(TCefCommandLineRef.UnWrap(command_line));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then
|
||||
TCefBrowserProcessHandlerOwn(TempObject).OnBeforeChildProcessLaunch(TCefCommandLineRef.UnWrap(command_line));
|
||||
end;
|
||||
|
||||
procedure cef_browser_process_handler_on_render_process_thread_created(
|
||||
self: PCefBrowserProcessHandler; extra_info: PCefListValue); stdcall;
|
||||
procedure cef_browser_process_handler_on_render_process_thread_created(self : PCefBrowserProcessHandler;
|
||||
extra_info : PCefListValue); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefBrowserProcessHandlerOwn(CefGetObject(self)) do
|
||||
OnRenderProcessThreadCreated(TCefListValueRef.UnWrap(extra_info));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then
|
||||
TCefBrowserProcessHandlerOwn(TempObject).OnRenderProcessThreadCreated(TCefListValueRef.UnWrap(extra_info));
|
||||
end;
|
||||
|
||||
procedure cef_browser_process_handler_on_schedule_message_pump_work(self: PCefBrowserProcessHandler; delay_ms: Int64); stdcall;
|
||||
function cef_browser_process_handler_get_print_handler(self: PCefBrowserProcessHandler): PCefPrintHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TCefBrowserProcessHandlerOwn(CefGetObject(self)).OnScheduleMessagePumpWork(delay_ms);
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then
|
||||
Result := CefGetData(TCefBrowserProcessHandlerOwn(TempObject).GetPrintHandler)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure cef_browser_process_handler_on_schedule_message_pump_work(self : PCefBrowserProcessHandler;
|
||||
delay_ms : Int64); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then
|
||||
TCefBrowserProcessHandlerOwn(TempObject).OnScheduleMessagePumpWork(delay_ms);
|
||||
end;
|
||||
|
||||
constructor TCefBrowserProcessHandlerOwn.Create;
|
||||
@ -100,29 +145,52 @@ begin
|
||||
on_context_initialized := cef_browser_process_handler_on_context_initialized;
|
||||
on_before_child_process_launch := cef_browser_process_handler_on_before_child_process_launch;
|
||||
on_render_process_thread_created := cef_browser_process_handler_on_render_process_thread_created;
|
||||
get_print_handler := nil; // linux
|
||||
get_print_handler := cef_browser_process_handler_get_print_handler;
|
||||
on_schedule_message_pump_work := cef_browser_process_handler_on_schedule_message_pump_work;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserProcessHandlerOwn.OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||
function TCefBrowserProcessHandlerOwn.GetPrintHandler : ICefPrintHandler;
|
||||
begin
|
||||
|
||||
Result := nil; // only linux
|
||||
end;
|
||||
|
||||
procedure TCefBrowserProcessHandlerOwn.OnContextInitialized;
|
||||
begin
|
||||
|
||||
// TCefCustomBrowserProcessHandler
|
||||
|
||||
|
||||
constructor TCefCustomBrowserProcessHandler.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserProcessHandlerOwn.OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||
destructor TCefCustomBrowserProcessHandler.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserProcessHandlerOwn.OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||
procedure TCefCustomBrowserProcessHandler.OnContextInitialized;
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnContextInitialized;
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBeforeChildProcessLaunch(commandLine);
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnRenderProcessThreadCreated(extraInfo);
|
||||
end;
|
||||
|
||||
procedure TCefCustomBrowserProcessHandler.OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnScheduleMessagePumpWork(delayMs);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -92,7 +92,7 @@ end;
|
||||
|
||||
constructor TCefDragHandlerOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefDragHandler), False);
|
||||
CreateData(SizeOf(TCefDragHandler));
|
||||
with PCefDragHandler(FData)^ do
|
||||
begin
|
||||
on_drag_enter := cef_drag_handler_on_drag_enter;
|
||||
|
@ -82,7 +82,7 @@ end;
|
||||
|
||||
constructor TCefFindHandlerOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefFindHandler), False);
|
||||
CreateData(SizeOf(TCefFindHandler));
|
||||
|
||||
with PCefFindHandler(FData)^ do on_find_result := cef_find_handler_on_find_result;
|
||||
end;
|
||||
|
@ -101,6 +101,7 @@ type
|
||||
ICefExtensionHandler = interface;
|
||||
ICefExtension = interface;
|
||||
ICefStreamReader = interface;
|
||||
ICefLoadHandler = interface;
|
||||
|
||||
TCefv8ValueArray = array of ICefv8Value;
|
||||
TCefX509CertificateArray = array of ICefX509Certificate;
|
||||
@ -828,13 +829,6 @@ type
|
||||
count, total: Integer; out deleteCookie: Boolean): Boolean;
|
||||
end;
|
||||
|
||||
ICefResourceBundleHandler = interface(ICefBaseRefCounted)
|
||||
['{09C264FD-7E03-41E3-87B3-4234E82B5EA2}']
|
||||
function GetLocalizedString(stringId: Integer; var stringVal: ustring): Boolean;
|
||||
function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean;
|
||||
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean;
|
||||
end;
|
||||
|
||||
ICefCommandLine = interface(ICefBaseRefCounted)
|
||||
['{6B43D21B-0F2C-4B94-B4E6-4AF0D7669D8E}']
|
||||
function IsValid: Boolean;
|
||||
@ -860,11 +854,19 @@ type
|
||||
property CommandLineString: ustring read GetCommandLineString;
|
||||
end;
|
||||
|
||||
ICefResourceBundleHandler = interface(ICefBaseRefCounted)
|
||||
['{09C264FD-7E03-41E3-87B3-4234E82B5EA2}']
|
||||
function GetLocalizedString(stringId: Integer; var stringVal: ustring): Boolean;
|
||||
function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean;
|
||||
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean;
|
||||
end;
|
||||
|
||||
ICefBrowserProcessHandler = interface(ICefBaseRefCounted)
|
||||
['{27291B7A-C0AE-4EE0-9115-15C810E22F6C}']
|
||||
procedure OnContextInitialized;
|
||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||
function GetPrintHandler : ICefPrintHandler;
|
||||
procedure OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||
end;
|
||||
|
||||
@ -874,20 +876,22 @@ type
|
||||
procedure OnWebKitInitialized;
|
||||
procedure OnBrowserCreated(const browser: ICefBrowser);
|
||||
procedure OnBrowserDestroyed(const browser: ICefBrowser);
|
||||
function GetLoadHandler : ICefLoadHandler;
|
||||
function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean;
|
||||
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
|
||||
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace);
|
||||
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode);
|
||||
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean;
|
||||
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean;
|
||||
end;
|
||||
|
||||
ICefApp = interface(ICefBaseRefCounted)
|
||||
['{970CA670-9070-4642-B188-7D8A22DAEED4}']
|
||||
procedure OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
||||
procedure OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
||||
function GetResourceBundleHandler: ICefResourceBundleHandler;
|
||||
function GetBrowserProcessHandler: ICefBrowserProcessHandler;
|
||||
function GetRenderProcessHandler: ICefRenderProcessHandler;
|
||||
procedure GetResourceBundleHandler(var aHandler : ICefResourceBundleHandler);
|
||||
procedure GetBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler);
|
||||
procedure GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler);
|
||||
end;
|
||||
|
||||
TCefCookieVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(
|
||||
|
@ -119,7 +119,7 @@ end;
|
||||
|
||||
constructor TCefMenuModelDelegateOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefMenuModelDelegate), False);
|
||||
CreateData(SizeOf(TCefMenuModelDelegate));
|
||||
|
||||
with PCefMenuModelDelegate(FData)^ do
|
||||
begin
|
||||
|
@ -83,7 +83,7 @@ end;
|
||||
|
||||
constructor TCefNavigationEntryVisitorOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefNavigationEntryVisitor), False);
|
||||
CreateData(SizeOf(TCefNavigationEntryVisitor));
|
||||
with PCefNavigationEntryVisitor(FData)^ do
|
||||
visit := cef_navigation_entry_visitor_visit;
|
||||
end;
|
||||
|
@ -90,7 +90,7 @@ end;
|
||||
|
||||
constructor TCefPdfPrintCallbackOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefPdfPrintCallback), False);
|
||||
CreateData(SizeOf(TCefPdfPrintCallback));
|
||||
|
||||
PCefPdfPrintCallback(FData).on_pdf_print_finished := cef_pdf_print_callback_on_pdf_print_finished;
|
||||
end;
|
||||
|
@ -209,7 +209,7 @@ end;
|
||||
|
||||
constructor TCefRenderHandlerOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefRenderHandler), False);
|
||||
CreateData(SizeOf(TCefRenderHandler));
|
||||
|
||||
with PCefRenderHandler(FData)^ do
|
||||
begin
|
||||
|
@ -53,111 +53,206 @@ uses
|
||||
Classes,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFListValue, uCEFBrowser, uCEFFrame, uCEFRequest,
|
||||
uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage;
|
||||
uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage, uCEFApplication;
|
||||
|
||||
type
|
||||
TCefRenderProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefRenderProcessHandler)
|
||||
protected
|
||||
procedure OnRenderThreadCreated(const extraInfo: ICefListValue); virtual;
|
||||
procedure OnWebKitInitialized; virtual;
|
||||
procedure OnBrowserCreated(const browser: ICefBrowser); virtual;
|
||||
procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual;
|
||||
function GetLoadHandler: PCefLoadHandler; virtual;
|
||||
procedure OnRenderThreadCreated(const extraInfo: ICefListValue); virtual; abstract;
|
||||
procedure OnWebKitInitialized; virtual; abstract;
|
||||
procedure OnBrowserCreated(const browser: ICefBrowser); virtual; abstract;
|
||||
procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual; abstract;
|
||||
function GetLoadHandler: ICefLoadHandler; virtual;
|
||||
function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean; virtual;
|
||||
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual;
|
||||
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual;
|
||||
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual;
|
||||
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual;
|
||||
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; virtual;
|
||||
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; abstract;
|
||||
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; abstract;
|
||||
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual; abstract;
|
||||
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual; abstract;
|
||||
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual;
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
procedure OnRenderThreadCreated(const extraInfo: ICefListValue); override;
|
||||
procedure OnWebKitInitialized; override;
|
||||
procedure OnBrowserCreated(const browser: ICefBrowser); override;
|
||||
procedure OnBrowserDestroyed(const browser: ICefBrowser); override;
|
||||
function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean; override;
|
||||
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
|
||||
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
|
||||
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); override;
|
||||
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); override;
|
||||
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage : ICefProcessMessage): Boolean; override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions;
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants;
|
||||
|
||||
procedure cef_render_process_handler_on_render_thread_created(self: PCefRenderProcessHandler; extra_info: PCefListValue); stdcall;
|
||||
procedure cef_render_process_handler_on_render_thread_created(self : PCefRenderProcessHandler;
|
||||
extra_info : PCefListValue); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnRenderThreadCreated(TCefListValueRef.UnWrap(extra_info));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnRenderThreadCreated(TCefListValueRef.UnWrap(extra_info));
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_web_kit_initialized(self: PCefRenderProcessHandler); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnWebKitInitialized;
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnWebKitInitialized;
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_browser_created(self: PCefRenderProcessHandler; browser: PCefBrowser); stdcall;
|
||||
procedure cef_render_process_handler_on_browser_created(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnBrowserCreated(TCefBrowserRef.UnWrap(browser));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnBrowserCreated(TCefBrowserRef.UnWrap(browser));
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_browser_destroyed(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser); stdcall;
|
||||
procedure cef_render_process_handler_on_browser_destroyed(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnBrowserDestroyed(TCefBrowserRef.UnWrap(browser));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnBrowserDestroyed(TCefBrowserRef.UnWrap(browser));
|
||||
end;
|
||||
|
||||
function cef_render_process_handler_get_load_handler(self: PCefRenderProcessHandler): PCefLoadHandler; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
Result := GetLoadHandler();
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
Result := CefGetData(TCefRenderProcessHandlerOwn(TempObject).GetLoadHandler)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function cef_render_process_handler_on_before_navigation(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser; frame: PCefFrame; request: PCefRequest;
|
||||
navigation_type: TCefNavigationType; is_redirect: Integer): Integer; stdcall;
|
||||
function cef_render_process_handler_on_before_navigation(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser;
|
||||
frame : PCefFrame;
|
||||
request : PCefRequest;
|
||||
navigation_type : TCefNavigationType;
|
||||
is_redirect : Integer): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
Result := Ord(OnBeforeNavigation(TCefBrowserRef.UnWrap(browser),
|
||||
TCefFrameRef.UnWrap(frame), TCefRequestRef.UnWrap(request),
|
||||
navigation_type, is_redirect <> 0));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
Result := Ord(TCefRenderProcessHandlerOwn(TempObject).OnBeforeNavigation(TCefBrowserRef.UnWrap(browser),
|
||||
TCefFrameRef.UnWrap(frame),
|
||||
TCefRequestRef.UnWrap(request),
|
||||
navigation_type,
|
||||
is_redirect <> 0))
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_context_created(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall;
|
||||
procedure cef_render_process_handler_on_context_created(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser;
|
||||
frame : PCefFrame;
|
||||
context : PCefv8Context); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnContextCreated(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnContextCreated(TCefBrowserRef.UnWrap(browser),
|
||||
TCefFrameRef.UnWrap(frame),
|
||||
TCefv8ContextRef.UnWrap(context));
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_context_released(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall;
|
||||
procedure cef_render_process_handler_on_context_released(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser;
|
||||
frame : PCefFrame;
|
||||
context : PCefv8Context); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnContextReleased(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnContextReleased(TCefBrowserRef.UnWrap(browser),
|
||||
TCefFrameRef.UnWrap(frame),
|
||||
TCefv8ContextRef.UnWrap(context));
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_uncaught_exception(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context;
|
||||
exception: PCefV8Exception; stackTrace: PCefV8StackTrace); stdcall;
|
||||
procedure cef_render_process_handler_on_uncaught_exception(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser;
|
||||
frame : PCefFrame;
|
||||
context : PCefv8Context;
|
||||
exception : PCefV8Exception;
|
||||
stackTrace : PCefV8StackTrace); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnUncaughtException(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame),
|
||||
TCefv8ContextRef.UnWrap(context), TCefV8ExceptionRef.UnWrap(exception),
|
||||
TCefV8StackTraceRef.UnWrap(stackTrace));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnUncaughtException(TCefBrowserRef.UnWrap(browser),
|
||||
TCefFrameRef.UnWrap(frame),
|
||||
TCefv8ContextRef.UnWrap(context),
|
||||
TCefV8ExceptionRef.UnWrap(exception),
|
||||
TCefV8StackTraceRef.UnWrap(stackTrace));
|
||||
end;
|
||||
|
||||
procedure cef_render_process_handler_on_focused_node_changed(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser; frame: PCefFrame; node: PCefDomNode); stdcall;
|
||||
procedure cef_render_process_handler_on_focused_node_changed(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser;
|
||||
frame : PCefFrame;
|
||||
node : PCefDomNode); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
OnFocusedNodeChanged(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame),
|
||||
TCefDomNodeRef.UnWrap(node));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
TCefRenderProcessHandlerOwn(TempObject).OnFocusedNodeChanged(TCefBrowserRef.UnWrap(browser),
|
||||
TCefFrameRef.UnWrap(frame),
|
||||
TCefDomNodeRef.UnWrap(node));
|
||||
end;
|
||||
|
||||
function cef_render_process_handler_on_process_message_received(self: PCefRenderProcessHandler;
|
||||
browser: PCefBrowser; source_process: TCefProcessId;
|
||||
message: PCefProcessMessage): Integer; stdcall;
|
||||
function cef_render_process_handler_on_process_message_received(self : PCefRenderProcessHandler;
|
||||
browser : PCefBrowser;
|
||||
source_process : TCefProcessId;
|
||||
message_ : PCefProcessMessage): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
with TCefRenderProcessHandlerOwn(CefGetObject(Self)) do
|
||||
Result := Ord(OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser), source_process,
|
||||
TCefProcessMessageRef.UnWrap(message)));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then
|
||||
Result := Ord(TCefRenderProcessHandlerOwn(TempObject).OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser),
|
||||
source_process,
|
||||
TCefProcessMessageRef.UnWrap(message_)))
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
|
||||
@ -184,74 +279,113 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCefRenderProcessHandlerOwn.GetLoadHandler: PCefLoadHandler;
|
||||
function TCefRenderProcessHandlerOwn.GetLoadHandler: ICefLoadHandler;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCefRenderProcessHandlerOwn.OnBeforeNavigation(
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const request: ICefRequest; navigationType: TCefNavigationType;
|
||||
isRedirect: Boolean): Boolean;
|
||||
function TCefRenderProcessHandlerOwn.OnBeforeNavigation(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const request : ICefRequest;
|
||||
navigationType : TCefNavigationType;
|
||||
isRedirect : Boolean): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnBrowserCreated(
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnBrowserDestroyed(
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnContextCreated(
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const context: ICefv8Context);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnContextReleased(
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const context: ICefv8Context);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnFocusedNodeChanged(
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
function TCefRenderProcessHandlerOwn.OnProcessMessageReceived(
|
||||
const browser: ICefBrowser; sourceProcess: TCefProcessId;
|
||||
const message: ICefProcessMessage): Boolean;
|
||||
function TCefRenderProcessHandlerOwn.OnProcessMessageReceived(const browser : ICefBrowser;
|
||||
sourceProcess : TCefProcessId;
|
||||
const aMessage : ICefProcessMessage): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnRenderThreadCreated(const extraInfo: ICefListValue);
|
||||
begin
|
||||
|
||||
// TCefCustomRenderProcessHandler
|
||||
|
||||
|
||||
constructor TCefCustomRenderProcessHandler.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnUncaughtException(
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const context: ICefv8Context; const exception: ICefV8Exception;
|
||||
const stackTrace: ICefV8StackTrace);
|
||||
destructor TCefCustomRenderProcessHandler.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCefRenderProcessHandlerOwn.OnWebKitInitialized;
|
||||
procedure TCefCustomRenderProcessHandler.OnRenderThreadCreated(const extraInfo: ICefListValue);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnRenderThreadCreated(extraInfo);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnWebKitInitialized;
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnWebKitInitialized;
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnBrowserCreated(const browser: ICefBrowser);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBrowserCreated(browser);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnBrowserDestroyed(const browser: ICefBrowser);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBrowserDestroyed(browser);
|
||||
end;
|
||||
|
||||
function TCefCustomRenderProcessHandler.OnBeforeNavigation(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const request : ICefRequest;
|
||||
navigationType : TCefNavigationType;
|
||||
isRedirect : Boolean): Boolean;
|
||||
begin
|
||||
Result := inherited OnBeforeNavigation(browser, frame, request, navigationType, isRedirect);
|
||||
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnBeforeNavigation(browser, frame, request, navigationType, isRedirect, Result);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const context : ICefv8Context);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnContextCreated(browser, frame, context);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnContextReleased(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const context : ICefv8Context);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnContextReleased(browser, frame, context);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnUncaughtException(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const context : ICefv8Context;
|
||||
const exception : ICefV8Exception;
|
||||
const stackTrace : ICefV8StackTrace);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnUncaughtException(browser, frame, context, exception, stackTrace);
|
||||
end;
|
||||
|
||||
procedure TCefCustomRenderProcessHandler.OnFocusedNodeChanged(const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const node : ICefDomNode);
|
||||
begin
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnFocusedNodeChanged(browser, frame, node);
|
||||
end;
|
||||
|
||||
function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser : ICefBrowser;
|
||||
sourceProcess : TCefProcessId;
|
||||
const aMessage : ICefProcessMessage): Boolean;
|
||||
begin
|
||||
Result := inherited OnProcessMessageReceived(browser, sourceProcess, aMessage);
|
||||
|
||||
if (FCefApp <> nil) then FCefApp.Internal_OnProcessMessageReceived(browser, sourceProcess, aMessage, Result);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -117,7 +117,7 @@ end;
|
||||
|
||||
constructor TCefRequestContextHandlerOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefRequestContextHandler), False);
|
||||
CreateData(SizeOf(TCefRequestContextHandler));
|
||||
|
||||
with PCefRequestContextHandler(FData)^ do
|
||||
begin
|
||||
|
@ -114,7 +114,7 @@ end;
|
||||
|
||||
constructor TCefResolveCallbackOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefResolveCallback), False);
|
||||
CreateData(SizeOf(TCefResolveCallback));
|
||||
|
||||
with PCefResolveCallback(FData)^ do
|
||||
on_resolve_completed := cef_resolve_callback_on_resolve_completed;
|
||||
|
@ -47,7 +47,7 @@ unit uCEFResourceBundleHandler;
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplication;
|
||||
|
||||
type
|
||||
TCefResourceBundleHandlerOwn = class(TCefBaseRefCountedOwn, ICefResourceBundleHandler)
|
||||
@ -60,28 +60,57 @@ type
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCefCustomResourceBundleHandler = class(TCefResourceBundleHandlerOwn)
|
||||
protected
|
||||
FCefApp : TCefApplication;
|
||||
|
||||
function GetLocalizedString(stringid: Integer; var stringVal: ustring): Boolean; override;
|
||||
function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; override;
|
||||
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; override;
|
||||
|
||||
public
|
||||
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions;
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants;
|
||||
|
||||
function cef_resource_bundle_handler_get_localized_string(self : PCefResourceBundleHandler;
|
||||
string_id : Integer;
|
||||
string_val : PCefString): Integer; stdcall;
|
||||
var
|
||||
str: ustring;
|
||||
TempString : ustring;
|
||||
TempObject : TObject;
|
||||
begin
|
||||
Result := Ord(TCefResourceBundleHandlerOwn(CefGetObject(self)).GetLocalizedString(string_id, str));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (Result <> 0) then string_val^ := CefString(str);
|
||||
if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then
|
||||
begin
|
||||
TempString := '';
|
||||
Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetLocalizedString(string_id, TempString));
|
||||
|
||||
if (Result <> 0) then string_val^ := CefString(TempString);
|
||||
end
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function cef_resource_bundle_handler_get_data_resource(self : PCefResourceBundleHandler;
|
||||
resource_id : Integer;
|
||||
var data : Pointer;
|
||||
var data_size : NativeUInt): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
Result := Ord(TCefResourceBundleHandlerOwn(CefGetObject(self)).GetDataResource(resource_id, data, data_size));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then
|
||||
Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetDataResource(resource_id, data, data_size))
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function cef_resource_bundle_handler_get_data_resource_for_scale(self: PCefResourceBundleHandler;
|
||||
@ -89,8 +118,15 @@ function cef_resource_bundle_handler_get_data_resource_for_scale(self: PCefResou
|
||||
scale_factor : TCefScaleFactor;
|
||||
var data : Pointer;
|
||||
var data_size : NativeUInt): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
Result := Ord(TCefResourceBundleHandlerOwn(CefGetObject(self)).GetDataResourceForScale(resource_id, scale_factor, data, data_size));
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then
|
||||
Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetDataResourceForScale(resource_id, scale_factor, data, data_size))
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
constructor TCefResourceBundleHandlerOwn.Create;
|
||||
@ -105,4 +141,52 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// TCefCustomResourceBundleHandler
|
||||
|
||||
|
||||
constructor TCefCustomResourceBundleHandler.Create(const aCefApp : TCefApplication);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FCefApp := aCefApp;
|
||||
end;
|
||||
|
||||
destructor TCefCustomResourceBundleHandler.Destroy;
|
||||
begin
|
||||
FCefApp := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TCefCustomResourceBundleHandler.GetLocalizedString(stringid : Integer;
|
||||
var stringVal : ustring): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
Result := FCefApp.Internal_GetLocalizedString(stringid, stringVal)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TCefCustomResourceBundleHandler.GetDataResource(resourceId : Integer;
|
||||
var data : Pointer;
|
||||
var dataSize : NativeUInt): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
Result := FCefApp.Internal_GetDataResource(resourceId, data, dataSize)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TCefCustomResourceBundleHandler.GetDataResourceForScale(resourceId : Integer;
|
||||
scaleFactor : TCefScaleFactor;
|
||||
var data : Pointer;
|
||||
var dataSize : NativeUInt): Boolean;
|
||||
begin
|
||||
if (FCefApp <> nil) then
|
||||
Result := FCefApp.Internal_GetDataResourceForScale(resourceId, scaleFactor, data, dataSize)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -78,7 +78,7 @@ end;
|
||||
|
||||
constructor TCefResponseFilterOwn.Create;
|
||||
begin
|
||||
CreateData(SizeOf(TCefResponseFilter), False);
|
||||
CreateData(SizeOf(TCefResponseFilter));
|
||||
with PCefResponseFilter(FData)^ do
|
||||
begin
|
||||
init_filter := cef_response_filter_init_filter;
|
||||
|
@ -1542,7 +1542,7 @@ type
|
||||
on_context_released: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall;
|
||||
on_uncaught_exception: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context; exception: PCefV8Exception; stackTrace: PCefV8StackTrace); stdcall;
|
||||
on_focused_node_changed: procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; node: PCefDomNode); stdcall;
|
||||
on_process_message_received: function(self: PCefRenderProcessHandler; browser: PCefBrowser; source_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall;
|
||||
on_process_message_received: function(self: PCefRenderProcessHandler; browser: PCefBrowser; source_process: TCefProcessId; message_: PCefProcessMessage): Integer; stdcall;
|
||||
end;
|
||||
|
||||
// /include/capi/cef_request_handler_capi.h (cef_request_handler_t)
|
||||
|
Loading…
Reference in New Issue
Block a user