mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Added GlobalCEFApp.TouchEvents property
- Added TChromium.ExecuteTaskOnCefThread function. - Added TChromium.OnExecuteTaskOnCefThread event.
This commit is contained in:
parent
b218368d91
commit
86fd4a0c4d
@ -182,6 +182,7 @@ type
|
||||
FDisableSpellChecking : boolean;
|
||||
FOverrideSpellCheckLang : string;
|
||||
FEnablePrintPreview : boolean;
|
||||
FTouchEvents : TCefState;
|
||||
|
||||
FMustCreateResourceBundleHandler : boolean;
|
||||
FMustCreateBrowserProcessHandler : boolean;
|
||||
@ -424,6 +425,7 @@ type
|
||||
property EnableProfanityFilter : boolean read FEnableProfanityFilter write FEnableProfanityFilter; // --enable-profanity-filter
|
||||
property DisableSpellChecking : boolean read FDisableSpellChecking write FDisableSpellChecking; // --disable-spell-checking
|
||||
property OverrideSpellCheckLang : string read FOverrideSpellCheckLang write FOverrideSpellCheckLang; // --override-spell-check-lang
|
||||
property TouchEvents : TCefState read FTouchEvents write FTouchEvents; // --touch-events
|
||||
|
||||
// Properties used during the CEF initialization
|
||||
property WindowsSandboxInfo : Pointer read FWindowsSandboxInfo write FWindowsSandboxInfo;
|
||||
@ -638,6 +640,7 @@ begin
|
||||
FDisableSpellChecking := False;
|
||||
FOverrideSpellCheckLang := '';
|
||||
FEnablePrintPreview := False;
|
||||
FTouchEvents := STATE_DEFAULT;
|
||||
|
||||
FMustCreateResourceBundleHandler := False;
|
||||
FMustCreateBrowserProcessHandler := True;
|
||||
@ -1551,6 +1554,11 @@ begin
|
||||
STATE_DISABLED : commandLine.AppendSwitch('--disable-smooth-scrolling');
|
||||
end;
|
||||
|
||||
case FTouchEvents of
|
||||
STATE_ENABLED : commandLine.AppendSwitchWithValue('--touch-events', 'enabled');
|
||||
STATE_DISABLED : commandLine.AppendSwitchWithValue('--touch-events', 'disabled');
|
||||
end;
|
||||
|
||||
case FAutoplayPolicy of
|
||||
appDocumentUserActivationRequired :
|
||||
commandLine.AppendSwitchWithValue('--autoplay-policy', 'document-user-activation-required');
|
||||
|
@ -252,6 +252,7 @@ type
|
||||
FOnCertificateExceptionsCleared : TNotifyEvent;
|
||||
FOnHttpAuthCredentialsCleared : TNotifyEvent;
|
||||
FOnAllConnectionsClosed : TNotifyEvent;
|
||||
FOnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread;
|
||||
{$IFNDEF FPC}
|
||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||
@ -500,6 +501,7 @@ type
|
||||
procedure doCertificateExceptionsCleared; virtual;
|
||||
procedure doHttpAuthCredentialsCleared; virtual;
|
||||
procedure doAllConnectionsClosed; virtual;
|
||||
procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal); virtual;
|
||||
function MustCreateLoadHandler : boolean; virtual;
|
||||
function MustCreateFocusHandler : boolean; virtual;
|
||||
function MustCreateContextMenuHandler : boolean; virtual;
|
||||
@ -570,6 +572,7 @@ type
|
||||
procedure ResolveHost(const aURL : ustring);
|
||||
function TakeSnapshot(var aBitmap : TBitmap) : boolean;
|
||||
function IsSameBrowser(const aBrowser : ICefBrowser) : boolean;
|
||||
function ExecuteTaskOnCefThread(aCefThreadId : TCefThreadId; aTaskID : cardinal; aDelayMs : Int64 = 0) : boolean;
|
||||
|
||||
procedure ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl);
|
||||
procedure CloseDevTools(const aDevTools : TWinControl = nil);
|
||||
@ -715,6 +718,7 @@ type
|
||||
property OnCertificateExceptionsCleared : TNotifyEvent read FOnCertificateExceptionsCleared write FOnCertificateExceptionsCleared;
|
||||
property OnHttpAuthCredentialsCleared : TNotifyEvent read FOnHttpAuthCredentialsCleared write FOnHttpAuthCredentialsCleared;
|
||||
property OnAllConnectionsClosed : TNotifyEvent read FOnAllConnectionsClosed write FOnAllConnectionsClosed;
|
||||
property OnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread read FOnExecuteTaskOnCefThread write FOnExecuteTaskOnCefThread;
|
||||
{$IFNDEF FPC}
|
||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||
@ -1220,6 +1224,7 @@ begin
|
||||
FOnCertificateExceptionsCleared := nil;
|
||||
FOnHttpAuthCredentialsCleared := nil;
|
||||
FOnAllConnectionsClosed := nil;
|
||||
FOnExecuteTaskOnCefThread := nil;
|
||||
{$IFNDEF FPC}
|
||||
FOnBrowserCompMsg := nil;
|
||||
FOnWidgetCompMsg := nil;
|
||||
@ -2633,6 +2638,33 @@ begin
|
||||
Result := Initialized and (aBrowser <> nil) and FBrowser.IsSame(aBrowser);
|
||||
end;
|
||||
|
||||
// Calling ExecuteTaskOnCefThread function will trigger the TChromium.OnExecuteTaskOnCefThread event.
|
||||
// "aCefThreadId" indicates the CEF thread on which TChromium.OnExecuteTaskOnCefThread will be executed.
|
||||
// "aTaskID" is a custom ID used to identify the task that triggered the TChromium.OnExecuteTaskOnCefThread event.
|
||||
// "aDelayMs" is an optional delay in milliseconds to trigger the TChromium.OnExecuteTaskOnCefThread event.
|
||||
function TChromium.ExecuteTaskOnCefThread(aCefThreadId : TCefThreadId; aTaskID : cardinal; aDelayMs : Int64) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefGenericTask.Create(self, aTaskID);
|
||||
|
||||
if (aDelayMs <> 0) then
|
||||
CefPostDelayedTask(aCefThreadId, TempTask, aDelayMs)
|
||||
else
|
||||
CefPostTask(aCefThreadId, TempTask);
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromium.SimulateMouseWheel(aDeltaX, aDeltaY : integer);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
@ -3261,6 +3293,11 @@ begin
|
||||
if assigned(FOnAllConnectionsClosed) then FOnAllConnectionsClosed(self);
|
||||
end;
|
||||
|
||||
procedure TChromium.doOnExecuteTaskOnCefThread(aTaskID : cardinal);
|
||||
begin
|
||||
if assigned(FOnExecuteTaskOnCefThread) then FOnExecuteTaskOnCefThread(self, aTaskID);
|
||||
end;
|
||||
|
||||
function TChromium.MustCreateLoadHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnLoadStart) or
|
||||
|
@ -173,6 +173,7 @@ type
|
||||
TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object;
|
||||
TOnNavigationVisitorResultAvailableEvent = procedure(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer; var aResult : boolean) of object;
|
||||
TOnDownloadImageFinishedEvent = procedure(Sender: TObject; const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage) of object;
|
||||
TOnExecuteTaskOnCefThread = procedure(Sender: TObject; aTaskID : cardinal) of object;
|
||||
{$IFDEF MSWINDOWS}
|
||||
TOnCompMsgEvent = procedure(var aMessage: TMessage; var aHandled: Boolean) of object;
|
||||
{$ENDIF}
|
||||
|
@ -235,6 +235,7 @@ type
|
||||
FOnCertificateExceptionsCleared : TNotifyEvent;
|
||||
FOnHttpAuthCredentialsCleared : TNotifyEvent;
|
||||
FOnAllConnectionsClosed : TNotifyEvent;
|
||||
FOnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread;
|
||||
{$IFDEF MSWINDOWS}
|
||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||
@ -467,6 +468,7 @@ type
|
||||
procedure doCertificateExceptionsCleared; virtual;
|
||||
procedure doHttpAuthCredentialsCleared; virtual;
|
||||
procedure doAllConnectionsClosed; virtual;
|
||||
procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal); virtual;
|
||||
function MustCreateLoadHandler : boolean; virtual;
|
||||
function MustCreateFocusHandler : boolean; virtual;
|
||||
function MustCreateContextMenuHandler : boolean; virtual;
|
||||
@ -535,6 +537,7 @@ type
|
||||
procedure SavePreferences(const aFileName : string);
|
||||
procedure ResolveHost(const aURL : ustring);
|
||||
function IsSameBrowser(const aBrowser : ICefBrowser) : boolean;
|
||||
function ExecuteTaskOnCefThread(aCefThreadId : TCefThreadId; aTaskID : cardinal; aDelayMs : Int64 = 0) : boolean;
|
||||
|
||||
procedure ShowDevTools(inspectElementAt: TPoint);
|
||||
procedure CloseDevTools;
|
||||
@ -674,6 +677,7 @@ type
|
||||
property OnCertificateExceptionsCleared : TNotifyEvent read FOnCertificateExceptionsCleared write FOnCertificateExceptionsCleared;
|
||||
property OnHttpAuthCredentialsCleared : TNotifyEvent read FOnHttpAuthCredentialsCleared write FOnHttpAuthCredentialsCleared;
|
||||
property OnAllConnectionsClosed : TNotifyEvent read FOnAllConnectionsClosed write FOnAllConnectionsClosed;
|
||||
property OnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread read FOnExecuteTaskOnCefThread write FOnExecuteTaskOnCefThread;
|
||||
{$IFDEF MSWINDOWS}
|
||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||
@ -1123,6 +1127,7 @@ begin
|
||||
FOnCertificateExceptionsCleared := nil;
|
||||
FOnHttpAuthCredentialsCleared := nil;
|
||||
FOnAllConnectionsClosed := nil;
|
||||
FOnExecuteTaskOnCefThread := nil;
|
||||
end;
|
||||
|
||||
function TFMXChromium.CreateBrowser(const aWindowName : ustring;
|
||||
@ -2381,6 +2386,33 @@ begin
|
||||
Result := Initialized and (aBrowser <> nil) and FBrowser.IsSame(aBrowser);
|
||||
end;
|
||||
|
||||
// Calling ExecuteTaskOnCefThread function will trigger the TChromium.OnExecuteTaskOnCefThread event.
|
||||
// "aCefThreadId" indicates the CEF thread on which TChromium.OnExecuteTaskOnCefThread will be executed.
|
||||
// "aTaskID" is a custom ID used to identify the task that triggered the TChromium.OnExecuteTaskOnCefThread event.
|
||||
// "aDelayMs" is an optional delay in milliseconds to trigger the TChromium.OnExecuteTaskOnCefThread event.
|
||||
function TFMXChromium.ExecuteTaskOnCefThread(aCefThreadId : TCefThreadId; aTaskID : cardinal; aDelayMs : Int64) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefGenericTask.Create(self, aTaskID);
|
||||
|
||||
if (aDelayMs <> 0) then
|
||||
CefPostDelayedTask(aCefThreadId, TempTask, aDelayMs)
|
||||
else
|
||||
CefPostTask(aCefThreadId, TempTask);
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFMXChromium.SimulateMouseWheel(aDeltaX, aDeltaY : integer);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
@ -3003,6 +3035,11 @@ begin
|
||||
if assigned(FOnAllConnectionsClosed) then FOnAllConnectionsClosed(self);
|
||||
end;
|
||||
|
||||
procedure TFMXChromium.doOnExecuteTaskOnCefThread(aTaskID : cardinal);
|
||||
begin
|
||||
if assigned(FOnExecuteTaskOnCefThread) then FOnExecuteTaskOnCefThread(self, aTaskID);
|
||||
end;
|
||||
|
||||
function TFMXChromium.MustCreateLoadHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnLoadStart) or
|
||||
|
@ -393,6 +393,7 @@ type
|
||||
procedure doCertificateExceptionsCleared;
|
||||
procedure doHttpAuthCredentialsCleared;
|
||||
procedure doAllConnectionsClosed;
|
||||
procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal);
|
||||
function MustCreateLoadHandler : boolean;
|
||||
function MustCreateFocusHandler : boolean;
|
||||
function MustCreateContextMenuHandler : boolean;
|
||||
|
@ -113,6 +113,18 @@ type
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefGenericTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
FTaskID : cardinal;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; aTaskID : cardinal); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -283,4 +295,36 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
// TCefGenericTask
|
||||
|
||||
procedure TCefGenericTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnExecuteTaskOnCefThread(FTaskID);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefGenericTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefGenericTask.Create(const aEvents : IChromiumEvents; aTaskID : cardinal);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
FTaskID := aTaskID;
|
||||
end;
|
||||
|
||||
destructor TCefGenericTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 46,
|
||||
"InternalVersion" : 47,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "77.1.14.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user