1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-22 22:17:48 +02:00
Files
.github
bin
demos
Delphi_FMX_Linux
Delphi_FMX_Mac
Delphi_FMX_Windows
Delphi_VCL
Lazarus_Linux_Console
Lazarus_Linux_GTK2
Lazarus_Linux_GTK3
Lazarus_Mac
Lazarus_Windows
ConsoleBrowser2
CookieVisitor
CustomResourceBrowser
DOMVisitor
EditorBrowser
ExternalPumpBrowser
FullScreenBrowser
JavaScript
JSDialog
JSEval
JSExecutingFunctions
JSExtension
JSExtensionSubProcess
JSExtensionWithFunction
00-Delete.bat
JSExtensionWithFunction.lpi
JSExtensionWithFunction.lpr
JSExtensionWithFunction.res
uJSExtensionWithFunction.lfm
uJSExtensionWithFunction.pas
uMyV8Handler.pas
JSExtensionWithObjectParameter
JSSharedMemoryProcMessage
JSSimpleExtension
JSSimpleWindowBinding
JSWindowBindingSubProcess
JSWindowBindingWithArrayBuffer
JSWindowBindingWithFunction
JSWindowBindingWithObject
MediaRouter
MiniBrowser
MobileBrowser
NetworkTrackerBrowser
OAuth2Tester
OSRExternalPumpBrowser
PopupBrowser
PopupBrowser2
PostInspectorBrowser
ResponseFilterBrowser
SchemeRegistrationBrowser
SchemeRegistrationBrowser_subprocess
SimpleBrowser
SimpleBrowser2
SimpleExternalPumpBrowser
SimpleOSRBrowser
SimpleOSRBrowser2
SimpleServer
SubProcess
TabbedBrowser
TabbedBrowser2
TinyBrowser
TinyBrowser2
ToolBoxBrowser
ToolBoxBrowser2
URLRequest
VirtualUIBrowser
WebpageSnapshot
Lazarus_any_OS
docs
packages
source
tools
.gitignore
Delphinus.Info.json
Delphinus.Install.json
LICENSE.md
README.md
update_CEF4Delphi.json
CEF4Delphi/demos/Lazarus_Windows/JavaScript/JSExtensionWithFunction/uMyV8Handler.pas
salvadordf a0c8eda6e0 Update to CEF 120.1.10
Added Lazarus 3.0 support
2023-12-23 18:58:40 +01:00

55 lines
1.4 KiB
ObjectPascal

unit uMyV8Handler;
{$MODE Delphi}
{$I ..\..\..\..\source\cef.inc}
interface
uses
uCEFTypes, uCEFInterfaces, uCEFv8Value, uCEFProcessMessage, uCEFv8Handler, uCEFv8Context;
const
TEST_MESSAGE_NAME = 'test_message';
type
TMyV8Handler = class(TCefv8HandlerOwn)
protected
function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; override;
end;
implementation
function TMyV8Handler.Execute(const name : ustring;
const obj : ICefv8Value;
const arguments : TCefv8ValueArray;
var retval : ICefv8Value;
var exception : ustring): Boolean;
var
TempMessage : ICefProcessMessage;
TempFrame : ICefFrame;
begin
Result := False;
try
if (name = 'myfunc') then
begin
TempMessage := TCefProcessMessageRef.New(TEST_MESSAGE_NAME);
TempMessage.ArgumentList.SetString(0, 'Message received!');
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
if (TempFrame <> nil) and TempFrame.IsValid then
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
retval := TCefv8ValueRef.NewString('My Value!');
Result := True;
end;
finally
TempMessage := nil;
end;
end;
end.