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

Added TCEFSentinel to more demos

- Check that all frames are valid before using them
- Added an error page to MiniBrowser.
This commit is contained in:
Salvador Díaz Fau
2019-10-13 18:50:23 +02:00
parent 9391d68ee0
commit 77121dc510
89 changed files with 1097 additions and 522 deletions

View File

@ -67,35 +67,46 @@ function TTestExtensionHandler.Execute(const name : ustring;
var retval : ICefv8Value;
var exception : ustring): Boolean;
var
msg: ICefProcessMessage;
TempMessage : ICefProcessMessage;
TempFrame : ICefFrame;
begin
if (name = 'mouseover') then
begin
if (length(arguments) > 0) and arguments[0].IsString then
begin
msg := TCefProcessMessageRef.New(MOUSEOVER_MESSAGE_NAME);
msg.ArgumentList.SetString(0, arguments[0].GetStringValue);
Result := False;
TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage(PID_BROWSER, msg);
end;
Result := True;
end
else
if (name = 'sendresulttobrowser') then
try
if (name = 'mouseover') then
begin
if (length(arguments) > 1) and arguments[0].IsString and arguments[1].IsString then
if (length(arguments) > 0) and arguments[0].IsString then
begin
msg := TCefProcessMessageRef.New(arguments[1].GetStringValue);
msg.ArgumentList.SetString(0, arguments[0].GetStringValue);
TempMessage := TCefProcessMessageRef.New(MOUSEOVER_MESSAGE_NAME);
TempMessage.ArgumentList.SetString(0, arguments[0].GetStringValue);
TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage(PID_BROWSER, msg);
TempFrame := TCefv8ContextRef.Current.Browser.MainFrame;
if (TempFrame <> nil) and TempFrame.IsValid then
TempFrame.SendProcessMessage(PID_BROWSER, TempMessage);
end;
Result := True;
end
else
Result := False;
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.