mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-12 10:26:05 +02:00
Added CefLazApplication: Provide RegisterHandler for ContextInitialized
This commit is contained in:
parent
b9c57057b8
commit
605d31f8cf
@ -22,7 +22,7 @@
|
|||||||
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
|
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
|
||||||
<License Value="MPL 1.1"/>
|
<License Value="MPL 1.1"/>
|
||||||
<Version Major="89" Release="6"/>
|
<Version Major="89" Release="6"/>
|
||||||
<Files Count="200">
|
<Files Count="201">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||||
<UnitName Value="uCEFAccessibilityHandler"/>
|
<UnitName Value="uCEFAccessibilityHandler"/>
|
||||||
@ -840,6 +840,10 @@
|
|||||||
<HasRegisterProc Value="True"/>
|
<HasRegisterProc Value="True"/>
|
||||||
<UnitName Value="uceflazarusbrowserwindow"/>
|
<UnitName Value="uceflazarusbrowserwindow"/>
|
||||||
</Item200>
|
</Item200>
|
||||||
|
<Item201>
|
||||||
|
<Filename Value="..\source\uCEFLazApplication.pas"/>
|
||||||
|
<UnitName Value="uCEFLazApplication"/>
|
||||||
|
</Item201>
|
||||||
</Files>
|
</Files>
|
||||||
<RequiredPkgs Count="4">
|
<RequiredPkgs Count="4">
|
||||||
<Item1>
|
<Item1>
|
||||||
|
@ -65,8 +65,8 @@ uses
|
|||||||
uCEFMediaSinkDeviceInfoCallback, uCEFJson, uCEFBitmapBitBuffer,
|
uCEFMediaSinkDeviceInfoCallback, uCEFJson, uCEFBitmapBitBuffer,
|
||||||
uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback,
|
uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback,
|
||||||
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants,
|
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants,
|
||||||
uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa,
|
uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa,
|
||||||
uCEFLazarusBrowserWindow, LazarusPackageIntf;
|
uCEFLazarusBrowserWindow, uCEFLazApplication, LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ type
|
|||||||
// ICefLoadHandler and ICefPrintHandler should use them.
|
// ICefLoadHandler and ICefPrintHandler should use them.
|
||||||
procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
||||||
procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
||||||
procedure Internal_OnContextInitialized;
|
procedure Internal_OnContextInitialized; virtual;
|
||||||
procedure Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
procedure Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||||
procedure Internal_OnScheduleMessagePumpWork(const delayMs: Int64);
|
procedure Internal_OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||||
function Internal_GetLocalizedString(stringId: Integer; var stringVal: ustring) : boolean;
|
function Internal_GetLocalizedString(stringId: Integer; var stringVal: ustring) : boolean;
|
||||||
|
80
source/uCEFLazApplication.pas
Normal file
80
source/uCEFLazApplication.pas
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
unit uCEFLazApplication;
|
||||||
|
|
||||||
|
{$IFDEF FPC}
|
||||||
|
{$MODE OBJFPC}{$H+}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$I cef.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF DELPHI16_UP}
|
||||||
|
{$ELSE}
|
||||||
|
Forms, LclProc, Classes, SysUtils,
|
||||||
|
{$ENDIF}
|
||||||
|
uCEFTypes, uCEFApplication;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TCefLazApplication }
|
||||||
|
|
||||||
|
TCefLazApplication = class(TCefApplication)
|
||||||
|
protected
|
||||||
|
FContextInitializedHandlers: TMethodList;
|
||||||
|
FContextInitializedDone: Boolean;
|
||||||
|
|
||||||
|
procedure CallContextInitializedHandlers(Data: PtrInt);
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure Internal_OnContextInitialized; override; // In UI thread
|
||||||
|
|
||||||
|
Procedure AddContextInitializedHandler(AHandler: TNotifyEvent);
|
||||||
|
Procedure RemoveContextInitializedHandler(AHandler: TNotifyEvent);
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{ TCefLazApplication }
|
||||||
|
|
||||||
|
procedure TCefLazApplication.Internal_OnContextInitialized;
|
||||||
|
begin
|
||||||
|
inherited Internal_OnContextInitialized;
|
||||||
|
Application.QueueAsyncCall(@CallContextInitializedHandlers, 0);
|
||||||
|
//TThread.Queue(@CallContextInitializedHandlers);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefLazApplication.CallContextInitializedHandlers(Data: PtrInt);
|
||||||
|
begin
|
||||||
|
FContextInitializedHandlers.CallNotifyEvents(Self);
|
||||||
|
FContextInitializedDone := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TCefLazApplication.Create;
|
||||||
|
begin
|
||||||
|
FContextInitializedHandlers := TMethodList.Create;
|
||||||
|
inherited Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCefLazApplication.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
FContextInitializedHandlers.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefLazApplication.AddContextInitializedHandler(AHandler: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
FContextInitializedHandlers.Add(TMethod(AHandler));
|
||||||
|
if FContextInitializedDone then
|
||||||
|
AHandler(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefLazApplication.RemoveContextInitializedHandler(
|
||||||
|
AHandler: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
FContextInitializedHandlers.Remove(TMethod(AHandler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user