1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-07-02 22:26:53 +02:00
Files
.github
bin
demos
Delphi_FMX_Linux
Delphi_FMX_Mac
Delphi_FMX_Windows
Delphi_UniGUI
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
00-Delete.bat
JSExtension.lpi
JSExtension.lpr
JSExtension.res
uJSExtension.lfm
uJSExtension.pas
uSimpleTextViewer.lfm
uSimpleTextViewer.pas
uTestExtensionHandler.pas
JSExtensionSubProcess
JSExtensionWithFunction
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

74 lines
2.2 KiB
ObjectPascal
Raw Permalink Normal View History

unit uTestExtensionHandler;
{$MODE Delphi}
{$I ..\..\..\..\source\cef.inc}
interface
uses
LCLIntf, LCLType, LMessages,
uCEFRenderProcessHandler, uCEFBrowserProcessHandler, uCEFInterfaces, uCEFProcessMessage,
uCEFv8Context, uCEFTypes, uCEFv8Handler;
type
TTestExtensionHandler = class(TCefv8HandlerOwn)
protected
function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; override;
end;
implementation
uses
uCEFMiscFunctions, uCEFConstants, uJSExtension;
function TTestExtensionHandler.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 = 'mouseover') then
begin
if (length(arguments) > 0) and arguments[0].IsString then
begin
TempMessage := TCefProcessMessageRef.New(MOUSEOVER_MESSAGE_NAME);
TempMessage.ArgumentList.SetString(0, arguments[0].GetStringValue);
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
if (TempFrame <> nil) and TempFrame.IsValid then
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
end;
Result := True;
end
else
if (name = 'sendresulttobrowser') then
begin
if (length(arguments) > 1) and arguments[0].IsString and arguments[1].IsString then
begin
TempMessage := TCefProcessMessageRef.New(arguments[1].GetStringValue);
TempMessage.ArgumentList.SetString(0, arguments[0].GetStringValue);
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
if (TempFrame <> nil) and TempFrame.IsValid then
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
end;
Result := True;
end;
finally
TempMessage := nil;
end;
end;
end.