mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-16 00:05:55 +01:00
Fixed TChromium.OnDevToolsEvent declaration
Added more parameter checks to CefString. Added TChromium.DestroyAllHandlersAndObservers which includes DestroyDevToolsMsgObserver to fix issue #288.
This commit is contained in:
parent
5bfeb8de3f
commit
51658e03f2
@ -385,6 +385,7 @@ type
|
|||||||
procedure DestroyResourceRequestHandler;
|
procedure DestroyResourceRequestHandler;
|
||||||
procedure DestroyMediaObserver;
|
procedure DestroyMediaObserver;
|
||||||
procedure DestroyDevToolsMsgObserver;
|
procedure DestroyDevToolsMsgObserver;
|
||||||
|
procedure DestroyAllHandlersAndObservers;
|
||||||
|
|
||||||
procedure CreateReqContextHandler;
|
procedure CreateReqContextHandler;
|
||||||
procedure CreateResourceRequestHandler;
|
procedure CreateResourceRequestHandler;
|
||||||
@ -582,7 +583,7 @@ type
|
|||||||
// ICefDevToolsMessageObserver
|
// ICefDevToolsMessageObserver
|
||||||
procedure doOnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean); virtual;
|
procedure doOnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean); virtual;
|
||||||
procedure doOnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue); virtual;
|
procedure doOnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue); virtual;
|
||||||
procedure doOnDevToolsEvent(const method: ustring; const params: ICefValue); virtual;
|
procedure doOnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: ICefValue); virtual;
|
||||||
procedure doOnDevToolsAgentAttached(const browser: ICefBrowser); virtual;
|
procedure doOnDevToolsAgentAttached(const browser: ICefBrowser); virtual;
|
||||||
procedure doOnDevToolsAgentDetached(const browser: ICefBrowser); virtual;
|
procedure doOnDevToolsAgentDetached(const browser: ICefBrowser); virtual;
|
||||||
|
|
||||||
@ -1244,6 +1245,7 @@ end;
|
|||||||
|
|
||||||
procedure TChromiumCore.BeforeDestruction;
|
procedure TChromiumCore.BeforeDestruction;
|
||||||
begin
|
begin
|
||||||
|
try
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
RestoreCompWndProc(FBrowserCompHWND, 0, FOldBrowserCompWndPrc);
|
RestoreCompWndProc(FBrowserCompHWND, 0, FOldBrowserCompWndPrc);
|
||||||
FreeAndNilStub(FBrowserCompStub);
|
FreeAndNilStub(FBrowserCompStub);
|
||||||
@ -1255,14 +1257,11 @@ begin
|
|||||||
FreeAndNilStub(FRenderCompStub);
|
FreeAndNilStub(FRenderCompStub);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
DestroyClientHandler;
|
DestroyAllHandlersAndObservers;
|
||||||
DestroyReqContextHandler;
|
finally
|
||||||
DestroyResourceRequestHandler;
|
|
||||||
DestroyMediaObserver;
|
|
||||||
DestroyDevToolsMsgObserver;
|
|
||||||
|
|
||||||
inherited BeforeDestruction;
|
inherited BeforeDestruction;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
@ -1414,39 +1413,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChromiumCore.CreateReqContextHandler;
|
|
||||||
begin
|
|
||||||
if MustCreateRequestContextHandler and
|
|
||||||
(FReqContextHandler = nil) then
|
|
||||||
FReqContextHandler := TCustomRequestContextHandler.Create(self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChromiumCore.DestroyMediaObserver;
|
|
||||||
begin
|
|
||||||
FMediaObserverReg := nil;
|
|
||||||
FMediaObserver := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChromiumCore.CreateMediaObserver;
|
|
||||||
begin
|
|
||||||
if MustCreateMediaObserver and
|
|
||||||
(FMediaObserver = nil) then
|
|
||||||
FMediaObserver := TCustomMediaObserver.Create(self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChromiumCore.DestroyDevToolsMsgObserver;
|
|
||||||
begin
|
|
||||||
FDevToolsMsgObserverReg := nil;
|
|
||||||
FDevToolsMsgObserver := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChromiumCore.CreateDevToolsMsgObserver;
|
|
||||||
begin
|
|
||||||
if MustCreateDevToolsMessageObserver and
|
|
||||||
(FDevToolsMsgObserver = nil) then
|
|
||||||
FDevToolsMsgObserver := TCustomDevToolsMessageObserver.Create(self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChromiumCore.DestroyResourceRequestHandler;
|
procedure TChromiumCore.DestroyResourceRequestHandler;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
@ -1461,6 +1427,48 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.DestroyMediaObserver;
|
||||||
|
begin
|
||||||
|
FMediaObserverReg := nil;
|
||||||
|
FMediaObserver := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.DestroyDevToolsMsgObserver;
|
||||||
|
begin
|
||||||
|
FDevToolsMsgObserverReg := nil;
|
||||||
|
FDevToolsMsgObserver := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.DestroyAllHandlersAndObservers;
|
||||||
|
begin
|
||||||
|
DestroyDevToolsMsgObserver;
|
||||||
|
DestroyMediaObserver;
|
||||||
|
DestroyResourceRequestHandler;
|
||||||
|
DestroyReqContextHandler;
|
||||||
|
DestroyClientHandler;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.CreateReqContextHandler;
|
||||||
|
begin
|
||||||
|
if MustCreateRequestContextHandler and
|
||||||
|
(FReqContextHandler = nil) then
|
||||||
|
FReqContextHandler := TCustomRequestContextHandler.Create(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.CreateMediaObserver;
|
||||||
|
begin
|
||||||
|
if MustCreateMediaObserver and
|
||||||
|
(FMediaObserver = nil) then
|
||||||
|
FMediaObserver := TCustomMediaObserver.Create(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.CreateDevToolsMsgObserver;
|
||||||
|
begin
|
||||||
|
if MustCreateDevToolsMessageObserver and
|
||||||
|
(FDevToolsMsgObserver = nil) then
|
||||||
|
FDevToolsMsgObserver := TCustomDevToolsMessageObserver.Create(self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChromiumCore.CreateResourceRequestHandler;
|
procedure TChromiumCore.CreateResourceRequestHandler;
|
||||||
begin
|
begin
|
||||||
if MustCreateResourceRequestHandler and
|
if MustCreateResourceRequestHandler and
|
||||||
@ -5122,12 +5130,7 @@ begin
|
|||||||
RemoveBrowser(browser);
|
RemoveBrowser(browser);
|
||||||
|
|
||||||
if (BrowserCount = 0) then
|
if (BrowserCount = 0) then
|
||||||
begin
|
DestroyAllHandlersAndObservers;
|
||||||
DestroyMediaObserver;
|
|
||||||
DestroyResourceRequestHandler;
|
|
||||||
DestroyReqContextHandler;
|
|
||||||
DestroyClientHandler;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if assigned(FOnBeforeClose) then
|
if assigned(FOnBeforeClose) then
|
||||||
FOnBeforeClose(Self, browser);
|
FOnBeforeClose(Self, browser);
|
||||||
@ -5511,11 +5514,12 @@ begin
|
|||||||
FOnDevToolsMethodResult(self, browser, message_id, success, result);
|
FOnDevToolsMethodResult(self, browser, message_id, success, result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChromiumCore.doOnDevToolsEvent(const method : ustring;
|
procedure TChromiumCore.doOnDevToolsEvent(const browser : ICefBrowser;
|
||||||
|
const method : ustring;
|
||||||
const params : ICefValue);
|
const params : ICefValue);
|
||||||
begin
|
begin
|
||||||
if assigned(FOnDevToolsEvent) then
|
if assigned(FOnDevToolsEvent) then
|
||||||
FOnDevToolsEvent(self, method, params);
|
FOnDevToolsEvent(self, browser, method, params);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChromiumCore.doOnDevToolsAgentAttached(const browser: ICefBrowser);
|
procedure TChromiumCore.doOnDevToolsAgentAttached(const browser: ICefBrowser);
|
||||||
|
@ -183,7 +183,7 @@ type
|
|||||||
// ICefDevToolsMessageObserver
|
// ICefDevToolsMessageObserver
|
||||||
TOnDevToolsMessageEvent = procedure(Sender: TObject; const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean) of object;
|
TOnDevToolsMessageEvent = procedure(Sender: TObject; const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean) of object;
|
||||||
TOnDevToolsMethodResultEvent = procedure(Sender: TObject; const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue) of object;
|
TOnDevToolsMethodResultEvent = procedure(Sender: TObject; const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue) of object;
|
||||||
TOnDevToolsEventEvent = procedure(Sender: TObject; const method: ustring; const params: ICefValue) of object;
|
TOnDevToolsEventEvent = procedure(Sender: TObject; const browser: ICefBrowser; const method: ustring; const params: ICefValue) of object;
|
||||||
TOnDevToolsAgentAttachedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object;
|
TOnDevToolsAgentAttachedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object;
|
||||||
TOnDevToolsAgentDetachedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object;
|
TOnDevToolsAgentDetachedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean); virtual;
|
procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean); virtual;
|
||||||
procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue); virtual;
|
procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue); virtual;
|
||||||
procedure OnDevToolsEvent(const method: ustring; const params: ICefValue); virtual;
|
procedure OnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: ICefValue); virtual;
|
||||||
procedure OnDevToolsAgentAttached(const browser: ICefBrowser); virtual;
|
procedure OnDevToolsAgentAttached(const browser: ICefBrowser); virtual;
|
||||||
procedure OnDevToolsAgentDetached(const browser: ICefBrowser); virtual;
|
procedure OnDevToolsAgentDetached(const browser: ICefBrowser); virtual;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ type
|
|||||||
|
|
||||||
procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean); override;
|
procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean); override;
|
||||||
procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue); override;
|
procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue); override;
|
||||||
procedure OnDevToolsEvent(const method: ustring; const params: ICefValue); override;
|
procedure OnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: ICefValue); override;
|
||||||
procedure OnDevToolsAgentAttached(const browser: ICefBrowser); override;
|
procedure OnDevToolsAgentAttached(const browser: ICefBrowser); override;
|
||||||
procedure OnDevToolsAgentDetached(const browser: ICefBrowser); override;
|
procedure OnDevToolsAgentDetached(const browser: ICefBrowser); override;
|
||||||
|
|
||||||
@ -144,6 +144,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure cef_on_dev_tools_event( self : PCefDevToolsMessageObserver;
|
procedure cef_on_dev_tools_event( self : PCefDevToolsMessageObserver;
|
||||||
|
browser : PCefBrowser;
|
||||||
const method : PCefString;
|
const method : PCefString;
|
||||||
const params : Pointer;
|
const params : Pointer;
|
||||||
params_size : NativeUInt); stdcall;
|
params_size : NativeUInt); stdcall;
|
||||||
@ -156,7 +157,8 @@ begin
|
|||||||
if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then
|
if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then
|
||||||
try
|
try
|
||||||
TempValue := CefParseJson(params, params_size);
|
TempValue := CefParseJson(params, params_size);
|
||||||
TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsEvent(CefString(method),
|
TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsEvent(TCefBrowserRef.UnWrap(browser),
|
||||||
|
CefString(method),
|
||||||
TempValue);
|
TempValue);
|
||||||
finally
|
finally
|
||||||
TempValue := nil;
|
TempValue := nil;
|
||||||
@ -214,7 +216,8 @@ begin
|
|||||||
//
|
//
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEFDevToolsMessageObserverOwn.OnDevToolsEvent(const method : ustring;
|
procedure TCEFDevToolsMessageObserverOwn.OnDevToolsEvent(const browser : ICefBrowser;
|
||||||
|
const method : ustring;
|
||||||
const params : ICefValue);
|
const params : ICefValue);
|
||||||
begin
|
begin
|
||||||
//
|
//
|
||||||
@ -276,12 +279,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDevToolsMessageObserver.OnDevToolsEvent(const method : ustring;
|
procedure TCustomDevToolsMessageObserver.OnDevToolsEvent(const browser : ICefBrowser;
|
||||||
|
const method : ustring;
|
||||||
const params : ICefValue);
|
const params : ICefValue);
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
if (FEvents <> nil) then
|
if (FEvents <> nil) then
|
||||||
IChromiumEvents(FEvents).doOnDevToolsEvent(method, params);
|
IChromiumEvents(FEvents).doOnDevToolsEvent(browser, method, params);
|
||||||
except
|
except
|
||||||
on e : exception do
|
on e : exception do
|
||||||
if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsEvent', e) then raise;
|
if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsEvent', e) then raise;
|
||||||
|
@ -435,7 +435,7 @@ type
|
|||||||
// ICefDevToolsMessageObserver
|
// ICefDevToolsMessageObserver
|
||||||
procedure doOnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean);
|
procedure doOnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean);
|
||||||
procedure doOnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue);
|
procedure doOnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue);
|
||||||
procedure doOnDevToolsEvent(const method: ustring; const params: ICefValue);
|
procedure doOnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: ICefValue);
|
||||||
procedure doOnDevToolsAgentAttached(const browser: ICefBrowser);
|
procedure doOnDevToolsAgentAttached(const browser: ICefBrowser);
|
||||||
procedure doOnDevToolsAgentDetached(const browser: ICefBrowser);
|
procedure doOnDevToolsAgentDetached(const browser: ICefBrowser);
|
||||||
|
|
||||||
@ -1310,7 +1310,7 @@ type
|
|||||||
['{76E5BB2B-7F69-4BC9-94C7-B55C61CE630F}']
|
['{76E5BB2B-7F69-4BC9-94C7-B55C61CE630F}']
|
||||||
procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean);
|
procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean);
|
||||||
procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue);
|
procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue);
|
||||||
procedure OnDevToolsEvent(const method: ustring; const params: ICefValue);
|
procedure OnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: ICefValue);
|
||||||
procedure OnDevToolsAgentAttached(const browser: ICefBrowser);
|
procedure OnDevToolsAgentAttached(const browser: ICefBrowser);
|
||||||
procedure OnDevToolsAgentDetached(const browser: ICefBrowser);
|
procedure OnDevToolsAgentDetached(const browser: ICefBrowser);
|
||||||
end;
|
end;
|
||||||
|
@ -381,7 +381,7 @@ end;
|
|||||||
|
|
||||||
function CefString(const str: PCefString): ustring;
|
function CefString(const str: PCefString): ustring;
|
||||||
begin
|
begin
|
||||||
if (str <> nil) then
|
if (str <> nil) and (str^.str <> nil) and (str^.length > 0) and (str^.length < nativeuint(high(integer))) then
|
||||||
SetString(Result, str^.str, str^.length)
|
SetString(Result, str^.str, str^.length)
|
||||||
else
|
else
|
||||||
Result := '';
|
Result := '';
|
||||||
|
@ -1601,7 +1601,7 @@ type
|
|||||||
base : TCefBaseRefCounted;
|
base : TCefBaseRefCounted;
|
||||||
on_dev_tools_message : function(self: PCefDevToolsMessageObserver; browser: PCefBrowser; const message_: Pointer; message_size: NativeUInt): Integer; stdcall;
|
on_dev_tools_message : function(self: PCefDevToolsMessageObserver; browser: PCefBrowser; const message_: Pointer; message_size: NativeUInt): Integer; stdcall;
|
||||||
on_dev_tools_method_result : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser; message_id, success: Integer; const result: Pointer; result_size: NativeUInt); stdcall;
|
on_dev_tools_method_result : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser; message_id, success: Integer; const result: Pointer; result_size: NativeUInt); stdcall;
|
||||||
on_dev_tools_event : procedure(self: PCefDevToolsMessageObserver; const method: PCefString; const params: Pointer; params_size: NativeUInt); stdcall;
|
on_dev_tools_event : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser; const method: PCefString; const params: Pointer; params_size: NativeUInt); stdcall;
|
||||||
on_dev_tools_agent_attached : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser); stdcall;
|
on_dev_tools_agent_attached : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser); stdcall;
|
||||||
on_dev_tools_agent_detached : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser); stdcall;
|
on_dev_tools_agent_detached : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser); stdcall;
|
||||||
end;
|
end;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"UpdateLazPackages" : [
|
"UpdateLazPackages" : [
|
||||||
{
|
{
|
||||||
"ForceNotify" : true,
|
"ForceNotify" : true,
|
||||||
"InternalVersion" : 159,
|
"InternalVersion" : 160,
|
||||||
"Name" : "cef4delphi_lazarus.lpk",
|
"Name" : "cef4delphi_lazarus.lpk",
|
||||||
"Version" : "83.4.2.0"
|
"Version" : "83.4.2.0"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user