1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +02:00

The JSExtensionWithFunction demo now sends a text message back to the main process

This commit is contained in:
Salvador Díaz Fau
2018-03-21 11:21:41 +01:00
parent 7242c181a4
commit 665957e132
3 changed files with 42 additions and 2 deletions

View File

@ -42,7 +42,10 @@ unit uMyV8Handler;
interface
uses
uCEFTypes, uCEFInterfaces, uCEFv8Value, uCEFv8Handler;
uCEFTypes, uCEFInterfaces, uCEFv8Value, uCEFProcessMessage, uCEFv8Handler, uCEFv8Context;
const
TEST_MESSAGE_NAME = 'test_message';
type
TMyV8Handler = class(TCefv8HandlerOwn)
@ -57,9 +60,15 @@ function TMyV8Handler.Execute(const name : ustring;
const arguments : TCefv8ValueArray;
var retval : ICefv8Value;
var exception : ustring): Boolean;
var
msg: ICefProcessMessage;
begin
if (name = 'myfunc') then
begin
msg := TCefProcessMessageRef.New(TEST_MESSAGE_NAME);
msg.ArgumentList.SetString(0, 'Message received!');
TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg);
retval := TCefv8ValueRef.NewString('My Value!');
Result := True;
end